CVE-2021-45459: Command Injection in node-windows
Summary
CVE-2021-45459: Command Injection in node-windows. Affects node-windows versions < 1.0.0-beta.6. Fixed in 1.0.0-beta.6. 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 node-windows package is an npm package for Node.js that provides a set of tools for creating Windows services using Node.js. It allows developers to interact with the Windows API and perform various system-level operations. The package is widely used in Node.js applications running on Windows systems. However, a vulnerability has been discovered in versions prior to 1.0.0-beta.6 that allows command injection via the PID parameter.
Vulnerability Detail
The vulnerability in the node-windows package arises from a lack of input validation and sanitization in the lib/cmd.js file. An attacker can exploit this vulnerability by injecting malicious commands through the PID parameter. This can lead to arbitrary command execution with the privileges of the user running the Node.js application. The impact of this vulnerability can be severe, as an attacker can execute arbitrary commands on the underlying Windows system, potentially compromising its integrity and confidentiality.
How To Fix
Minimum fixed version
1.0.0-beta.6
This is the first release that contains the fix.
npm install node-windows@1.0.0-beta.6
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version is not immediately possible, a temporary workaround is to manually validate and sanitize any user-supplied input before using it in commands. This can be done by implementing input validation and sanitization routines in the application code. For example, using regular expressions or input validation libraries to ensure that the PID parameter only contains valid numeric values.
Conclusion
The command injection vulnerability in the node-windows package can be mitigated by upgrading to the latest version and implementing proper input validation and sanitization. It is crucial for developers to stay updated with security patches and follow best practices to ensure the security of their Node.js applications. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for node-windows →
FAQ
The node-windows package is an npm package for Node.js that provides tools for creating Windows services using Node.js.
Command injection is a security vulnerability that allows an attacker to execute arbitrary commands on a target system by injecting malicious input into a command execution context.
The impact of this vulnerability can be severe, as an attacker can execute arbitrary commands on the underlying Windows system, potentially compromising its integrity and confidentiality.
To fix this vulnerability, it is recommended to upgrade to version 1.0.0-beta.6 or later of the node-windows package and ensure that user-supplied input is properly validated and sanitized.
If upgrading to the latest version is not immediately possible, a temporary workaround is to manually validate and sanitize user-supplied input before using it in commands.