Skip to content
Medium 5.9

Forge: ReDoS in forge.http response header and cookie trimming

CVE-2026-125333 First seen on SecPulse

Affected packages

PackageAffected → Fixed
digitalbazaarforge —
npmnode-forge
< 1.4.3→ 1.4.3

Fix status by distribution

Records published by each distribution for this CVE. Fixed versions differ by release; check each link.

Original description The description as published by the source.

forge.http trims response header and Set-Cookie values with the regular expression /\s*$/, which takes quadratic time on a long run of whitespace followed by another character. A server or on-path attacker can block a forge.http client for minutes with one large response header. Fixed in node-forge 1.4.3.

Details

_trimString() in lib/http.js removes trailing whitespace with str.replace(/\s*$/, ''). On a string of n whitespace characters followed by a non-whitespace character, the regular expression engine tries a match at each of the n positions and scans the rest of the run each time, so the work is O(n^2). forge.http calls _trimString() on every response header value read by response.readHeader(), and again on cookie names and values in response.getCookies(). There is no limit on header size.

With Node.js 24, an 80 KB header value takes about 4 seconds to parse, and 1 MB about 10 minutes, during which the event loop (or browser tab) is blocked.

forge.http is not loaded by require('node-forge'). It is part of the forge.all bundle and needs a socket pool provided by the application (historically Flash sockets via forge.xhr), so few applications use it.

The fix trims trailing whitespace with a loop, as lib/pem.js has done since 1.4.1. The trimmed result is unchanged.

Patches

Fixed in node-forge 1.4.3.

Workarounds

Limit the size of HTTP response headers before passing them to forge.http, for example in the socket pool's data…

Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details