Dec 4, 2026·13 min read·3 visits
An OS command injection vulnerability in the Node.js cross-spawn library on Windows allows attackers to execute arbitrary commands via cmd.exe when untrusted arguments are passed to batch scripts invoked with quotes, delimiters, trailing tabs, or custom child PATHEXT variables. Upgrade to cross-spawn 6.0.8 or 7.1.1.
CVE-2026-137197 (GHSA-w3gc-668g-rf8f) is an OS command injection vulnerability (CWE-78) in the Node.js cross-spawn library affecting versions prior to 6.0.8 and 7.1.1 on Microsoft Windows. The flaw stems from parsing and resolution discrepancies between how cross-spawn identifies batch scripts (.bat and .cmd) and how Windows cmd.exe resolves target files. When a command string contains embedded double quotes, token delimiters, trailing whitespace, or relies on a child-specific PATHEXT environment variable, cross-spawn fails to detect that the target is a batch script and omits cmd.exe metacharacter escaping on user-supplied arguments, enabling arbitrary OS command execution.
cross-spawn is a core Node.js package designed to provide cross-platform support for child_process.spawn and child_process.spawnSync. While POSIX operating systems pass command arguments directly to the kernel as an array of strings via the execve system call without invoking a command interpreter, Microsoft Windows utilizes CreateProcessW, which requires all arguments to be concatenated into a single command-line string (lpCommandLine). Furthermore, Windows cannot natively execute batch scripts (.bat and .cmd) or files using shebangs directly through CreateProcessW; instead, cross-spawn must wrap the invocation inside a Windows Command Shell (cmd.exe /d /s /c "...").
Because cmd.exe applies distinct lexical parsing rules compared to the standard Microsoft Visual C++ Runtime (CommandLineToArgvW), cross-spawn must inspect the target command to determine whether it resolves to a batch file. If the target is identified as a .bat or .cmd file, cross-spawn applies specialized batch escaping using the cmd.exe caret (^) escape character to neutralize shell metacharacters (&, |, <, >, (, ), ^, %) in the argument array. If the target is classified as a standard Portable Executable (.exe or .com), cross-spawn applies only standard C-runtime double-quote escaping.
In versions prior to 6.0.8 and 7.1.1, cross-spawn contained a parsing and file-resolution divergence (CWE-78) between its internal batch file detection logic and the actual file resolution performed by cmd.exe. Specifically, if the command string passed to cross-spawn contained double quotes, command-name delimiters (spaces, tabs, commas, semicolons, equals signs), trailing non-space whitespace (such as tabs), or relied on a custom PATHEXT variable supplied in the child process options (options.env), cross-spawn failed to identify the target as a batch script.
When this misclassification occurs, cross-spawn skips batch-specific metacharacter escaping on the arguments array while still routing the execution through cmd.exe. When cmd.exe subsequently normalizes the command name, locates the underlying .bat or .cmd file, and executes it, any unescaped shell metacharacters present in attacker-controlled arguments are evaluated directly by the command interpreter. This results in arbitrary operating system command execution within the security context of the host Node.js process.
The root cause of CVE-2026-137197 lies in four distinct discrepancies between how cross-spawn resolved and tested command strings in lib/parse.js, lib/util/escape.js, and lib/util/resolveCommand.js, and how cmd.exe parses command tokens on Windows.
First, Windows NTFS and FAT file systems prohibit the double quote character (") inside file names, and cmd.exe transparently strips double quotes when parsing a command token (for example, resolving "tool.bat" or to"ol".bat as tool.bat). Prior to the patch, parseNonShell() in lib/parse.js passed the raw, unstripped parsed.command string directly to resolveCommand() and subsequently tested the string against isBatchFileRegExp (/\.(?:bat|cmd)$/i). Because the trailing or embedded quote remained in the string, both which.sync() path resolution and the regular expression match failed. cross-spawn treated the target as a non-batch file, whereas cmd.exe stripped the quotes and executed the batch script.
Second, cmd.exe treats standard whitespace (space and tab) as well as commas (,), semicolons (;), and equals signs (=) as token delimiters that terminate the command name and begin the argument list, even when those characters are preceded by a caret (^) escape. In vulnerable versions of cross-spawn, escapeCommand() in lib/util/escape.js escaped metacharacters with ^ but did not wrap the command token in double quotes. If an application passed a command string containing a delimiter (e.g., spawn('npm install', [userInput]) or spawn('script,arg', [userInput])), which.sync() searched for a file literally named npm install, failed to find it, and skipped batch escaping. When handed to cmd.exe, the shell split the token at the delimiter, resolved npm to npm.cmd, and executed it alongside the unescaped userInput.
Third, Windows file system APIs and cmd.exe strip trailing dots and trailing whitespace characters when resolving file names. While cross-spawn previously included trailingDotsAndSpacesRegExp (/[. ]+$/) to strip trailing dots and ASCII spaces (0x20) before testing against isBatchFileRegExp, it failed to strip other whitespace characters such as horizontal tabs (\t). Passing a command string like script.bat\t bypassed the /\.(:?bat|cmd)$/i check in cross-spawn, while cmd.exe stripped the trailing tab and invoked script.bat.
Fourth, when resolveCommandAttempt() in lib/util/resolveCommand.js invoked which.sync() to resolve an extensionless command name (such as my-script) against the system path, it passed path: env[getPathKey({ env })] using the child's options.env, but left the pathExt option undefined. When pathExt is undefined, which.sync() falls back to process.env.PATHEXT from the parent Node.js process rather than options.env.PATHEXT. If the parent process environment excluded .BAT or .CMD from PATHEXT (or used a restricted PATHEXT), while the child's options.env.PATHEXT included .BAT or .CMD, which.sync() failed to locate the batch script. However, the spawned cmd.exe process inherited options.env and resolved the extensionless command to the batch file.
The remediation for CVE-2026-137197 was implemented in commits d0ead352a7380492cbb0f6548fa86f19448323c9 (for the v7.x branch, released as 7.1.1) and 4a15965b05415e9f817315206771b25558804b16 (for the v6.x branch, released as 6.0.8). The patch modifies three core files: lib/parse.js, lib/util/escape.js, and lib/util/resolveCommand.js.
In lib/parse.js, the regular expression trailingDotsAndSpacesRegExp was updated from /[. ]+$/ to /[.\s]+$/ to ensure that all trailing whitespace characters (including tabs) are stripped prior to testing the file extension against isBatchFileRegExp. Additionally, parseNonShell() now strips all double-quote characters (") from parsed.command before calling detectShebang(parsed) (which internally invokes resolveCommand(parsed)).
// File: lib/parse.js
const isExecutableRegExp = /\.(?:com|exe)$/i;
const isBatchFileRegExp = /\.(?:bat|cmd)$/i;
// Vulnerability Fix 1: Expand /[ .]+$/ to /[.\s]+$/ to strip trailing tabs and whitespace
const trailingDotsAndSpacesRegExp = /[.\s]+$/;
function parseNonShell(parsed) {
if (!isWin) {
return parsed;
}
// Vulnerability Fix 2: Strip all double quotes from the command name before resolution
// cmd.exe ignores double quotes in command names; removing them ensures which.sync
// and isBatchFileRegExp evaluate the exact filename cmd.exe will locate.
parsed.command = parsed.command.replace(/"/g, '');
// Detect & add support for shebangs
const commandFile = detectShebang(parsed);
// Apply quote escaping if the command is not a standard .com/.exe executable
const applyQuotes = !isExecutableRegExp.test(commandFile);
if (parsed.options.forceShell || applyQuotes) {
// Detect if the resolved or normalized command is a .bat or .cmd file
const needToEscapeBatchArgs = isBatchFileRegExp.test(commandFile) ||
isBatchFileRegExp.test(parsed.command.replace(trailingDotsAndSpacesRegExp, ''));
// ...In lib/util/escape.js, escapeCommand() previously attempted to escape shell metacharacters using caret (^) prefixes via arg.replace(metaCharsRegExp, '^$1'). However, because cmd.exe splits unquoted command tokens at spaces, tabs, ,, ;, and = even when preceded by ^, this allowed command strings containing delimiters to be truncated by cmd.exe into a valid batch script name followed by extra arguments. The patch replaces caret escaping in escapeCommand() with enclosing double quotes ("${escapePercent(arg)}"). Because double quotes were already stripped from parsed.command in lib/parse.js, wrapping the command token in double quotes forces cmd.exe to treat the entire string as a single literal file path.
// File: lib/util/escape.js
function escapeCommand(arg) {
assertNoLineBreaks(arg);
// Vulnerability Fix 3: Wrap the command token in double quotes instead of caret-escaping.
// This forces cmd.exe to evaluate the command string as a single filename token
// rather than splitting at spaces, tabs, commas, semicolons, or equals signs.
return `"${escapePercent(arg)}"`;
}In lib/util/resolveCommand.js, the patch introduces a helper function getPathExt(env) that performs a case-insensitive lookup for the PATHEXT key on the target environment object (parsed.options.env || process.env). Passing this extracted value to which.sync() guarantees that cross-spawn resolves extensionless commands using the exact same executable extensions list that the child cmd.exe process will use.
// File: lib/util/resolveCommand.js
// Vulnerability Fix 4: Case-insensitive extraction of PATHEXT from the child environment
function getPathExt(env) {
const key = Object.keys(env).find((name) => name.toUpperCase() === 'PATHEXT');
return key ? env[key] : undefined;
}
function resolveCommandAttempt(parsed, withoutPathExt) {
const env = parsed.options.env || process.env;
// ...
try {
resolved = which.sync(parsed.command, {
path: env[getPathKey({ env })],
pathExt: withoutPathExt ? path.delimiter : getPathExt(env),
});
} catch (e) {
/* Empty */
}
// ...
}> [!NOTE]
> Assessment of Fix Completeness: The combination of quote removal in parse.js and forced double-quoting in escapeCommand() completely neutralizes delimiter-splitting vectors. As an intentional side effect, applications that previously abused cross-spawn by passing both the command name and flags inside the first argument (e.g., spawn('npm install')) will now fail with an ENOENT error on Windows, matching POSIX execve behavior. One residual architectural limitation on Windows involves invoking cmd.exe built-in commands that re-parse their arguments (such as call or start), though those are non-executable shell built-ins rather than external binaries or batch scripts.
Exploiting CVE-2026-137197 requires three prerequisites: the target Node.js application must be executing on a Microsoft Windows host (process.platform === 'win32'), the application must invoke cross-spawn (spawn or spawnSync) using a command string or environment configuration that triggers one of the four resolution discrepancies, and the application must pass attacker-controlled data inside the args array.
When these conditions are met, cross-spawn wraps each element of args in double quotes and escapes internal backslashes and double quotes (\"), which is the standard format expected by CommandLineToArgvW. However, cross-spawn does not apply batch escaping (which normally replaces " with ^"^" and prefixes metacharacters with ^). When cmd.exe /d /s /c executes a batch script, cmd.exe strips the outer quotes of the cmd.exe /c string and parses the inner command line. If an argument contains "&calc.exe&", the embedded " closes the argument quote introduced by cross-spawn, allowing the & command separator to execute an arbitrary binary (calc.exe) before re-opening the quote.
If a developer wraps the command name or path in double quotes (a common defensive mistake when handling paths with spaces) or allows partial user control over the formatting of the command string, batch detection is bypassed:
const spawn = require('cross-spawn');
// Application invokes a batch file with surrounding quotes
// Vulnerable cross-spawn (< 6.0.8 or 7.0.0 - 7.1.0) fails to match /\.(?:bat|cmd)$/i
const command = '"echo-forward.bat"';
// Attacker-controlled argument breaks out of standard C-runtime quotes
const untrustedArg = '"&whoami > C:\\pwned.txt&"';
// Resulting cmd.exe invocation:
// cmd.exe /d /s /c "^"echo-forward.bat^" "\"&whoami > C:\pwned.txt&\"""
spawn(command, [untrustedArg]);If an application passes a command string containing a space, tab, comma, semicolon, or equals sign (for example, combining a base command and subcommand into the command parameter), which.sync fails to locate a matching .bat or .cmd file, while cmd.exe splits the string at the delimiter:
const spawn = require('cross-spawn');
// Developer passes subcommand inside the command parameter instead of the args array
// which.sync('npm run') returns null; cross-spawn skips batch escaping.
// cmd.exe splits at the space, resolves 'npm' to 'npm.cmd', and executes the injected payload.
const command = 'npm run';
const untrustedArg = '"&calc.exe&"';
spawn(command, [untrustedArg]);If the parent Node.js process runs with a restricted PATHEXT (e.g., PATHEXT=.COM;.EXE) or a modified environment, and passes a full PATHEXT inside options.env to the child process, cross-spawn fails to resolve extensionless batch files during which.sync:
const spawn = require('cross-spawn');
// Assume parent process.env.PATHEXT is '.COM;.EXE'
const options = {
env: {
...process.env,
PATHEXT: '.COM;.EXE;.BAT;.CMD'
}
};
// Vulnerable cross-spawn checks parent PATHEXT, does not find 'build-tool.bat',
// and omits batch escaping. The spawned cmd.exe uses options.env.PATHEXT,
// resolves 'build-tool.bat', and executes notepad.exe.
spawn('build-tool', ['"¬epad.exe&"'], options);Successful exploitation of CVE-2026-137197 grants an attacker arbitrary operating system command execution via cmd.exe with the privileges of the running Node.js service account. This compromises confidentiality (allowing reading of sensitive application files, source code, and environment secrets), integrity (allowing arbitrary file modification, payload dropping, or lateral movement), and availability (enabling termination of the Node.js process or exhaustion of host resources).
The vulnerability is assigned a CVSS v3.1 Base Score of 8.1 (High) with the vector CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H. The Attack Vector (AV:N) reflects scenarios where a Node.js web service, API endpoint, RPC handler, or CI/CD runner accepts remote input over the network and passes it as arguments to cross-spawn. Privileges Required (PR:N) and User Interaction (UI:N) indicate that exploitation can occur without prior authentication or human intervention if the vulnerable code path is exposed.
The Attack Complexity (AC:H) metric is rated High because exploitation depends on non-default invocation patterns beyond simply passing untrusted arguments to a batch file. Standard calls such as spawn('tool.bat', [untrustedInput]) or spawn('npm', [untrustedInput]) (with a standard parent PATHEXT) were already protected by cross-spawn's existing batch detection. An application is only vulnerable if it runs on Windows and invokes cross-spawn with quotes in the command name, command delimiters in the command name, trailing non-space whitespace, or a child-specific PATHEXT that diverges from the parent process.
According to CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) assessment, active exploitation is currently listed as none, automatability is no (due to the application-specific constraints required to reach a vulnerable spawn call), and technical impact is total. The Exploit Prediction Scoring System (EPSS) assigns CVE-2026-137197 a probability score of 0.00824 (58.66th percentile), and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.
The primary remediation is to upgrade the cross-spawn dependency to a patched release that normalizes command strings, enforces double-quoting on commands passed to cmd.exe, and inspects the child environment's PATHEXT. Patched releases are available for both active major release branches:
cross-spawn 7.x: upgrade to version 7.1.1 or later.cross-spawn 6.x (or older 4.x/5.x branches): upgrade to version 6.0.8 or later.Because cross-spawn is frequently included as a transitive dependency by build tools, linters, and test runners, development teams should audit their dependency trees using npm ls cross-spawn, yarn why cross-spawn, or pnpm why cross-spawn. To update transitive dependencies in npm, execute npm audit fix or configure an overrides entry in package.json:
{
"overrides": {
"cross-spawn": "^7.1.1"
}
}> [!WARNING]
> Behavior Change in Patched Versions: Upgrading to 6.0.8 or 7.1.1 enforces strict command-token quoting. If an application previously passed arguments or flags inside the command string (e.g., spawn('npm install', ['--save'])), the call will now fail with ENOENT on Windows because cmd.exe will look for an executable literally named "npm install". All command arguments must be separated into the args array (spawn('npm', ['install', '--save'])).
For environments where an immediate dependency upgrade cannot be deployed, apply the following code-level mitigations:
command parameter passed to cross-spawn is a static, unquoted string representing a single binary or script name, free of surrounding quotes, spaces, tabs, commas, semicolons, or equals signs.args array. Reject or strip cmd.exe metacharacters (&, |, <, >, ^, %, ", \r, \n) using an allowlist regular expression (such as /^[a-zA-Z0-9._\/-]+$/).PATHEXT: If passing a custom options.env object to cross-spawn, ensure that options.env.PATHEXT matches process.env.PATHEXT or explicitly append .bat / .cmd to the command filename passed to cross-spawn.CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
cross-spawn moxystudio | < 6.0.8 | 6.0.8 |
cross-spawn moxystudio | >= 7.0.0, < 7.1.1 | 7.1.1 |
| Attribute | Detail |
|---|---|
| CVE / GHSA ID | CVE-2026-137197 / GHSA-w3gc-668g-rf8f |
| Weakness Class | CWE-78 (OS Command Injection) |
| CVSS v3.1 Score | 8.1 High (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H) |
| EPSS Score | 0.824% (58.66th Percentile) |
| Affected Package | cross-spawn (npm) < 6.0.8 and >= 7.0.0, < 7.1.1 |
| Affected Platform | Microsoft Windows (win32) |
| Exploit Status | Proof-of-Concept (Unit test reproduction cases) |
| CISA KEV Status | Not Listed |
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
An input validation flaw in github.com/Luzifer/ots prior to version 1.21.8 allows unauthenticated remote attackers to bypass configured secret expiration policies. By supplying an expire=0 query parameter during secret creation, clients force the server to store secrets without a time-to-live (TTL) in both Redis and in-memory storage backends. This invalidates administrative data retention policies and permits unbounded storage consumption via unread secrets.
A stored Cross-Site Scripting (XSS) vulnerability exists in Silverstripe Framework versions prior to 6.2.13 within the HTML sanitisation engine (SilverStripe\Core\XssSanitiser). The sanitiser fails to strip or normalize non-printable ASCII C0 control characters and DEL bytes prior to evaluating URI attributes against scheme-blocking regular expressions. Because modern web browsers ignore these control bytes according to the WHATWG URL Standard, an authenticated CMS author can embed control bytes before or within a javascript: URI to bypass detection and execute arbitrary JavaScript in the browser context of users viewing the rendered content.
CVE-2026-74871 (also tracked as GHSA-vxf9-vwp6-2w43 and PYSEC-2026-3976) is a cryptographic composition vulnerability in the Python file encryption library openssl_encrypt affecting versions prior to 1.4.6. When generating keys under sequential XOR composition mode (format versions 8 and 10), the key derivation routine redundantly appends the final chain output to an accumulator that already contains the normalized output of the final derivation stage. Because bitwise XOR is self-inverting (A XOR A = 0), the final stage cancels itself out completely. When a single memory-hard key derivation function (such as Argon2id or Scrypt) is configured without preceding hash stages, the derived key collapses to an unhardened SHA-256(password || salt) digest, allowing offline password cracking at raw SHA-256 throughput.
CVE-2026-142637 (GHSA-ch34-gjmh-c4hp) is a query logic injection vulnerability (CWE-943) in the Laravel framework prior to versions 12.73.0 and 13.43.0. When fluent database validation rules such as Rule::exists() or Rule::unique() are scoped using the scalar where() method, the framework serializes the rule object into its legacy comma-delimited string format and subsequently reparses it. During reparsing, the database presence verifier evaluates specific reserved tokens—'NULL', 'NOT_NULL', and values prefixed with '!'—as SQL predicates rather than literal values. If an application passes untrusted user input into a fluent where() scope, an attacker can supply these sentinel tokens to alter the SQL evaluation logic and bypass multi-tenant isolation or ownership validation.
CVE-2026-142622 (GHSA-ww2c-pqp9-rvrq) is an origin validation error (CWE-346) in the Laravel Framework (`laravel/framework`) prior to version 12.53.0. The Pusher and Reverb broadcasting drivers previously accepted a `callback` query parameter on the `/broadcasting/auth` endpoint, returning the channel authentication token wrapped in a JSONP response. Because this endpoint also accepted HTTP GET requests without CSRF validation, an external page could include the authorization endpoint via an HTML `<script>` tag to bypass Same-Origin Policy protections and exfiltrate the authenticated user's private or presence channel tokens.
CVE-2026-142593 is a path traversal and improper symbolic link resolution vulnerability in the Rack::Directory middleware of the Rack Ruby web server interface. A discrepancy between lexical path validation in Ruby user space and physical path resolution by the operating system kernel allows unauthenticated remote attackers to bypass document root restrictions when a symlinked directory exists inside the served root. Attackers can enumerate file names, directory structures, file sizes, and modification timestamps outside the intended document root.