GHSL-2020-299: ReDoS (Regular Expression Denial of Service) in simple-markdown
The simple-markdown library contained a regular expression vulnerable to ReDoS, where a crafted input string could cause exponential backtracking and excessive CPU usage. An attacker could exploit this to cause a denial of service by supplying a malicious markdown string.
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 had overlapping or ambiguous clauses that allowed exponential backtracking on crafted input.
Impact
This issue may lead to a denial of service.
What the attacker needed
Attacker can control markdown input; library used to parse untrusted input
The fix
The issue was fixed in version 0.7.3 by removing the ambiguity in the regular expression.
How it was found
- Install simple-markdown using npm.
- Create a JavaScript file that requires simple-markdown and calls the default block parser with a crafted string.
- Run the file with node to trigger the slow regex.
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 be written in a way that makes them very slow when given certain inputs, because the computer tries many possible ways to match. This report shows that a markdown parsing library had such a pattern, so a specially crafted input could make the program hang or use too much CPU, causing a denial of service.
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.