GHSL-2020-293: Regular expression Denial of Service in react-native - CVE-2020-1920
A regular expression used to validate URLs in react-native is vulnerable to catastrophic backtracking, allowing an attacker to cause a denial of service by supplying a crafted URL. The report demonstrates that a long string of digits and dots can make the regex take exponential time.
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
The regular expression contains overlapping alternatives that allow many ways to match the same input, leading to exponential backtracking.
Impact
This issue may lead to a denial of service.
What the attacker needed
Attacker can control URL input; application uses validateBaseUrl
The fix
The regular expression should be fixed by removing ambiguity and overlap between its clauses, as was done in the released version 0.64.1.
How it was found
- Copy the validateBaseUrl function containing the vulnerable regex into a JavaScript file.
- Run the file with Node.js.
- Call validateBaseUrl with a crafted URL consisting of 'http://foobar.' followed by many '00.' segments.
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 check text. Some patterns can become extremely slow when given a specially crafted input, like a very long string of numbers and dots. This slowness can freeze the program, which is called 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.