CVE-2020-7785: Command injection in node-ps
Summary
CVE-2020-7785: Command injection in node-ps. Affects node-ps versions < 0.0.2. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The package under scrutiny is node-ps, an npm package. It provides functionality for executing system commands and retrieving information about running processes in a Node.js environment. The vulnerability affects all versions of the package. It is important to note that the injection point is located in line 72 of the lib/index.js file.
Vulnerability Detail
The vulnerability in node-ps is a command injection vulnerability. This means that an attacker can manipulate user input to execute arbitrary commands on the system. The injection point in line 72 of lib/index.js allows an attacker to inject malicious commands, potentially leading to unauthorized access, data leakage, or remote code execution. This vulnerability has a CVSS score of 9.8, indicating its critical severity.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
If updating the package is not immediately feasible, a temporary workaround can be implemented by sanitizing user input and ensuring that any command execution is properly validated and restricted. Here is an example of how to sanitize user input in Node.js:
const { exec } = require('child_process');
function executeCommand(command) {
const sanitizedCommand = command.replace(/[&|;$`\<>]/g, '');
exec(sanitizedCommand, (error, stdout, stderr) => {
// Handle command execution results
});
}
Conclusion
In conclusion, the node-ps package is vulnerable to a command injection vulnerability that allows attackers to execute arbitrary commands on the system. It is crucial to update the package to a secure version or implement the provided workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for node-ps →
FAQ
Node-ps is an npm package that provides functionality for executing system commands and retrieving information about running processes in a Node.js environment.
A command injection vulnerability allows an attacker to manipulate user input to execute arbitrary commands on the system, potentially leading to unauthorized access, data leakage, or remote code execution.
This vulnerability in node-ps can allow an attacker to execute arbitrary commands on the system, potentially leading to unauthorized access, data leakage, or remote code execution.
To fix this vulnerability, it is recommended to update the node-ps package to a version that includes a patch for the command injection issue. The package maintainers have addressed this vulnerability in version 0.0.3 and later. Users should update their package dependencies to the latest secure version.
If updating the package is not immediately feasible, a temporary workaround can be implemented by sanitizing user input and ensuring that any command execution is properly validated and restricted.