Aug 4, 2026·7 min read·43 visits
A vulnerability in Undici allows remote attackers to inject arbitrary cookie attributes (such as SameSite, HttpOnly, and Secure) via unsanitized domain inputs and custom unparsed options arrays, undermining core web-security mitigations like CSRF protections.
CVE-2026-16729 (GHSA-v3r7-h72x-cjcm) is a medium-severity cookie attribute injection vulnerability in Undici's web-compliant cookie utility module. Due to insufficient validation of domain parameters and raw attributes in the unparsed options array, arbitrary attributes like SameSite, HttpOnly, and Secure can be injected. This allows attackers to bypass CSRF protections, strip security flags, or override intended cookie behaviors when applications pass user-controlled values to these properties.
Undici is the standard, high-performance HTTP/1.1 client for Node.js, forming the backbone of the global fetch API implementation inside modern Node.js environments. Within Undici, cookie serialization and compliance are handled by dedicated utilities inside lib/web/cookies/util.js. This file exports functions such as setCookie and stringify to help developers easily craft and apply Set-Cookie headers.
The attack surface exists when host applications take untrusted user inputs and map them directly to parameters used in cookie generation, such as tenant-specified domain scopes or dynamic preference arrays. In these architectural patterns, if the underlying HTTP client library lacks robust parameter validation, structural delimiters can be smuggled directly into the header payload.
This specific vulnerability is classified as CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component). Successful exploitation allows attackers to manipulate cookie attributes, potentially stripping integrity flags or forcing configurations that reduce client-side protections. The impact is restricted to cookies processed by downstream user agents (browsers) that receive the malformed headers generated by the library.
The root cause of the vulnerability lies in two separate code paths in lib/web/cookies/util.js that failed to sanitize inputs before generating the final Set-Cookie header. The first flaw resides within the validateCookieDomain helper function. This function was implemented using a blacklist check that only rejected domains starting with a hyphen or ending with a period or hyphen.
This blacklist-based verification failed to check for standard delimiters, most notably the semicolon (;). Because semicolons serve as structural parameter boundaries in HTTP cookie headers, an attacker supplying a domain string like example.com; SameSite=None; Secure could easily inject arbitrary parameters. Undici would directly append this string to the outgoing header, and downstream browsers would parse the injected parameters as separate, valid cookie attributes.
The second flaw exists in the custom attribute serialization loop of the stringify function. This loop iterates over the unparsed options array, which is intended to allow developers to define raw custom cookie configurations. The pre-patch loop split each element on the first equal sign (=) and immediately appended them to the output list without executing any security-critical validations on either the keys or values. If user input reached this array, arbitrary characters could be injected into the output sequence.
To fix this vulnerability, the development team replaced the fragile blacklist validations with robust, RFC-compliant whitelists. The patches were backported across three major version branches. The critical changes target both domain verification and unparsed options verification.
In the patched version of validateCookieDomain, Undici implements a precise character-by-character scanner that enforces RFC 1034, RFC 1123, and RFC 1035 standards. The code now checks that domain segments (labels) only contain alphanumeric characters or hyphens, that labels do not exceed 63 characters, and that the total domain length does not exceed 255 characters. Semicolons and other non-compliant characters now trigger immediate validation errors.
// Patched validateCookieDomain implementation in lib/web/cookies/util.js
function validateCookieDomain (domain) {
if (domain === ' ') {
return
}
if (domain.length > 255) {
throw new Error('Invalid cookie domain')
}
let labelLength = 0
for (let i = 0; i < domain.length; ++i) {
const code = domain.charCodeAt(i)
if (code === 0x2E) { // "."
if (labelLength === 0 || domain.charCodeAt(i - 1) === 0x2D) {
throw new Error('Invalid cookie domain')
}
labelLength = 0
continue
}
if (labelLength === 0 && !isLetterOrDigit(code)) {
throw new Error('Invalid cookie domain')
}
if (!isLetterOrDigit(code) && code !== 0x2D) { // "-"
throw new Error('Invalid cookie domain')
}
if (++labelLength > 63) {
throw new Error('Invalid cookie domain')
}
}
if (labelLength === 0 || domain.charCodeAt(domain.length - 1) === 0x2D) {
throw new Error('Invalid cookie domain')
}
}Additionally, the stringify function was patched to validate elements from the unparsed array. Instead of appending elements directly, the patched code validates both the keys and values using existing utility methods:
// Patched serialization block in stringify()
const [key, ...value] = part.split('=')
const trimmedKey = key.trim()
const joinedValue = value.join('=')
// These helpers ensure neither keys nor values contain injection delimiters
validateCookieName(trimmedKey)
validateCookieValue(joinedValue)
out.push(`${trimmedKey}=${joinedValue}`)To exploit CVE-2026-16729, an attacker must locate an application interface that exposes the domain configuration of cookies or the unparsed attribute array to user-controlled parameters. This is common in multi-tenant architectures, where cookie scopes are dynamically determined from incoming host headers, or in proxy servers that handle cookie propagation.
In a typical attack scenario targeting the domain parameter, an attacker submits a modified HTTP request where the query string contains structural cookie delimiters. For instance, sending ?tenant_domain=victim.com;%20SameSite=None;%20Secure forces the application to produce a malformed header.
Because standard browsers prioritize initial configuration parameters or fail to resolve duplicate attribute conflicts safely, appending an injected SameSite=None parameter can override the application's default SameSite=Lax setting. This successfully strips the client-side cross-site request forgery (CSRF) protections. Similarly, an injection into the unparsed array using X-Attr=Val; HttpOnly can alter the visibility of session tokens to client-side scripts, disrupting session integrity controls.
The overall impact of CVE-2026-16729 is rated as Medium with a CVSS v3.1 score of 4.8. The attack complexity is classified as high because exploitation requires specific application-level configurations that expose Undici's cookie parameters to raw user inputs.
If exploited, the confidentiality and integrity of web sessions can be compromised. For example, stripping the HttpOnly or Secure attributes enables cross-site scripting (XSS) payloads to extract sensitive session keys or facilitates the interception of cookies over unencrypted channels. Conversely, injecting SameSite=None exposes critical session cookies to CSRF attacks.
The vulnerability is currently not known to be used in active ransomware campaigns, nor has it been added to the CISA Known Exploited Vulnerabilities (KEV) catalog. No active exploitation has been observed, and public proof-of-concept codes are limited to manual verification scripts.
The definitive remediation for this vulnerability is upgrading Undici to a secure, patched release depending on the active major release branch. Applications running on the 6.x line must upgrade to 6.28.0 or higher. Applications running on 7.x must upgrade to 7.29.0 or higher, and applications on 8.x must upgrade to 8.9.0 or higher.
If library upgrades cannot be immediately scheduled, temporary mitigation must be enforced at the application layer. Developers must apply a strict regular expression to sanitize domain inputs before passing them to the setCookie utility. This validation filter must reject any inputs containing semicolons, spaces, or control characters.
// Temporary input-level sanitization filter
const RFC_1123_DOMAIN_REGEX = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
function sanitizeDomain(domainInput) {
const trimmed = domainInput.trim();
if (trimmed === '') return ' ';
if (!RFC_1123_DOMAIN_REGEX.test(trimmed) || trimmed.length > 255) {
throw new Error('Security Violation: Invalid domain configuration input');
}
return trimmed;
}Security teams must verify nested dependency trees using dependency-lock audit tools to ensure older versions of Undici are not introduced transitively via dependent packages.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
undici Node.js / OpenJS Foundation | < 6.28.0 | 6.28.0 |
undici Node.js / OpenJS Foundation | >= 7.0.0 < 7.29.0 | 7.29.0 |
undici Node.js / OpenJS Foundation | >= 8.0.0 < 8.9.0 | 8.9.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-74 |
| Attack Vector | Network |
| CVSS v3.1 Score | 4.8 |
| Exploit Status | poc |
| CISA KEV Status | No |
| Ransomware Association | No |
The software constructs an output using input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the structure of the output when processed by a downstream component.
NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.
CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.
CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.
CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.
A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.
CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.