CVE-2026-137199: CVE-2026-137199: OS Command Injection in cross-spawn on Windows via Batch File Argument Escaping Bypass
CVE-2026-137199: OS Command Injection in cross-spawn on Windows via Batch File Argument Escaping Bypass Vulnerability ID: CVE-2026-137199 CVSS Score: 9.2 Published: 2026-12-01 CVE-2026-137199 (GHSA-ghv9-86vm-4v8m) i
CVE-2026-137199: OS Command Injection in cross-spawn on Windows via Batch File Argument Escaping Bypass
Vulnerability ID: CVE-2026-137199
CVSS Score: 9.2
Published: 2026-12-01
CVE-2026-137199 (GHSA-ghv9-86vm-4v8m) is a critical OS command injection vulnerability in the Node.js cross-spawn library affecting versions prior to 6.0.7 and 7.1.0 on Windows. The vulnerability stems from incomplete metacharacter escaping when routing batch scripts (.bat and .cmd) outside of node_modules/.bin through cmd.exe, alongside flaws in file extension canonicalization, environment variable expansion, and line break handling. Attackers who control arguments passed to batch scripts can break out of argument quoting and execute arbitrary system commands.
TL;DR
Windows applications using cross-spawn (< 6.0.7 or >= 7.0.0, < 7.1.0) to execute batch files (.bat, .cmd) with untrusted arguments are vulnerable to arbitrary OS command injection due to secondary cmd.exe parsing, path canonicalization quirks, variable expansion, and newline injection. Upgrade to cross-spawn 6.0.7 or 7.1.0.
โ ๏ธ Exploit Status: POC
Technical Details
- CVE / GHSA ID: CVE-2026-137199 / GHSA-ghv9-86vm-4v8m
- Weakness Class: CWE-78: OS Command Injection
- CVSS v4.0 Score: 9.2 Critical (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)
- Affected Platform: Microsoft Windows (win32)
- Affected Versions: cross-spawn < 6.0.7 and >= 7.0.0, < 7.1.0
- Patched Versions: cross-spawn 6.0.7 and 7.1.0
- Exploit Maturity: Proof-of-Concept (PoC) Publicly Available
- CISA KEV Status: Not Listed
Affected Systems
- moxystudio/node-cross-spawn (npm package: cross-spawn) on Microsoft Windows
-
cross-spawn: < 6.0.7 (Fixed in:
6.0.7) -
cross-spawn: >= 7.0.0, < 7.1.0 (Fixed in:
7.1.0)
Code Analysis
Commit: 244ffea
fix: escape commands and arguments safely when running them through cmd.exe (v7.1.0)
Commit: 1b71aa5
fix: escape commands and arguments safely when running them through cmd.exe (v6.0.7)
Exploit Details
- GitHub: Public issue demonstrating proof-of-concept command injection on Windows via spawn.sync('test.cmd', ['"&calc']).
Mitigation Strategies
- Upgrade cross-spawn to version 7.1.0 (for 7.x series) or 6.0.7 (for 6.x series and earlier) across all direct and transitive dependencies.
- Avoid executing .bat and .cmd batch scripts with untrusted user arguments on Windows; instead, invoke the underlying binary executable (.exe) or Node.js script directly via process.execPath.
- Audit custom batch scripts executed by Node.js applications to ensure they always enclose parameter expansions in double quotes (e.g., "%~1") and do not use unquoted %~1, internal CALL commands on untrusted arguments, or setlocal EnableDelayedExpansion.
- Reject or strictly allowlist user-supplied arguments before passing them to child process spawning utilities.
Remediation Steps:
- Identify all installed versions of cross-spawn in the project dependency graph using 'npm ls cross-spawn', 'yarn why cross-spawn', or 'pnpm why cross-spawn'.
- Update direct dependencies in package.json to 'cross-spawn': '^7.1.0' or '^6.0.7'.
- For transitive dependencies, configure 'overrides' (npm/pnpm) or 'resolutions' (Yarn) in package.json to force resolution to 6.0.7 or 7.1.0.
- Regenerate package lockfiles and redeploy affected Windows applications and services.
- Ensure application error handling accounts for the new TypeError thrown by cross-spawn when commands or arguments routed through cmd.exe contain carriage return (\r) or line feed (\n) characters.
References
- GitHub Security Advisory GHSA-ghv9-86vm-4v8m
- Fix Commit for cross-spawn v7.1.0 (244ffeaa8473de0080c93ebbf779bb953b94114b)
- Fix Commit for cross-spawn v6.0.7 (1b71aa519a2e4f97d1f3ee27f0e2fc24ba17cf1a)
- GitHub Issue #171: Command injection on Windows when spawning batch files
- GitHub Pull Request #191
- GitHub Pull Request #192
- cross-spawn v7.1.0 Release Tag
- cross-spawn v6.0.7 Release Tag
- CVE.org Record: CVE-2026-137199
- NVD Vulnerability Detail: CVE-2026-137199
- CVEList V5 JSON Record for CVE-2026-137199
Read the full report for CVE-2026-137199 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.