GHSA-GHV9-86VM-4V8M
Vulnerability from github – Published: 2026-12-01 02:58 – Updated: 2026-12-01 02:58Impact
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:
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 namedVAR^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) 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.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "cross-spawn"
},
"ranges": [
{
"events": [
{
"introduced": "7.0.0"
},
{
"fixed": "7.1.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "cross-spawn"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.0.7"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-137199"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-12-01T02:58:48Z",
"nvd_published_at": "2026-11-30T21:17:25Z",
"severity": "CRITICAL"
},
"details": "### Impact\n\nOn Windows, `cross-spawn` runs commands that aren\u0027t 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(\u0027cross-spawn\u0027);\n\n// Runs calc.exe on Windows\nspawn.sync(\u0027npm\u0027, [\u0027\" \u0026 calc \u0026 \"\u0027]);\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\u0027 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\u0027t affected, and neither is `options.shell`, which doesn\u0027t 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\u0027t escape, are rejected with a `TypeError`.\n\nSome limitations can\u0027t 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.",
"id": "GHSA-ghv9-86vm-4v8m",
"modified": "2026-12-01T02:58:48Z",
"published": "2026-12-01T02:58:48Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/security/advisories/GHSA-ghv9-86vm-4v8m"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-137199"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/issues/171"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/pull/191"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/pull/192"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/commit/1b71aa519a2e4f97d1f3ee27f0e2fc24ba17cf1a"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/commit/244ffeaa8473de0080c93ebbf779bb953b94114b"
},
{
"type": "PACKAGE",
"url": "https://github.com/moxystudio/node-cross-spawn"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/releases/tag/v6.0.7"
},
{
"type": "WEB",
"url": "https://github.com/moxystudio/node-cross-spawn/releases/tag/v7.1.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "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",
"type": "CVSS_V4"
}
],
"summary": "cross-spawn: Command injection on Windows when spawning batch files"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.