Skip to content
DoS Disclosed report Intermediate CVE-2022-2596

node-fetch Inefficient Regular Expression Complexity

The node-fetch package contains a regular expression in its referrer handling that can be made to run very slowly by a crafted URL with alternating letters and periods. An attacker could cause a denial of service by supplying such a URL.

node-fetch/node-fetch

Originally disclosed on huntr

node-fetch is a light-weight module that brings window.fetch to node.js.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the isOriginPotentiallyTrustworthy() function in referrer.js, when processing a URL string with alternating letters and periods, such as 'http://' + 'a.a.'.repeat(i) + 'a'.

From the GitHub Advisory Database (GHSA-vp56-6g26-6827, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the regular expression used in the isOriginPotentiallyTrustworthy function has catastrophic backtracking when matching strings with many alternating letters and periods.

Impact

An attacker could cause a denial of service by making the application process a crafted URL, potentially making it unresponsive.

What the attacker needed

Ability to supply a crafted URL

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A regular expression is a pattern used to match text. Some patterns can take a very long time to check certain inputs, which can freeze the program. Here, a specially crafted web address could make the library hang, so an attacker could stop the service from responding.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from node-fetch/node-fetch

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.