CVE-2021-45459: Command Injection in node-windows

node-windows Updated 02 Oct 2025

Summary

05/01/2022
Yes i
Critical
9.8

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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 →

Share this vulnerability

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.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback