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