GHSL-2020-289: Regular Expression Denial of Service (ReDoS) in insane - CVE-202026303
The insane HTML sanitizer contains a regular expression vulnerable to ReDoS, allowing an attacker to cause a denial of service by supplying a crafted input string that triggers exponential backtracking.
Originally disclosed on GitHub Security Lab
The project contains one or more regular expressions that are vulnerable to ReDoS (Regular Expression Denial of Service)
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
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 `rstart` has overlapping alternatives that cause exponential backtracking when matching certain inputs.
Impact
This issue may lead to a denial of service.
What the attacker needed
Attacker can supply input to the sanitizer
How it was found
- Install the insane package using npm.
- Create a JavaScript file that requires insane and calls it with a crafted string containing repeated patterns.
- Run the file with Node.js to observe the sanitizer hanging.
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 become extremely slow when given specially crafted input, causing the program to hang. Here, the sanitizer that cleans HTML can be tricked into taking a very long time, so a malicious user could make the service unavailable.
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.