GHSL-2021-027: Regular expression Denial of Service in ProtonMail - CVE-2021-32816
ProtonMail's method for extracting public keys from a message used regular expressions vulnerable to exponential backtracking. An attacker could supply a crafted input string to cause the regular expression to run for an extremely long time, leading to 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 contain overlapping or ambiguous clauses that allow exponential backtracking when matching certain inputs.
Impact
This issue may lead to a denial of service.
What the attacker needed
Ability to supply input to key extraction
The fix
The bug was fixed by removing the ambiguity in the regular expressions.
How it was found
- Run the provided JavaScript code with node.
- The code defines an attack string and three regular expressions.
- Calling test on each regular expression with the attack string does not terminate.
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 be written so that a specially crafted input makes the matching process take exponentially longer, freezing the program. Here, an attacker could send a message with a particular string that makes ProtonMail's key-extraction code hang, so the service becomes 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.