CVE-2026-137199

Command Injection
Affects
cross-spawn
in
cross-spawn
No items found.
Versions
<6.0.7, >=7.0.0 <7.1.0

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

cross-spawn is a cross-platform drop-in replacement for the Node.js child_process spawn and spawnSync functions. It works around Windows issues such as ignored PATHEXT, missing shebang support, and commands with spaces.

A command injection vulnerability (CVE-2026-137199) has been identified in cross-spawn on Windows, which allows attackers to run arbitrary operating system commands when an application passes untrusted input as arguments to a command, such as a batch file, that cross-spawn runs through cmd.exe. Environment variable references in an argument can also be expanded instead of being passed literally.

Per OWASP: Command injection is an attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable application. Command injection attacks are possible when an application passes unsafe user supplied data (forms, cookies, HTTP headers etc.) to a system shell. In this attack, the attacker-supplied operating system commands are usually executed with the privileges of the vulnerable application.

This issue affects multiple versions of cross-spawn.

‍

Details

Module Info

Vulnerability Info

This Critical-severity vulnerability is found in the cross-spawn package in multiple versions of cross-spawn. On Windows, cross-spawn runs every command that is not a .exe or .com executable, including batch files such as npm.cmd, through cmd.exe, and builds the cmd.exe command line by escaping the command and each argument itself. That escaping does not match how cmd.exe parses the line, so a crafted argument can leave its quotes and be interpreted as shell syntax.

In cross-spawn 5.x, each argument is quoted as follows before it is joined into the cmd.exe command line:

// Sequence of backslashes followed by a double quote:
// double up all the backslashes and escape the double quote
arg = arg.replace(/(\\*)"/g, '$1$1\\"');

// ...

// Quote the whole thing:
arg = '"' + arg + '"';
parsed.args = ['/d', '/s', '/c', '"' + parsed.command + (parsed.args.length ? ' ' + parsed.args.join(' ') : '') + '"'];
parsed.command = process.env.comspec || 'cmd.exe';
parsed.options.windowsVerbatimArguments = true;

cmd.exe does not treat \" as an escaped quote: every " toggles its quoting state. An argument such as " & calc & " therefore becomes "\" & calc & \"", the & operators fall outside any quoted section, and cmd.exe runs calc as a separate command. Metacharacters such as &, |, < and > are not escaped with ^ inside the quotes, %VAR% references are not neutralized, and cmd.exe is not started with /v:off, so variable references in an argument can also be expanded. cross-spawn 3.0.x builds the command line the same way for every command on Windows.

In cross-spawn 6.x and 7.x before the fix, metacharacters are escaped with ^, but they are escaped a second time only when the command is an npm cmd-shim in node_modules/.bin:

const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;

// ...

const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);

parsed.command = escape.command(parsed.command);
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));

A batch file that forwards its arguments, for example with %*, makes cmd.exe parse them a second time, after the first parse has removed the ^ escapes. For any other batch file, such as npm.cmd, globally installed package shims or user batch files, a crafted argument can break out of its quotes during that second parse and run arbitrary commands. Batch file detection can also be bypassed with trailing dots or spaces in the command name (for example tool.bat ), which Windows strips. A %VAR% reference in an argument is expanded when an environment variable named VAR^ exists, and a !VAR! reference is expanded when delayed expansion is enabled in the registry. Other platforms are not affected, and neither is options.shell, which does not escape the command or its arguments by design.

‍

Steps to Reproduce

1. On Windows, install an affected version of cross-spawn, for example npm install cross-spawn@6.0.6.

2. Run the following script with Node.js:

const spawn = require('cross-spawn');

// Runs calc.exe on Windows
spawn.sync('npm', ['" & calc & "']);

3. Observe that the Windows Calculator starts, because the argument broke out of its quotes in cmd.exe.

‍

Mitigation

Upstream has made no cross-spawn 3.0.x release since 3.0.1 (May 2016), no 5.0.x release since 5.0.1 (November 2016), and no 5.1.x release since 5.1.0 (February 2017), so no release on those lines is available to address this issue. For more information, see here.

Users of the affected components should apply one of the following mitigations:

  • Upgrade affected applications to a supported cross-spawn release that contains the fix.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

‍

Credits

Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
Critical
ID
CVE-2026-137199
PROJECT Affected
cross-spawn
Versions Affected
<6.0.7, >=7.0.0 <7.1.0
NES Versions Affected
Published date
December 1, 2026
≈ Fix date
Category
Command Injection
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for cross-spawn
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.