Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. shell-quote
  4. ›
  5. CVE-2026-9277

CVE-2026-9277: shell-quote quote() does not escape newlines in object .op values

June 9, 2026

shell-quote’s quote() function did not validate object-token inputs against the operator model used by parse(). The .op field was backslash-escaped character by character using /(.)/g, which in JavaScript does not match line terminators (\n, \r, U+2028, U+2029). A line terminator in .op therefore passed through unescaped into the output; POSIX shells treat a literal \n as a command separator, so any content after it would execute as a second command.

The vulnerable code path is reachable in two ways. Neither requires the parser to misbehave — parse() only emits ops from a fixed control set — but both are documented API surface:

  1. Direct construction. A caller builds { op: '...\n...' } from external input (e.g. a deserialized argument array) and passes it to quote().
  2. envFn return. parse(cmd, envFn) is documented to splice the return value of envFn into the result array when it is an object. An attacker-influenced data source consulted by envFn can introduce an object token whose .op reaches quote().

References

  • github.com/advisories/GHSA-w7jw-789q-3m8p
  • github.com/ljharb/shell-quote
  • github.com/ljharb/shell-quote/commit/1518179
  • github.com/ljharb/shell-quote/security/advisories/GHSA-w7jw-789q-3m8p
  • nvd.nist.gov/vuln/detail/CVE-2026-9277
  • www.npmjs.com/package/shell-quote

Code Behaviors & Features

Detect and mitigate CVE-2026-9277 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 1.1.0 before 1.8.4

Fixed versions

  • 1.8.4

Solution

Upgrade to version 1.8.4 or above.

Impact 8.1 HIGH

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
  • CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

Source file

npm/shell-quote/CVE-2026-9277.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Tue, 23 Jun 2026 12:24:56 +0000.