CVE-2026-137199: cross-spawn: Command injection on Windows when spawning batch files
cross-spawn is a cross-platform solution for Node.js spawn and spawnSync. Prior to 6.0.7 and 7.1.0, Windows applications that pass untrusted arguments to commands routed through cmd.exe can be vulnerable because cross-spawn did not account for the second cmd.exe parse performed when a batch file outside nodemodules/.bin forwards its arguments. A crafted argument could break out of its quotes and execute arbitrary commands through npm.cmd, globally installed package shims, or user batch files. Trailing dots or spaces could bypass batch-file detection. A percent-delimited variable in an argument could be expanded when an environment variable with the same name followed by a caret existed, and an exclamation-delimited variable could be expanded when delayed expansion was enabled in the registry. Other platforms and the intentionally unescaped options.shell mode are not affected. This issue is fixed in versions 6.0.7 and 7.1.0.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/cross-spawnto a version that resolves this vulnerability.Fixed in 6.0.7 - Upgrade
Upgrade
npm/cross-spawnto a version that resolves this vulnerability.Fixed in 7.1.0
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Only Windows applications are affected, and only when they pass untrusted arguments to commands that are routed through cmd.exe and ultimately invoke a batch file outside node_modules/.bin. Other platforms are not affected.
What attacker-controlled input is required for exploitation?
An attacker must be able to supply crafted command arguments. The risk arises when those arguments are forwarded through batch files such as npm.cmd, globally installed package shims, or user batch files, allowing a value to escape quoting during cmd.exe's second parse.
Are default cross-spawn uses affected?
The issue does not affect the intentionally unescaped options.shell mode, and it requires the specific Windows cmd.exe and external batch-file forwarding path. Batch-file detection could also be bypassed with trailing dots or spaces.
What versions contain the fix?
Upgrade to cross-spawn 6.0.7 or 7.1.0. Versions before those releases are affected under the described Windows execution conditions.
Are there environment-dependent exploitation conditions?
Yes. Percent-delimited variables may expand when an environment variable with the same name followed by a caret exists, while exclamation-delimited variables may expand when delayed expansion is enabled in the registry.