cross-spawn: Command injection on Windows when the command is not a plain program name or pathGHSA-w3gc-668g-rf8f
HIGHFix: moxystudio/node-cross-spawn#196GHSA-w3gc-668g-rf8f is a high-severity (CVSS 8.1) OS Command Injection vulnerability in cross-spawn. A fix is available for cross-spawn — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-w3gc-668g-rf8f.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
cross-spawn📦cross-spawnReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Impact
On Windows, cross-spawn runs commands that aren't executables, such as batch files (.bat and .cmd), through cmd.exe, and escapes their arguments for it. Batch files need a stricter escaping, because cmd.exe parses their arguments a second time. 7.1.0 and 6.0.7 fixed that escaping (GHSA-ghv9-86vm-4v8m), but it only applies when cross-spawn detects that the command is a batch file.
The detection could be bypassed when the command isn't written as a plain program name or path, while cmd.exe still runs a batch file:
- the command contains double quotes, e.g.
spawn('"tool.bat"', args)orspawn('"tool"', args); - the command contains a space, tab,
,,;or=, wherecmd.exeends the command name, e.g.spawn('npm install', args), which runsnpm.cmd; - the command ends with a tab or other whitespace;
- the
PATHEXTpassed inoptions.envmakescmd.exefind a batch file that the parent'sPATHEXTdoesn't.
In those cases the arguments were escaped for a regular program, and an argument such as "&calc could run arbitrary commands.
Applications are affected if they run on Windows, pass a command in one of these forms, and pass untrusted input as arguments.
Patches
Fixed in 7.1.1 and 6.0.8. The command is now always quoted when it runs through cmd.exe, so cmd.exe treats it as a single name. Double quotes are removed from it first, since Windows file names can't contain them, and it's looked up with the child's PATHEXT. As a consequence, the command must be the name or path of a single program, as documented: spawn('npm install') now fails with ENOENT, like on other platforms.
Versions before 6.0.0 are not maintained and won't be fixed. Upgrade to 7.1.1, or force it with overrides in package.json.
Workarounds
Pass the program as the command and its arguments in args, without quotes, e.g. spawn('npm', ['install', ...]), and don't set PATHEXT in options.env.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | cross-spawn | ≥ 7.0.0&&< 7.1.1 | 7.1.1npm install cross-spawn@7.1.1 |
| 📦npm | cross-spawn | all versions | 6.0.8npm install cross-spawn@6.0.8 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for cross-spawn, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update cross-spawn to 7.1.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-w3gc-668g-rf8f is resolved across your whole dependency graph.
Workarounds
Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
Frequently Asked Questions
Is GHSA-w3gc-668g-rf8f in your dependencies?
Find it across npm, including transitive dependencies.