GHSL-2020-301: Regular Expression Denial of Service (ReDoS) in HTML2Markdown - CVE-2020-26307
The HTML2Markdown library contains regular expressions for parsing HTML tags and attributes that are vulnerable to catastrophic backtracking. An attacker could supply a crafted HTML string to cause excessive CPU usage and a denial of service.
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 expressions for start tags and attributes have ambiguous repetition that allows exponential backtracking on crafted input.
What the attacker needed
Attacker controls HTML input; application uses html2markdown
How it was found
- Install the html2markdown package using npm.
- Create a JavaScript file that requires the package and calls it with a crafted HTML string containing many repeated attributes.
- Run the file with Node.js to observe the slowdown.
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.
Regular expressions are patterns used to match text. Some patterns can take a very long time to process certain inputs, especially if they have overlapping rules. Here, a specially crafted HTML string makes the library's pattern matching slow down dramatically, which can freeze the application.
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.