CVE-2021-29369

9.8 CRITICAL

📋 TL;DR

CVE-2021-29369 is a critical OS command injection vulnerability in the @rkesters/gnuplot Node.js package. It allows attackers to execute arbitrary shell commands by injecting metacharacters into Gnuplot commands. This affects any Node.js application using vulnerable versions of this package.

💻 Affected Systems

Products:
  • @rkesters/gnuplot Node.js package
Versions: All versions prior to 0.1.0
Operating Systems: All platforms where Node.js runs
Default Config Vulnerable: ⚠️ Yes
Notes: Any application that passes user-controlled input to gnuplot commands is vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with remote code execution, allowing attackers to install malware, exfiltrate data, or pivot to other systems.

🟠

Likely Case

Remote code execution within the application context, potentially leading to data theft, service disruption, or lateral movement.

🟢

If Mitigated

Limited impact if proper input validation and sandboxing are implemented, potentially only causing application crashes.

🌐 Internet-Facing: HIGH - Web applications using this package could be exploited remotely without authentication.
🏢 Internal Only: MEDIUM - Internal applications could be exploited by authenticated users or through other attack vectors.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation is straightforward - attackers can inject shell metacharacters into gnuplot commands.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.1.0 and later

Vendor Advisory: https://github.com/rkesters/gnuplot/commit/23671d4d3d28570fb19a936a6328bfac742410de

Restart Required: Yes

Instructions:

1. Update package.json to require '@rkesters/gnuplot': '>=0.1.0'. 2. Run 'npm update @rkesters/gnuplot'. 3. Restart your Node.js application.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to reject any input containing shell metacharacters before passing to gnuplot commands.

// JavaScript example: if (/[;&|`$()\[\]{}<>]/g.test(userInput)) { rejectInput(); }

Sandbox Execution

all

Run the gnuplot process in a restricted environment with limited permissions.

// Use child_process with restricted environment variables and user permissions

🧯 If You Can't Patch

  • Implement strict input validation to reject shell metacharacters in all user-controlled inputs passed to gnuplot.
  • Run the Node.js application with minimal privileges and in a containerized/sandboxed environment.

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list @rkesters/gnuplot' to see if version is below 0.1.0.

Check Version:

npm list @rkesters/gnuplot

Verify Fix Applied:

Confirm version is 0.1.0 or higher with 'npm list @rkesters/gnuplot' and test that shell metacharacters in gnuplot commands no longer execute.

📡 Detection & Monitoring

Log Indicators:

  • Unexpected shell commands in application logs
  • Gnuplot process spawning unexpected child processes
  • Application crashes with command execution errors

Network Indicators:

  • Unexpected outbound connections from the Node.js process
  • Data exfiltration patterns

SIEM Query:

process.name: 'node' AND (process.args: '*gnuplot*' AND process.args: '*[;&|`$()]*')

🔗 References

📤 Share & Export