Home/Research/Post

GHSA-w3gc-668g-rf8f: cross-spawn: Command injection on Windows when the command is not a plain program name or path

  • Severity: HIGH
  • CVE: CVE-2026-137197
  • Ecosystems: npm, npm
  • Packages: cross-spawn, cross-spawn

### 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](https://github.com/moxystudio/node-cross-spawn/security/advisories/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…

Source: GitHub Security Advisories · 2026-12-04