HighGHSA-w3gc-668g-rf8fCVE-2026-137197

cross-spawn: Command injection on Windows when the command is not a plain program name or path

Published 4 Dec 2026 · Updated 5 Dec 2026

Affected packages

Affected
>=7.0.0 <7.1.1
Fixed in
7.1.1
Update to the fixed version for your release line, for example:npm install cross-spawn@7.1.1
Affected
<6.0.8
Fixed in
6.0.8
Update to the fixed version for your release line, for example:npm install cross-spawn@6.0.8

We confirm your address first. See our privacy policy.

Which cross-spawn does your project really install?

Drop your package-lock.json hereWe find the exact cross-spawn version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

Works for private projects: the file is read in memory to run the scan and then dropped. Also reads yarn.lock, pnpm-lock.yaml or package.json.

Public repo?

Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Details

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) or spawn('"tool"', args);
  • the command contains a space, tab, ,, ; or =, where cmd.exe ends the command name, e.g. spawn('npm install', args), which runs npm.cmd;
  • the command ends with a tab or other whitespace;
  • the PATHEXT passed in options.env makes cmd.exe find a batch file that the parent's PATHEXT doesn'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.

Is GHSA-w3gc-668g-rf8f in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected cross-spawn, and gives you the command that fixes it.

More advisories for cross-spawn

  • HighCVE-2026-137198cross-spawn: Argument injection on Windows via backslashes before a double quote · 4 Dec 2026
  • CriticalCVE-2026-137199cross-spawn: Command injection on Windows when spawning batch files · 1 Dec 2026
  • HighCVE-2024-21538Regular Expression Denial of Service (ReDoS) in cross-spawn · 8 Nov 2024
cross-spawn security overview

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.