CVE-2021-29060: Color string Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-257v-vj4p-3w2h
CVSS 5.3
CWE-770
Published
Advisory Summary

CVE-2021-29060 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Color string libraries in the npm ecosystem. The issue involves regular expression denial of service (redos). Remediation is available by upgrading affected packages to version 1.5.5.

CVE-2021-29060 at a Glance

CVE Identifier CVE-2021-29060
GHSA Identifier GHSA-257v-vj4p-3w2h
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Color string
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2021-29060

To remediate this vulnerability, upgrade all affected Color string dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

color-string fixed: 1.5.5
npm install color-string@1.5.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls color-string

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-29060, inspect your project dependencies using npm:

npm ls color-string

Analyze the terminal output to locate any version of Color string in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.5), your application is affected.

Note: The npm ls color-string command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Color string, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

In the npm package `color-string`, there is a ReDos (Regular Expression Denial of Service) vulnerability regarding an exponential time complexity for linearly increasing input lengths for `hwb()` color strings. Strings reaching more than 5000 characters would see several milliseconds of processing time; strings reaching more than 50,000 characters began seeing 1500ms (1.5s) of processing time. The cause was due to a the regular expression that parses hwb() strings - specifically, the hue value - where the integer portion of the hue value used a 0-or-more quantifier shortly thereafter followed by a 1-or-more quantifier. This caused excessive backtracking and a cartesian scan, resulting in exponential time complexity given a linear increase in input length.

CVE-2021-29060 Affected Color string Versions

1 component(s)
Fixed Versions:
1.5.5
Product / Package Ecosystem Affected Versions Fixed Version
color-string
npm
< 1.5.5
1.5.5

References

Frequently Asked Questions

What is CVE-2021-29060?
CVE-2021-29060 is a security vulnerability in Color string involving Regular Expression Denial of Service (ReDOS) under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Color string versions are affected?
Affected versions include releases prior to 1.5.5 across affected packages: color-string.
What version fixes CVE-2021-29060?
Upgrading to 1.5.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is color-string affected?
Yes, color-string is affected in releases prior to 1.5.5. Upgrade your dependency to 1.5.5 or later.
What is the CVSS score of CVE-2021-29060?
CVE-2021-29060 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2021-29060?
CVE-2021-29060 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check npm dependencies for CVE-2021-29060?
Run the dependency tree command: 'npm ls color-string'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-257v-vj4p-3w2h",
  "modified" : "2021-06-30T18:03:29Z",
  "published" : "2021-06-22T01:14:09Z",
  "aliases" : [ "CVE-2021-29060" ],
  "summary" : "Regular Expression Denial of Service (ReDOS)",
  "details" : "In the npm package `color-string`, there is a  ReDos (Regular Expression Denial of Service) vulnerability regarding an exponential time complexity for\nlinearly increasing input lengths for `hwb()` color strings.\n\nStrings reaching more than 5000 characters would see several\nmilliseconds of processing time; strings reaching more than\n50,000 characters began seeing 1500ms (1.5s) of processing time.\n\nThe cause was due to a the regular expression that parses\nhwb() strings - specifically, the hue value - where\nthe integer portion of the hue value used a 0-or-more quantifier\nshortly thereafter followed by a 1-or-more quantifier.\n\nThis caused excessive backtracking and a cartesian scan,\nresulting in exponential time complexity given a linear\nincrease in input length.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "color-string"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29060"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Qix-/color-string/commit/0789e21284c33d89ebc4ab4ca6f759b9375ac9d3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Qix-/color-string/releases/tag/1.5.5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yetingli/PoCs/blob/main/CVE-2021-29060/Color-String.md"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yetingli/SaveResults/blob/main/js/color-string.js"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/color-string"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-06-21T23:20:37Z",
    "nvd_published_at" : "2021-06-21T16:15:00Z"
  }
}