TechNews
cross-spawn fixes critical command injection when Node.js apps run batch files on Windows
CVE-2026-137199 in the cross-spawn npm package lets a crafted argument break out of its quotes when a batch file such as npm.cmd runs on Windows. Versions 7.1.0 and 6.0.7 fix it; other platforms are not affected.
9.2 CriticalPatch available
- Severity
- 9.2 Critical
CVSS 9.2, Critical - Status
- Patch available
- Product
- cross-spawn (npm package)
Am I affected?
Check your version- Affected
- versions before 6.0.7, and 7.0.0 up to but not including 7.1.0
- Fixed in
- 6.0.7 and 7.1.0
What to do now:
- Update cross-spawn to 7.1.0 or later, or to 6.0.7 on the 6.x line. It is usually a dependency of another package: run npm ls cross-spawn to find every copy.
- On Windows, do not pass untrusted input as arguments to batch files (.bat or .cmd). Call executables directly.
- Remember that options.shell is not escaped by design, before and after this fix.
The maintainers of cross-spawn, one of the most widely used packages on npm, have fixed a critical flaw that lets a crafted argument run extra commands when a Node.js program starts a batch file on Windows. The advisory, CVE-2026-137199, was published on Dec 1 and is rated 9.2 under CVSS 4.0.
cross-spawn is a small library that starts other programs the same way on every operating system. Many tools depend on it, often indirectly: npm counted about 346 million downloads of the package in the week of Nov 24 to Nov 30.
What goes wrong
On Windows, programs that are not .exe or .com files, such as batch files (.bat or .cmd), run through cmd.exe. cross-spawn escapes the command and its arguments for it.
A batch file that passes its arguments on, for example with %*, makes cmd.exe read them a second time. According to the advisory, cross-spawn only accounted for that second pass when the batch file was an npm shim in node_modules/.bin. For any other batch file, such as npm.cmd, globally installed package shims or a user’s own batch files, a crafted argument could break out of its quotes. The advisory’s example runs the Windows calculator:
const spawn = require('cross-spawn');
// Runs calc.exe on Windows
spawn.sync('npm', ['" & calc & "']);The advisory lists three more weaknesses fixed at the same time:
- Batch file detection could be bypassed with trailing dots or spaces in the command name, such as
tool.bat, which Windows removes. %VAR%in an argument was expanded if an environment variable namedVAR^existed.!VAR!in an argument was expanded if delayed expansion was enabled in the registry.
Who is affected
Programs are affected if they pass untrusted input as arguments to a command that runs through cmd.exe on Windows. Other operating systems are not affected. Neither is the shell option, which does not escape the command or its arguments by design.
The CVSS 4.0 rating marks the attack as high complexity with specific preconditions, because the input has to reach a batch file on Windows.
The fix
Versions 7.1.0 and 6.0.7, released on Nov 28, fix the flaw. Version 8.0.0, released a day later, is outside the affected ranges. The fixed versions quote batch file arguments with double quotes, the approach Rust adopted after the BatBadBut vulnerability (CVE-2024-24576). It also neutralizes %, starts cmd.exe with /e:on /v:off, strips trailing dots and spaces before detecting batch files, and rejects line breaks, which cmd.exe cannot escape, with a TypeError.
Some cases cannot be fixed by any escaping, the maintainers warn, such as batch files that use %~1 without quotes. For those, the advice is to validate input and call executables directly.
What to do now
Update cross-spawn wherever it appears in your dependency tree, including through other packages, and keep untrusted input away from batch files on Windows.
Sources
Spotted a mistake? Report an error
Related coverage
More in Tech ›TechNews
node-tar 8 fixes 20 archive flaws, including symlink escapes, but needs Node.js 22
TechNews
Rack, Mongoose and DOMPurify flaws get CVEs this week, but the fixes have been out since November
TechNews