Medium

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

  • Disclosed: 10.11.2026
  • Updated: 11.11.2026 00:17

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 handler.

Resources

Severity

CVSS 3.1: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H (5.9, Moderate) CVSS 4.0 (informational): CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N (8.2) CVSS 4.0 has no counterpart to 3.1's AC:H beyond AT:P and scores this higher; the severity rating follows CVSS 3.1.

Credits

Reported by @manus-pi.

Proof of concept

var response = forge.http.createResponse();
var ws = new Array(40001).join('\t ');
response.readHeader(forge.util.createBuffer(
  'HTTP/1.1 200 OK\r\nX-A: a' + ws + 'X\r\n\r\n'));
// <= 1.4.2: about 4 seconds (quadratic in the whitespace length)
// 1.4.3: about 1 ms

Regression tests are in tests/security/ghsa-6cv4-p8m7-4r25.js.

Impact

Applications that use forge.http to talk to servers they don't control are affected. The server, or an on-path attacker, can send a response header that blocks the client's event loop for minutes, denying service to everything else in the process. There is no confidentiality or integrity impact.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package node-forge >= 0.1.2, < 1.4.3 1.4.3

References

CVSS score 5.9/10
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness (CWE)
CWE-1333
Platform
npm
Package
node-forge
Disclosed
10.11.2026
Updated
11.11.2026 00:17

Sources and licenses

OSV / GitHub Advisory Database - GHSA-6cv4-p8m7-4r25 - CC BY 4.0

Vulnerability history: node-forge

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (35) in the archive
Total entries
35
First → latest
09.2020 11.2026
Without a fix
1
Exploited in attacks
0

Severity breakdown

  • High 16
  • Medium 10
  • Low 9

Disclosures per year

  1. 2020: 1
  2. 2021: 0
  3. 2022: 7
  4. 2023: 0
  5. 2024: 0
  6. 2025: 3
  7. 2026: 24
Severity:
  1. Forge: ReDoS in forge.http response header and cookie trimming this entry
    Medium · 5.9 CVE-2026-125333 >= 0.1.2, < 1.4.3 1.4.3
  2. High CVE-2025-66031 < 1.3.2 1.3.2
  3. High · 7.5 CVE-2022-24772 < 1.3.0 1.3.0
  4. High · 7.5 CVE-2022-24771 < 1.3.0 1.3.0
  5. High · 9.8 CVE-2020-7720 < 0.10.0 0.10.0

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.