{"id":"GHSA-w3gc-668g-rf8f","summary":"cross-spawn: Command injection on Windows when the command is not a plain program name or path","details":"### Impact\n\nOn 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.\n\nThe 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:\n\n- the command contains double quotes, e.g. `spawn('\"tool.bat\"', args)` or `spawn('\"tool\"', args)`;\n- the command contains a space, tab, `,`, `;` or `=`, where `cmd.exe` ends the command name, e.g. `spawn('npm install', args)`, which runs `npm.cmd`;\n- the command ends with a tab or other whitespace;\n- the `PATHEXT` passed in `options.env` makes `cmd.exe` find a batch file that the parent's `PATHEXT` doesn't.\n\nIn those cases the arguments were escaped for a regular program, and an argument such as `\"&calc` could run arbitrary commands.\n\nApplications are affected if they run on Windows, pass a command in one of these forms, and pass untrusted input as arguments.\n\n### Patches\n\nFixed 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.\n\nVersions 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`.\n\n### Workarounds\n\nPass 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`.","aliases":["CVE-2026-137197"],"modified":"2026-12-05T18:45:15.733175092Z","published":"2026-12-04T19:52:52Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-12-04T19:52:52Z","nvd_published_at":"2026-11-30T21:17:25Z","cwe_ids":["CWE-78"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/security/advisories/GHSA-w3gc-668g-rf8f"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-137197"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/pull/196"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/pull/197"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/commit/4a15965b05415e9f817315206771b25558804b16"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/commit/d0ead352a7380492cbb0f6548fa86f19448323c9"},{"type":"PACKAGE","url":"https://github.com/moxystudio/node-cross-spawn"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/releases/tag/v6.0.8"},{"type":"WEB","url":"https://github.com/moxystudio/node-cross-spawn/releases/tag/v7.1.1"}],"affected":[{"package":{"name":"cross-spawn","ecosystem":"npm","purl":"pkg:npm/cross-spawn"},"ranges":[{"type":"SEMVER","events":[{"introduced":"7.0.0"},{"fixed":"7.1.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-w3gc-668g-rf8f/GHSA-w3gc-668g-rf8f.json"}},{"package":{"name":"cross-spawn","ecosystem":"npm","purl":"pkg:npm/cross-spawn"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"6.0.8"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-w3gc-668g-rf8f/GHSA-w3gc-668g-rf8f.json"}}],"schema_version":"1.9.3","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}