HTTP request smuggling In nodejs

Description

Undici has an HTTP Request/Response Smuggling issue

Impact

Undici allows duplicate HTTP Content-Length headers when they are provided in an array with case-variant names (e.g., Content-Length and content-length). This produces malformed HTTP/1.1 requests with multiple conflicting Content-Length values on the wire.

Who is impacted:

    Applications using undici.request(), undici.Client, or similar low-level APIs with headers passed as flat arrays

    Applications that accept user-controlled header names without case-normalization

Potential consequences:

    Denial of Service: Strict HTTP parsers (proxies, servers) will reject requests with duplicate Content-Length headers (400 Bad Request)

    HTTP Request Smuggling: In deployments where an intermediary and backend interpret duplicate headers inconsistently (e.g., one uses the first value, the other uses the last), this can enable request smuggling attacks leading to ACL bypass, cache poisoning, or credential hijacking

Patches

Patched in the undici version v7.24.0 and v6.24.0. Users should upgrade to this version or later.

Workarounds

If upgrading is not immediately possible:

    Validate header names: Ensure no duplicate Content-Length headers (case-insensitive) are present before passing headers to undici

    Use object format: Pass headers as a plain object ({ 'content-length': '123' }) rather than an array, which naturally deduplicates by key

    Sanitize user input: If headers originate from user input, normalize header names to lowercase and reject duplicates

Mitigation

Update Impact

Minimal update. May introduce new vulnerabilities or breaking changes.

Ecosystem
Package
Affected version
Patched versions