CVE-2026-9277: CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') in shell-quote
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 newline as a command separator, so any content after it would execute as a second command. The vulnerable code path is reachable in two ways: (1) direct construction of `{ op: '...\n...' }` from external input, and (2) via `parse(cmd, envFn)` when `envFn` returns object tokens whose `.op` is attacker-influenced. Both are documented API surface. Fixed by replacing the per-character escape with strict shape validation: `.op` must match the parser's control-operator allowlist; `{ op: 'glob', pattern }` validates `pattern` and forbids line terminators; `{ comment }` validates `comment` and forbids line terminators; any other object shape throws `TypeError`.
AI Analysis
Technical Summary
The shell-quote library's quote() function failed to properly escape line terminators in the .op field of object tokens, due to the use of a JavaScript regex that does not match line terminators. This allowed unescaped newlines to be injected into shell commands, which POSIX shells interpret as command separators, leading to OS command injection. The vulnerability is exploitable via two documented API surfaces: direct construction of malicious { op: '...\n...' } objects, and via parse(cmd, envFn) when envFn returns attacker-controlled tokens. The fix replaced per-character escaping with strict validation ensuring .op matches a control-operator allowlist and forbids line terminators, throwing TypeError for invalid shapes. Red Hat advisories confirm the vulnerability and provide patches for affected products.
Potential Impact
Successful exploitation allows an attacker to inject arbitrary OS commands due to improper neutralization of special elements (line terminators) in shell commands. This can lead to arbitrary code execution with the privileges of the affected application. The CVSS 3.1 base score is 8.1 (High), indicating high confidentiality, integrity, and availability impacts without requiring privileges or user interaction. No known exploits in the wild have been reported at this time.
Mitigation Recommendations
Red Hat has released security advisories and updates addressing CVE-2026-9277. Users of affected versions (shell-quote 1.1.0) should apply the vendor-provided patches or updates as soon as possible. The vulnerability is fixed by enforcing strict validation of the .op field and forbidding line terminators in object tokens. Patch status is not explicitly stated in the input data, but multiple Red Hat errata references indicate that fixes are available. Check the Red Hat advisories linked for detailed update instructions and ensure all relevant errata are applied.
CVE-2026-9277: CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') in shell-quote
Description
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 newline as a command separator, so any content after it would execute as a second command. The vulnerable code path is reachable in two ways: (1) direct construction of `{ op: '...\n...' }` from external input, and (2) via `parse(cmd, envFn)` when `envFn` returns object tokens whose `.op` is attacker-influenced. Both are documented API surface. Fixed by replacing the per-character escape with strict shape validation: `.op` must match the parser's control-operator allowlist; `{ op: 'glob', pattern }` validates `pattern` and forbids line terminators; `{ comment }` validates `comment` and forbids line terminators; any other object shape throws `TypeError`.
CVSS v3.1
Score 8.1high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The shell-quote library's quote() function failed to properly escape line terminators in the .op field of object tokens, due to the use of a JavaScript regex that does not match line terminators. This allowed unescaped newlines to be injected into shell commands, which POSIX shells interpret as command separators, leading to OS command injection. The vulnerability is exploitable via two documented API surfaces: direct construction of malicious { op: '...\n...' } objects, and via parse(cmd, envFn) when envFn returns attacker-controlled tokens. The fix replaced per-character escaping with strict validation ensuring .op matches a control-operator allowlist and forbids line terminators, throwing TypeError for invalid shapes. Red Hat advisories confirm the vulnerability and provide patches for affected products.
Potential Impact
Successful exploitation allows an attacker to inject arbitrary OS commands due to improper neutralization of special elements (line terminators) in shell commands. This can lead to arbitrary code execution with the privileges of the affected application. The CVSS 3.1 base score is 8.1 (High), indicating high confidentiality, integrity, and availability impacts without requiring privileges or user interaction. No known exploits in the wild have been reported at this time.
Mitigation Recommendations
Red Hat has released security advisories and updates addressing CVE-2026-9277. Users of affected versions (shell-quote 1.1.0) should apply the vendor-provided patches or updates as soon as possible. The vulnerability is fixed by enforcing strict validation of the .op field and forbidding line terminators in object tokens. Patch status is not explicitly stated in the input data, but multiple Red Hat errata references indicate that fixes are available. Check the Red Hat advisories linked for detailed update instructions and ensure all relevant errata are applied.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- harborist
- Date Reserved
- 2026-05-22T12:13:25.893Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Remediation Level
- null
- Vendor Advisory Urls
- [{"url":"https://access.redhat.com/security/cve/CVE-2026-9277","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:28010","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26234","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:29197","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26072","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26080","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26077","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26079","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26090","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:30076","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:28571","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:26225","vendor":"Red Hat"}]
Threat ID: 6a105dd3e1370fbb48fef13b
Added to database: 05/22/2026, 13:44:51 UTC
Last enriched: 07/30/2026, 21:59:23 UTC
Last updated: 07/31/2026, 21:26:41 UTC
Views: 113
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.