Regular Expression Denial of Service (ReDoS)
The is-my-json-valid package used a regular expression to validate email addresses that could take a very long time to match certain long inputs. An attacker could supply a crafted email string to block the event loop and cause a denial of service.
Originally disclosed on HackerOne
- Triaged in 10 days
- Fixed in 12 months
- Disclosed after 13 months
The issue was already fixed.
Module: is-my-json-valid
Summary: Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks. It used a regular expression (/^\S+@\S+$/) in order to validate emails. This can cause an impact of about 10 seconds matching time for data 90K characters long.
Description: Regex: formats.js exports[‘email’] = /^\S+@\S+$/ (introduced in 2014, 34a1a706)
Supporting Material/References:
- https://github.com/mafintosh/is-my-json-valid/pull/159
- https://github.com/mafintosh/is-my-json-valid/commit/b3051b277f7caa08cd2edc6f74f50aeda65d2976
Impact
Denial of service through blocking the event loop.
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 email validation regular expression was not designed to handle long, repetitive inputs efficiently, leading to excessive backtracking.
Impact
An attacker could cause a denial of service by blocking the event loop with a crafted long email string.
What the attacker needed
Ability to supply input validated as email
The fix
The issue was fixed.
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 specially crafted long input, which ties up the program and stops it from doing other work. Here, an email-checking pattern could be made to run for many seconds, effectively freezing the 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.