Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-102422 Overview
CVE-2026-102422 is a command injection vulnerability in the shell-quote npm package. The quote() function emits a { comment } token as # followed by its text, which comments out the rest of the shell line, including the opening quote of any later string token. A line terminator (\n, \r, U+2028, U+2029) in that later string ends the comment, and the remainder is parsed as shell input. Downstream applications that pass user-controlled tokens through quote() or combine parse() output with untrusted strings can execute attacker-supplied commands in sh, bash, dash, ksh, and zsh. This flaw is classified under [CWE-78] OS Command Injection.
Critical Impact
An unauthenticated attacker can achieve arbitrary command execution against Node.js applications that use shell-quote to build shell command strings from untrusted input.
Affected Products
- shell-quote npm package versions prior to 1.11.0
- Node.js applications that call quote() with objects emitted by parse()
- Applications combining parse(untrustedCommand).concat(untrustedArg) patterns
Discovery Timeline
- 2026-09-29 - CVE CVE-2026-102422 published to NVD
- 2026-09-30 - Last updated in NVD database
Technical Details for CVE-2026-102422
Vulnerability Analysis
The shell-quote library serializes an array of tokens into a shell-safe command string. When a { comment } object appears in the token array, quote() renders it as # followed by the comment text. Shell parsers treat # as the start of a comment that continues until the next line terminator. The library did not account for subsequent string tokens containing embedded newlines, so any content after such a newline is interpreted as fresh shell input rather than an argument.
An attacker who controls a later token can supply a payload such as a\nid;#. The newline terminates the comment, and id executes as a shell command. The parse() function compounds the risk: it converts fragments like http://example.com/#frag into a comment token, so any pipeline that concatenates parse() output with attacker-supplied strings inherits this behavior.
Root Cause
The fix for CVE-2026-9277 blocked line terminators inside a comment's own text but did not sanitize tokens following the comment. Because shell comment scope extends to the end of the physical line, allowing raw newlines in any downstream token breaks the quoting contract and yields command injection.
Attack Vector
Exploitation requires an application to pass untrusted data through quote() where a { comment } token precedes an attacker-influenced string. This is common in wrapper libraries that reuse parse() output when appending user arguments. The result is executed by any POSIX shell invoked by child_process.exec or equivalent.
// Vulnerable pattern - pre-1.11.0 behavior
// quote(['echo', 'ok', { comment: 'x' }, 'a\nid;#'])
// Emits: echo ok #x a
// id;#
// The shell executes `id` after the newline terminates the comment.
// Patched behavior in 1.11.0 (quote.js)
var sawComment = false;
return xs.map(function (s) {
if (sawComment && typeof s === 'string' && LINE_TERMINATORS.test(s)) {
throw new TypeError('a token after a `comment` must not contain line terminators');
}
if (s === '') {
return /** @type {const} */ ('\'\'');
}
// ...
});
Source: GitHub commit 6002b2e
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-102422
Indicators of Compromise
- Shell process trees where a Node.js parent spawns unexpected binaries such as id, curl, wget, sh, or bash following an application request
- Command lines containing embedded \n, \r, U+2028, or U+2029 characters passed to child_process.exec or spawn with shell: true
- HTTP request parameters containing # fragments followed by newline-encoded payloads (%0A, %0D)
Detection Strategies
- Inventory package-lock.json and yarn.lock files across build pipelines for shell-quote versions below 1.11.0
- Static analysis rules that flag calls to quote(parse(x).concat(y)) or any quote() invocation with mixed object and string tokens
- Runtime monitoring for Node.js processes spawning shells with argument strings containing raw line terminators
Monitoring Recommendations
- Log all child_process shell invocations with full argument arrays and correlate with upstream HTTP inputs
- Alert on new child processes of long-running Node.js services whose executable names were not observed in baseline profiling
- Enable EDR telemetry for shell command creation events tied to web application service accounts
How to Mitigate CVE-2026-102422
Immediate Actions Required
- Upgrade shell-quote to version 1.11.0 or later in all direct and transitive dependencies
- Audit application code for the quote(parse(untrusted).concat(...)) pattern and refactor to avoid mixing untrusted input into token arrays
- Replace shell-based command execution with child_process.execFile or spawn using explicit argument arrays and shell: false
Patch Information
The fix is delivered in shell-quote 1.11.0. quote() now throws a TypeError when a string token that follows a { comment } token contains a line terminator. Review the GitHub Security Advisory GHSA-pqg4-j6r4-53mv and the patch commit for full details.
Workarounds
- Strip line terminators (\n, \r, U+2028, U+2029) from any string passed to quote() when upgrading is not immediately possible
- Reject { comment } tokens entirely before invoking quote() in code paths that handle untrusted data
- Enforce input validation that rejects # characters in URL fragments before they reach parse()
# Upgrade shell-quote across the project
npm install shell-quote@^1.11.0
npm ls shell-quote
# Verify no lockfile still references a vulnerable version
grep -R "shell-quote" package-lock.json | grep -v "1.11"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

