MEDIUM 5.9

CVE-2026-9679: Undici Cookie Parser HTTP Header Injection Vulnerability

Undici, a popular Node.js HTTP client library, contains a cookie parsing flaw that incorrectly decodes percent-encoded characters in Set-Cookie headers. When applications use undici's cookie parsing functions and then forward the parsed values into HTTP response headers—a common pattern in proxies, middleware, and server-side rendering frameworks—attackers can inject malicious headers into downstream responses. This enables session hijacking, open redirects, or cache poisoning attacks. The vulnerability affects undici versions 7.0.0 through 7.27.x and 8.0.0 through 8.4.x.

Source data · NVD / CISA · public domain

CVSS
3.1 · 5.9 MEDIUM · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Weaknesses (CWE)
CWE-93
Affected products
1 configuration(s)
Published / Modified
2026-06-17 / 2026-06-25

NVD description (verbatim)

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.

2 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

Undici's parseSetCookie and related functions apply percent-decoding (qsUnescape) to cookie values, converting encoded sequences such as %0D%0A (carriage return + line feed), %00 (null), %3B (semicolon), and %3D (equals) into their literal byte equivalents. RFC 6265 §5.4, the HTTP State Management Mechanism standard, specifies no such decoding, and browsers do not perform this decoding either. When applications parse a Set-Cookie header from an upstream response and forward the decoded cookie value directly into their own response headers without sanitization, an attacker controlling the upstream can craft a malicious cookie value containing encoded newlines and special characters that, once decoded by undici and echoed into the response, become literal control characters. This breaks the HTTP header boundary and allows injection of entirely new headers. The root cause was introduced in undici 7.0.0 via PR #3789.

Business impact

This vulnerability poses a session security and cache integrity risk for any organization running applications that proxy or middleware HTTP traffic using undici. Session fixation attacks allow attackers to pre-set victim sessions, potentially escalating to account takeover. Open redirect vulnerabilities can be weaponized in phishing campaigns. Cache poisoning affects content delivery networks and reverse proxies, allowing attackers to serve malicious content to all downstream users. Organizations using undici in production—particularly those in ecommerce, SaaS, and content delivery—face both direct exploitation risk and reputational damage if poisoned responses reach end users.

Affected systems

The vulnerability affects undici versions 7.0.0 through 7.27.x (pending v7.28.0 patch) and 8.0.0 through 8.4.x (pending v8.5.0 patch). Undici 6.x versions remain unaffected. Any Node.js application or framework using undici's cookie parsing functions (parseSetCookie, parseCookie, getSetCookies) is potentially affected if those parsed values are forwarded into response headers. This includes Next.js and other SSR frameworks, API proxies, and middleware that rely on undici for HTTP handling.

Exploitability

Exploitation requires two conditions: an application must parse Set-Cookie headers using undici and forward the parsed cookie value into a response header without sanitization. The attacker must control or influence the upstream Set-Cookie response—typically via a compromised or attacker-controlled API, or via an open redirect in a trusted service. The CVSS score of 5.9 (MEDIUM) reflects the high impact (response header injection) but assumes the attacker lacks direct access and the vulnerable code path must be present and actively used. Real-world exploitability depends on deployment context; applications that proxy user-supplied URLs or trust upstream APIs are at higher risk.

Remediation

Upgrade undici immediately: to v6.26.0 for LTS users, v7.28.0 for stable users, or v8.5.0 for bleeding-edge users. Verify your package.json and dependency tree for undici versions and apply the appropriate patch. If immediate upgrade is infeasible, implement input sanitization on all cookie values returned by undici before forwarding them into response headers; explicitly strip or reject CR (\r), LF (\n), NUL (\0), semicolon (;), and equals (=) bytes. This is a temporary workaround only and does not address the underlying design flaw.

Patch guidance

Patches are available in undici v6.26.0, v7.28.0, and v8.5.0. Determine which version line your application depends on and upgrade accordingly. Most Node.js projects should target v8.5.0 unless constrained to LTS or specific compatibility requirements. After upgrading, run your application's test suite to confirm no regressions, then deploy to staging to validate behavior with real upstream services before rolling to production. Monitor your package management tools (npm, yarn) for any additional undici advisories during rollout.

Detection guidance

Review your application logs for unusual Set-Cookie, Location, or Cache-Control headers in outbound responses, particularly those containing newlines or special characters. If your application proxies HTTP traffic, inspect upstream responses before they are forwarded downstream. Check for undici version usage via `npm ls undici` and cross-reference against the affected version ranges (7.0.0–7.27.x, 8.0.0–8.4.x). Runtime monitoring for header injection patterns—detecting CR/LF bytes in response header values—can catch exploitation attempts. Consider adding a lint rule or pre-deployment check that flags code paths forwarding parseSetCookie output directly into response headers without sanitization.

Why prioritize this

Although the CVSS score is MEDIUM (5.9), this vulnerability warrants HIGH prioritization because it affects a widely used library in the Node.js ecosystem and enables header injection—a gateway vulnerability for session attacks and cache poisoning. Many organizations use undici indirectly through frameworks or proxies without realizing it. The fix is straightforward (version bump), so rapid patching is feasible and should be prioritized for any production services handling authentication or sensitive content.

Risk score, explained

CVSS 5.9 (MEDIUM) is assigned because the vulnerability has network-adjacent attack complexity (an attacker must control or influence an upstream response), requires no user interaction, and yields high integrity impact (response header injection) but no confidentiality or availability impact. The score does not fully capture the downstream business risk—session hijacking and cache poisoning are high-impact attack vectors—which is why manual risk assessment and prioritization should supplement the CVSS score in organizational context.

Frequently asked questions

Does this affect me if I use undici only for outbound HTTP requests and do not parse Set-Cookie headers?

No. The vulnerability requires that you call parseSetCookie, parseCookie, or getSetCookies and then forward the result into a response header. If your application only makes HTTP requests without explicitly parsing or re-forwarding cookies, you are not vulnerable. However, check your framework's internals; Next.js and similar SSR frameworks may use undici's cookie parsing internally.

Can I safely upgrade from undici 7.x to 8.x without compatibility concerns?

Upgrading from 7.x to 8.x may include breaking changes unrelated to this vulnerability. Review undici's changelog between your current version and v8.5.0, and test thoroughly in staging. If breaking changes are a concern, upgrade to v7.28.0 instead, which provides the security fix with minimal disruption.

What exactly is the difference between undici's behavior and RFC 6265?

RFC 6265 §5.4 specifies that Set-Cookie values should be parsed as-is, with no percent-decoding applied. Undici applied percent-decoding (converting %0D into a literal carriage return, etc.), which violates the standard and creates an injection vector. Browsers also do not decode Set-Cookie values, making undici's behavior a non-standard deviation that introduces risk.

If I implement the recommended sanitization workaround, am I fully protected?

The workaround—stripping CR, LF, NUL, semicolon, and equals bytes from cookie values before forwarding them—eliminates the injection vector and reduces risk to near-zero for this specific vulnerability. However, it is a band-aid; the underlying design flaw (non-standard decoding) remains. You should still upgrade to a patched version as soon as feasible to address the root cause.

This analysis is based on the CVE disclosure published 2026-06-17 and modified 2026-06-25. Security landscape and remediation strategies may evolve; always consult official vendor advisories and your organization's security policies. This vulnerability is not currently listed on CISA's Known Exploited Vulnerabilities (KEV) catalog, though absence from the KEV list does not guarantee the vulnerability is not being exploited in the wild. Verify patch availability and compatibility with your specific Node.js and undici versions before deploying. SEC.co does not provide legal, compliance, or operational guidance; coordinate patching decisions with your infrastructure and security teams. Source: NVD (public-domain), retrieved 2026-07-27. Analysis generated by SEC.co (claude-haiku-4-5).