
Proof-of-concept reproducing CVE-2026-102422, a command injection in shell-quote's quote() via line terminators after comment tokens, with vulnerable and patched snapshots.
Proof of concept for GHSA-pqg4-j6r4-53mv / CVE-2026-102422: a command injection in shell-quote's quote() via a line terminator in a token that follows a { comment } token.
shell-quote (npm)>= 1.8.4, < 1.11.01.11.0AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)This repo reproduces the bug locally and shows the official fix blocking it. It does not target any live service — it calls the quote() function directly with two bundled snapshots of quote.js: the pre-fix version and the patched version.
quote() renders a { comment: 'x' } token as #x, which comments out the rest of the shell line it's part of — including the opening quote of any later string token. If that later string contains a line terminator (\n, \r, U+2028, or U+2029), the terminator ends the # comment early, and the remainder of the string is parsed as live shell syntax:
quote(['echo', 'ok', { comment: 'x' }, 'a\nid;#']);
// => "echo ok #x 'a\nid;#'"
Passed to sh, bash, dash, ksh, or zsh, this runs id.
parse() emits a comment token for a # in the middle of a word too (e.g. http://example.com/#frag), so any caller combining parse() output with another untrusted string — e.g. quote(parse(untrustedCommand).concat(untrustedArg)) — is reachable the same way, without ever constructing a { comment } token explicitly.
The original fix for CVE-2026-9277 only rejected line terminators inside the comment's own text, not in tokens that come after it. 1.11.0 closes that gap by rejecting a line terminator in any string token once a comment token has been seen.
node poc.js
Expected output: the vulnerable snapshot executes the injected id (proven by a marker file written to the OS temp dir), and the patched snapshot throws a TypeError for the same input.
--- 1) Vulnerable quote() (shell-quote < 1.11.0) ---
quote() output:
echo ok #x 'a
id > /tmp/.../shell-quote-poc-12345.marker;#'
ok
[VULNERABLE] injected `id` ran outside the quoted argument -> ... was created:
uid=501(...) gid=20(...) ...
--- 2) Patched quote() (shell-quote >= 1.11.0) ---
[PATCHED] quote() threw TypeError: a token after a `comment` must not contain line terminators
vulnerable/quote.js — quote.js as it existed immediately before the fix commit (shell-quote < 1.11.0).patched/quote.js — the current, patched quote.js (shell-quote >= 1.11.0).poc.js — runs the same malicious call against both and reports the result.Both snapshots are taken from the upstream shell-quote repository and carry its original MIT license/copyright (see LICENSE).
Upgrade to [email protected] or later. If you can't upgrade immediately, per the advisory's workaround: drop every token after a { comment } token before calling quote(), or reject line terminators in untrusted strings before they reach it.