A new cross-spawn vulnerability turns a crafted argument into arbitrary commands on Windows, and the package sits in almost every Node.js dependency tree. Between November 28 and 29, the maintainers shipped fixes for three related bugs in how cross-spawn escapes commands for cmd.exe. The worst, CVE-2026-137199, has been listed as critical in the GitHub Advisory Database since December 1, with a CVSS 4.0 score of 9.2. If your code runs on Windows and passes outside input to cross-spawn, upgrade to 7.1.2 or 6.0.10. Linux and macOS are not affected.
Why a tiny npm package keeps showing up in security reports
cross-spawn is a drop-in replacement for Node’s child_process.spawn that smooths over Windows quirks. It resolves commands through PATHEXT, honors shebang lines and launches batch files such as npm.cmd correctly. npm counted 345,651,038 downloads in the week from November 24 to 30. Very few projects list it in their own package.json, though. It arrives as a transitive dependency: ESLint 10.16.0 requires cross-spawn ^7.0.6, and the older execa 5.1.1 asks for ^7.0.3.
Plenty of developers know the name from CVE-2024-21538, published on November 8, 2024. That one was a regular expression denial of service (ReDoS): an attacker could craft a long string that made a regex eat CPU time and stall the process. Versions before 6.0.6 and 7.0.0 through 7.0.4 were vulnerable, and 7.0.5 and 6.0.6 fixed it. Many teams first met it in Trivy, Snyk or GitLab dependency scanning reports, often for Docker images. Part of the reason was npm itself: older npm releases bundle their own copy, and npm 10.8.2 ships cross-spawn 7.0.3. npm 11.21.1 and 12.2.3 no longer include the package, but an image built on an older Node.js release can still trip the scanner even when your lockfile is clean.
This round is more serious. A ReDoS can take a process down, while the November 2026 bugs let an attacker execute arbitrary commands. And one of the three new flaws was introduced by the very patch that fixed the ReDoS.
The root cause: cmd.exe parses batch file arguments a second time
On Unix, a child process receives its arguments as an array. On Windows, they travel as one command line string that the child splits back apart. Batch files (.bat and .cmd) go through cmd.exe, which has its own rules, and a batch file that forwards its arguments with %* makes cmd.exe parse them a second time. That double parse was the heart of BatBadBut in 2024, which hit Rust (CVE-2024-24576) and Node.js (CVE-2024-27980). Since then Node refuses to run batch files without shell: true, so libraries like cross-spawn have to handle the escaping themselves.
Three advisories, three ways to break out of the quotes
CVE-2026-137199 (GHSA-ghv9-86vm-4v8m) is the big one. cross-spawn only accounted for the second parse when the batch file was an npm cmd-shim inside node_modules/.bin. For any other batch file, including npm.cmd, globally installed package shims and user batch files, a crafted argument could break out of its quotes. The advisory’s proof of concept fits on one line: spawn.sync('npm', ['" & calc & "']) opens the Windows calculator. Batch-file detection could also be bypassed with trailing dots or spaces (tool.bat ), %VAR% was expanded if a variable named VAR^ existed, and !VAR! was expanded when delayed expansion was enabled in the registry. Affected versions are 7.0.0 through 7.0.6 and everything before 6.0.7. The maintainers rate it high, the GitHub Advisory Database rates it critical. Its CVSS vector (AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H) explains the tension: no login is needed and the impact is total, but attack complexity is high and the attack only works if the application passes untrusted input along. The issue was first reported publicly in GitHub issue #171, and Duong Bui Thai privately reported the details.
CVE-2026-137198 (GHSA-m6qr-m48x-3xhh) is the ReDoS fix coming back to bite. The rewritten regular expressions in 7.0.4, 7.0.5, 7.0.6 and 6.0.6 no longer doubled backslashes before a double quote correctly. An argument like x\\" --evil reached the program as two arguments, and even an ordinary path such as C:\some\dir\\ could swallow the arguments that followed it. The command still exits successfully and nothing lands on stderr. This one can’t run other commands, but it can smuggle in flags, say a --write next to a --check. It’s rated medium.
CVE-2026-137197 (GHSA-w3gc-668g-rf8f) landed a few hours later and shows how hard this is to get right. The new escaping in 7.1.0 only applied when cross-spawn detected a batch file. Detection failed when the command contained double quotes (spawn('"tool"', args)), a space, tab, comma, semicolon or equals sign (spawn('npm install', args) runs npm.cmd), trailing whitespace, or when a custom PATHEXT in options.env made cmd.exe find a batch file the parent couldn’t see. Arguments were then escaped for a regular program, and "&calc was enough to run a command again. Everything before 7.1.1 and 6.0.8 is affected, rated high. Versions before 6.0.0 are unmaintained and won’t get a fix.
Patched versions: which cross-spawn version to install
The release timeline is the best argument against stopping at the first patched version. All times UTC:
- Nov 28, 18:48: 7.1.0 and 6.0.7 fix CVE-2026-137199 and CVE-2026-137198.
- Nov 28, 23:09: 7.1.1 and 6.0.8 fix CVE-2026-137197.
- Nov 29, 03:57 and 04:15: 7.1.2 and 6.0.10 fix a regression where a batch file found in
PATHsaw the current directory in%~dp0, which broke Gradle withUnable to access jarfile. 6.0.9 went out by mistake without that fix and is identical to 6.0.8. - Nov 29, 05:12: cross-spawn 8.0.0 ships as a new major version.
So the targets are 7.1.2 on the 7.x line and 6.0.10 on 6.x. The project called 6.0.7 the last 6.x release and then needed two more, which is a good reason to move to 7.x if you can.
Detection: finding the vulnerable package version in your dependency tree
Because cross-spawn is almost always a dependency of a dependency, you have to look at the whole tree:
# Every installed copy of cross-spawn
npm ls cross-spawn --all
# Why a given version is there
npm explain cross-spawn
# Known advisories (keep dev dependencies in the report)
npm audit
# pnpm and Yarn
pnpm why cross-spawn
yarn why cross-spawn
Don’t add --omit=dev here. cross-spawn mostly lives in linters, test runners and build scripts, which is exactly what runs on your Windows build agents. If you use Trivy, trivy fs --scanners vuln . reads the lockfile directly and works in a Docker container without installed node modules. Snyk and Dependabot pick the advisories up once their databases sync, and Dependabot can open pull requests automatically for transitive dependencies too.
Most of the time the fix is already allowed by the parent’s version range. ESLint’s ^7.0.6 accepts 7.1.2, so only the lockfile holds you back and npm update cross-spawn does the job. npm audit fix works the same way, within existing ranges. Be careful with npm audit fix --force: it will install breaking major versions of the parent packages to resolve the advisory, which can push a whole build tool a major release forward. When a package pins an old version, an override is the cleaner fix:
{
"overrides": {
"cross-spawn": "^7.1.2"
}
}
pnpm uses pnpm.overrides and Yarn uses resolutions for the same thing. This also lifts 6.x consumers to 7.x, which is usually fine because the API didn’t change, but verify it on a Windows runner before it reaches your release branch. Don’t force cross-spawn 8 across the tree, since the new major breaks the API. Watch the dist-tags as well:
npm view cross-spawn dist-tags
# { '7x': '7.1.2', latest: '8.0.0', '6x': '6.0.10' }
Since November 29, latest points at 8.0.0. A quick npm install cross-spawn@latest gets you the new major, not the latest version of 7.x. Use cross-spawn@7 if you want to stay on the 7.x line.
Who is actually affected by the cross-spawn vulnerability
The advisories put it plainly: “Applications are affected if they pass untrusted input as arguments to a command that runs through cmd.exe on Windows.” All three conditions have to hold. An Express API on a Linux host is not exploitable even if cross-spawn is in its tree, and the same goes for the usual Linux-based Docker images. Windows containers, such as build images based on Windows Server Core, behave like any other Windows machine.
The realistic risk sits on Windows runners in GitHub Actions, Azure DevOps or Jenkins, where build scripts pass branch names, PR titles or tags to npm or other shims. Git allows characters like & in branch names, and whoever opens a pull request from a fork picks the name. Electron apps, internal admin tools and local build servers that forward form input to command line tools are potentially exposed too. On a build agent, exploitation means code running next to your deploy keys and tokens.
A typical risky pattern looks like this:
const spawn = require('cross-spawn');
// branch comes from a webhook payload, i.e. untrusted
spawn.sync('npm', ['run', 'deploy', '--', branch], { stdio: 'inherit' });
The advisories recommend two mitigations: validate untrusted input against a safe subset, and call executables directly rather than through batch files. For a Node script, process.execPath points at the running node.exe, so cmd.exe never gets involved:
const { spawnSync } = require('node:child_process');
// Validate on every platform, not just when process.platform === 'win32'
if (!/^[\w.\/-]{1,100}$/.test(branch)) {
throw new Error('Invalid branch name');
}
spawnSync(process.execPath, ['scripts/deploy.js', branch], { stdio: 'inherit' });
Limits no patch can fix
The updated README is unusually candid about what can’t be made safe on Windows. Line breaks can’t be escaped for cmd.exe, so since 7.1.0, spawn() and spawn.sync() throw a TypeError instead of silently truncating the argument. Batch files that read %~1 unquoted, use call or enable delayed expansion remain exploitable. If you maintain your own .cmd files, write "%~1" or forward with %*. Programs behind batch files that don’t follow Microsoft C runtime parsing, such as Go binaries, may split quoted arguments differently. And WorstFit still applies: programs that read arguments through the legacy ANSI code page can turn characters like " (U+FF02) into a plain double quote.
The patches also change behavior in ways that can break builds. Since 7.1.1 and 6.0.8, the command is always quoted when it runs through cmd.exe, so spawn('npm install') now fails with ENOENT. Pass arguments in the array. Inner double quotes are escaped as "" for batch files, and cmd.exe runs with /e:on /v:off, which breaks scripts that rely on delayed expansion from the registry.
cross-spawn 8: worth the upgrade for tools on Node 22.13+
Version 8.0.0 requires Node.js 22.13 or later, the first release that can require() an ES module without a warning. It’s now an ES module with named exports only, spawn.sync() became spawnSync(), and TypeScript types ship with the package, so @types/cross-spawn can go. On Windows, it throws a TypeError with code ERR_INVALID_ARG_VALUE for commands that can’t safely go through cmd.exe, such as those containing double quotes, ^ or %. That includes a quoted path like spawn('"C:\\Program Files\\tool.exe"'). Also note that spawnSync() results now leave error unset instead of null, so check if (result.error) rather than comparing with null.
// cross-spawn 8
import { spawn, spawnSync } from 'cross-spawn';
spawnSync('npm', ['install'], { stdio: 'inherit' });
Jest only loads ES modules required from CommonJS tests on Node.js 24.9+ with --experimental-vm-modules or through a transform, although jest.mock('cross-spawn', factory) keeps working. For your own tooling on a current Node release, 8.0.0 is the better choice because unsafe calls fail loudly. Libraries that support older Node versions should stay on 7.1.2, which the maintainers say will keep receiving security fixes.
What to do this week
This fits a pattern we have seen all autumn. Like the React Router advisories from November, the risk comes from code deep in the dependency tree. Like the npm dependency confusion wave, the most valuable target is the build machine that holds the secrets. And Vite 8.4’s stricter dev server file serving was another reminder that dev tooling deserves production-grade patching.
My advice: run npm ls cross-spawn --all today in every repo that builds or ships on Windows, and get to 7.1.2 or 6.0.10. Then grep your own code for spawn calls that feed external input to a .cmd file, and either rewrite them to call an executable directly or put an allow list in front. The primary sources are the advisories GHSA-ghv9-86vm-4v8m and GHSA-w3gc-668g-rf8f, plus the 7.1.2 release notes.



