{"id":"CVE-2026-137199","aliases":["CVE-2026-137199","GHSA-ghv9-86vm-4v8m"],"related":[],"kind":"vulnerability","state":"published","title":"cross-spawn: Command injection on Windows when spawning batch files","summary":"cross-spawn is a cross-platform solution for Node.js spawn and spawnSync. Prior to 6.0.7 and 7.1.0, Windows applications that pass untrusted arguments to commands routed through cmd.exe can be vulnerable because cross-spawn did not account for the second cmd.exe parse performed when a batch file outside node_modules/.bin forwards its arguments. A crafted argument could break out of its quotes and execute arbitrary commands through npm.cmd, globally installed package shims, or user batch files. Trailing dots or spaces could bypass batch-file detection. A percent-delimited variable in an argument could be expanded when an environment variable with the same name followed by a caret existed, and an exclamation-delimited variable could be expanded when delayed expansion was enabled in the registry. Other platforms and the intentionally unescaped options.shell mode are not affected. This issue is fixed in versions 6.0.7 and 7.1.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"cross-spawn is a cross-platform solution for Node.js spawn and spawnSync. Prior to 6.0.7 and 7.1.0, Windows applications that pass untrusted arguments to commands routed through cmd.exe can be vulnerable because cross-spawn did not account for the second cmd.exe parse performed when a batch file outside node_modules/.bin forwards its arguments. A crafted argument could break out of its quotes and execute arbitrary commands through npm.cmd, globally installed package shims, or user batch files. Trailing dots or spaces could bypass batch-file detection. A percent-delimited variable in an argument could be expanded when an environment variable with the same name followed by a caret existed, and an exclamation-delimited variable could be expanded when delayed expansion was enabled in the registry. Other platforms and the intentionally unescaped options.shell mode are not affected. This issue is fixed in versions 6.0.7 and 7.1.0.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nOn 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.\n\nA 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:\n\n```js\nconst spawn = require('cross-spawn');\n\n// Runs calc.exe on Windows\nspawn.sync('npm', ['\" & calc & \"']);\n```\n\nThe following were also affected:\n\n- 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.\n- `%VAR%` in an argument was expanded if an environment variable named `VAR^` existed.\n- `!VAR!` in an argument was expanded if delayed expansion was enabled in the registry.\n\nApplications 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.\n\n### Patches\n\nThis 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`.\n\nSome 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.\n\n### Workarounds\n\nValidate untrusted input so that only a safe subset is allowed, and call executables directly rather than through batch files.\n\n### Credits\n\nThanks 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.","format":"markdown","source":"ghsa"}],"published":"2026-11-30T20:39:53.636Z","modified":"2026-12-01T03:15:04.449Z","severity":{"scorer":"GitHub_M","scheme":"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","score":9.2,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"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","score":9.2,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"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","rating":"CRITICAL"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":"< 6.0.7","status":"affected"},{"version":">= 7.0.0, < 7.1.0","status":"affected"}],"vendor":"moxystudio","product":"node-cross-spawn","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"7.0.0","status":"affected","fixed":"7.1.0"}],"ecosystem":"npm","package":"cross-spawn","purl":"pkg:npm/cross-spawn","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"6.0.7"}],"ecosystem":"npm","package":"cross-spawn","purl":"pkg:npm/cross-spawn","source":"ghsa"}],"references":[{"url":"https://github.com/moxystudio/node-cross-spawn/security/advisories/GHSA-ghv9-86vm-4v8m","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/issues/171","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/pull/191","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/pull/192","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/commit/1b71aa519a2e4f97d1f3ee27f0e2fc24ba17cf1a","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/commit/244ffeaa8473de0080c93ebbf779bb953b94114b","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/releases/tag/v6.0.7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/moxystudio/node-cross-spawn/releases/tag/v7.1.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-137199","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/moxystudio/node-cross-spawn","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-137199","url":"https://www.cve.org/CVERecord?id=CVE-2026-137199","licence":"CVE Terms of Use","modified":"2026-11-30T20:39:53.636Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ghv9-86vm-4v8m","url":"https://github.com/advisories/GHSA-ghv9-86vm-4v8m","licence":"CC-BY-4.0","modified":"2026-12-01T03:15:04.449Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-137199","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-137199","licence":"Public domain","modified":"2026-11-30T21:17:25.533Z"}],"updatedAt":"2026-12-01T03:27:24.819Z","epss":{"score":0.0101,"percentile":0.64089,"date":"2026-12-01T12:00:22.000Z"}}