CRITICAL · CVSS 4.0 CWE-78

CVE-2026-137199: cross-spawn: Command injection on Windows when spawning batch files

Published 2026-12-01 · Updated 2026-12-01 · Also known as GHSA-ghv9-86vm-4v8m

Summary

The cross-spawn package contains a command injection vulnerability on Windows when spawning batch files due to improper argument escaping. Developers using affected versions of cross-spawn on Windows systems should update to the patched releases immediately.

Who is affected

The vulnerability affects applications passing untrusted input as arguments to commands processed through cmd.exe, such as .bat or .cmd files. Successful exploitation allows an attacker to break out of command quotes and execute arbitrary commands, potentially leading to full system compromise. Non-Windows platforms and implementations using options.shell are not affected.

Exploitability

The vulnerability is considered critical but requires specific conditions, including an attack surface where untrusted input is passed to cross-spawn on Windows. The CVSS 4.0 vector indicates high impacts for confidentiality, integrity, and availability, though EPSS data is not yet available and the vulnerability is not listed in CISA KEV.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-12-01. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm cross-spawn >= 7.0.0, < 7.1.0 7.1.0 npm install [email protected]
npm cross-spawn >= 0, < 6.0.7 6.0.7 npm install [email protected]

CVSS 4.0 vector

CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Attack vectorNetwork
Attack complexityHigh
Attack requirementsPresent
Privileges requiredNone
User interactionNone
Confidentiality (vulnerable system)High
Integrity (vulnerable system)High
Availability (vulnerable system)High
Confidentiality (subsequent systems)None
Integrity (subsequent systems)None
Availability (subsequent systems)None

Base score is not computed for CVSS 4.0 vectors; severity is taken from the advisory.

FAQ

Is this vulnerability exploitable on Linux or macOS?

No, the vulnerability is specific to the Windows command parsing behavior when using cmd.exe.

Does setting options.shell mitigate this issue?

Yes, using options.shell is not affected as it does not perform the problematic command or argument escaping.

Are there scenarios where patching is insufficient?

Yes, batch files that use unquoted arguments such as %~1 cannot be fully protected by escaping; in these cases, you must change how the batch file handles arguments.

Original advisory description
### Impact On Windows, `cross-spawn` runs commands that aren't executables (`.exe` or `.com`), such as batch files (`.bat` or `.cmd`), through `cmd.exe`, and escapes the command and its arguments for it. A batch file that forwards its arguments, e.g. with `%*`, makes `cmd.exe` parse them a second time. `cross-spawn` only accounted for that second parse when the batch file was an npm cmd-shim located in `node_modules/.bin`. For any other batch file, such as `npm.cmd`, globally installed package shims or user batch files, a crafted argument could break out of its quotes and run arbitrary commands: ```js const spawn = require('cross-spawn'); // Runs calc.exe on Windows spawn.sync('npm', ['" & calc & "']); ``` The following were also affected: - Batch file detection could be bypassed with trailing dots or spaces in the command name (e.g. `tool.bat `), which Windows strips, similar to Node.js' CVE-2024-36138. - `%VAR%` in an argument was expanded if an environment variable named `VAR^` existed. - `!VAR!` in an argument was expanded if delayed expansion was enabled in the registry. Applications are affected if they pass untrusted input as arguments to a command that runs through `cmd.exe` on Windows. Other platforms aren't affected, and neither is `options.shell`, which doesn't escape the command or its arguments by design. ### Patches This is fixed in `7.1.0` and `6.0.7`. Batch file arguments are now escaped with double quotes, like Rust does since the BatBadBut vulnerability (CVE-2024-24576), `%` is neutralized, `cmd.exe` runs with `/e:on /v:off`, batch files are detected after stripping trailing dots and spaces, and line breaks, which `cmd.exe` can't escape, are rejected with a `TypeError`. Some limitations can't be fixed by any escaping, such as batch files that use `%~1` unquoted. Please see the "Windows argument escaping" section of the README. ### Workarounds Validate untrusted input so that only a safe subset is allowed, and call executables directly rather than through batch files. ### Credits Thanks to Duong Bui Thai ([LinkedIn](https://www.linkedin.com/in/thaiducng/)) for privately reporting the quote breakout through batch files outside `node_modules/.bin` and the `!VAR!` expansion under delayed expansion, and to @mohd-akram for publicly reporting the batch file injection in #171.

References

Source records: GHSA-ghv9-86vm-4v8m (OSV.dev).