GHSA-7wwv-vh3v-89cq: ReDOS vulnerabities Multiple Grammars Vulnerability

MODERATE
CWE-400 CWE-20
Published
Advisory Summary

GHSA-7wwv-vh3v-89cq is a MODERATE multiple grammars vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting ReDOS vulnerabities libraries in the npm ecosystem. The issue involves multiple grammars. Remediation is available by upgrading affected packages to version 10.4.1.

GHSA-7wwv-vh3v-89cq at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-7wwv-vh3v-89cq
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product ReDOS vulnerabities
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-7wwv-vh3v-89cq

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

highlight.js fixed: 10.4.1
npm install highlight.js@10.4.1
@highlightjs/cdn-assets fixed: 10.4.1
npm install @highlightjs/cdn-assets@10.4.1
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 highlight.js

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-7wwv-vh3v-89cq, inspect your project dependencies using npm:

npm ls highlight.js

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

Note: The npm ls highlight.js 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In ReDOS vulnerabities, 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

### Impact: Potential ReDOS vulnerabilities (exponential and polynomial RegEx backtracking) [oswasp](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS): > The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to work very slowly (exponentially related to input size). An attacker can then cause a program using a Regular Expression to enter these extreme situations and then hang for a very long time. If are you are using Highlight.js to highlight user-provided data you are possibly vulnerable. On the client-side (in a browser or Electron environment) risks could include lengthy freezes or crashes... On the server-side infinite freezes could occur... effectively preventing users from accessing your app or service (ie, Denial of Service). This is an issue with grammars shipped with the parser (and potentially 3rd party grammars also), not the parser itself. If you are using Highlight.js with any of the following grammars you are vulnerable. If you are using `highlightAuto` to detect the language (and have any of these grammars registered) you are vulnerable. Exponential grammars (C, Perl, JavaScript) are auto-registered when using the common grammar subset/library `require('highlight.js/lib/common')` as of 10.4.0 - see https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.0/build/highlight.js All versions prior to 10.4.1 are vulnerable, including version 9.18.5. **Grammars with exponential backtracking issues:** - c-like (c, cpp, arduino) - handlebars (htmlbars) - gams - perl - jboss-cli - r - erlang-repl - powershell - routeros - livescript (10.4.0 and 9.18.5 included this fix) - javascript & typescript (10.4.0 included partial fixes) And of course any aliases of those languages have the same issue. ie: `hpp` is no safer than `cpp`. **Grammars with polynomial backtracking issues:** - kotlin - gcode - d - aspectj - moonscript - coffeescript/livescript - csharp - scilab - crystal - elixir - basic - ebnf - ruby - fortran/irpf90 - livecodeserver - yaml - x86asm - dsconfig - markdown - ruleslanguage - xquery - sqf And again: any aliases of those languages have the same issue. ie: `ruby` and `rb` share the same ruby issues. ### Patches - Version 10.4.1 resolves these vulnerabilities. Please upgrade. ### Workarounds / Mitigations - Discontinue use the affected grammars. (or perhaps use only those with poly vs exponential issues) - Attempt cherry-picking the grammar fixes into older versions... - Attempt using newer CDN versions of any affected languages. (ie using an older CDN version of the library with newer CDN grammars). Your mileage may vary. ### References - https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS ### For more information If you have any questions or comments about this advisory: * Open an issue: https://github.com/highlightjs/highlight.js/issues * Email us at [security@highlightjs.com](mailto:security@highlightjs.com)

GHSA-7wwv-vh3v-89cq Affected ReDOS vulnerabities Versions

2 component(s)
Fixed Versions:
10.4.1
Product / Package Ecosystem Affected Versions Fixed Version
highlight.js
npm
≥ 9.0.0
< 10.4.1
10.4.1
@highlightjs/cdn-assets
npm
< 10.4.1
10.4.1

References

Frequently Asked Questions

What is GHSA-7wwv-vh3v-89cq?
GHSA-7wwv-vh3v-89cq is a security vulnerability in ReDOS vulnerabities involving multiple grammars under CWE-400: Uncontrolled Resource Consumption.
Which ReDOS vulnerabities versions are affected?
Affected versions include releases prior to 10.4.1 across affected packages: highlight.js, @highlightjs/cdn-assets.
What version fixes GHSA-7wwv-vh3v-89cq?
Upgrading to 10.4.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is highlight.js affected?
Yes, highlight.js is affected in releases prior to 10.4.1. Upgrade your dependency to 10.4.1 or later.
Is @highlightjs/cdn-assets affected?
Yes, @highlightjs/cdn-assets is affected in releases prior to 10.4.1. Upgrade your dependency to 10.4.1 or later.
What CWE is associated with GHSA-7wwv-vh3v-89cq?
GHSA-7wwv-vh3v-89cq is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for GHSA-7wwv-vh3v-89cq?
Run the dependency tree command: 'npm ls highlight.js'. 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-7wwv-vh3v-89cq",
  "modified" : "2022-05-03T08:27:45Z",
  "published" : "2020-12-04T16:47:20Z",
  "aliases" : [ ],
  "summary" : "ReDOS vulnerabities: multiple grammars",
  "details" : "### Impact: Potential ReDOS vulnerabilities (exponential and polynomial RegEx backtracking)\n\n[oswasp](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS): \n\n> The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to work very slowly (exponentially related to input size). An attacker can then cause a program using a Regular Expression to enter these extreme situations and then hang for a very long time.\n\nIf are you are using Highlight.js to highlight user-provided data you are possibly vulnerable.  On the client-side (in a browser or Electron environment) risks could include lengthy freezes or crashes... On the server-side infinite freezes could occur... effectively preventing users from accessing your app or service (ie, Denial of Service).\n\nThis is an issue with grammars shipped with the parser (and potentially 3rd party grammars also), not the parser itself. If you are using Highlight.js with any of the following grammars you are vulnerable.  If you are using `highlightAuto` to detect the language (and have any of these grammars registered) you are vulnerable. Exponential grammars (C, Perl, JavaScript) are auto-registered when using the common grammar subset/library `require('highlight.js/lib/common')` as of 10.4.0 - see https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.0/build/highlight.js\n\nAll versions prior to 10.4.1 are vulnerable, including version 9.18.5. \n\n**Grammars with exponential backtracking issues:**\n\n  - c-like (c, cpp, arduino)\n  - handlebars (htmlbars)\n  - gams\n  - perl\n  - jboss-cli\n  - r\n  - erlang-repl\n  - powershell\n  - routeros\n  - livescript (10.4.0 and 9.18.5 included this fix)\n  - javascript & typescript (10.4.0 included partial fixes)\n\nAnd of course any aliases of those languages have the same issue. ie: `hpp` is no safer than `cpp`.\n\n**Grammars with polynomial backtracking issues:**\n\n- kotlin\n- gcode\n- d\n- aspectj\n- moonscript\n- coffeescript/livescript\n- csharp\n- scilab\n- crystal\n- elixir\n- basic\n- ebnf\n- ruby\n- fortran/irpf90\n- livecodeserver\n- yaml\n- x86asm\n- dsconfig\n- markdown\n- ruleslanguage\n- xquery\n- sqf\n\nAnd again: any aliases of those languages have the same issue. ie: `ruby` and `rb` share the same ruby issues.\n\n\n### Patches\n\n- Version 10.4.1 resolves these vulnerabilities.  Please upgrade.\n\n### Workarounds / Mitigations\n\n- Discontinue use the affected grammars. (or perhaps use only those with poly vs exponential issues)\n- Attempt cherry-picking the grammar fixes into older versions...\n- Attempt using newer CDN versions of any affected languages.  (ie using an older CDN version of the library with newer CDN grammars).  Your mileage may vary.\n\n### References\n\n- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue: https://github.com/highlightjs/highlight.js/issues\n* Email us at [security@highlightjs.com](mailto:security@highlightjs.com)",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "highlight.js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "9.0.0"
      }, {
        "fixed" : "10.4.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@highlightjs/cdn-assets"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "10.4.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/highlightjs/highlight.js/security/advisories/GHSA-7wwv-vh3v-89cq"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/highlightjs/highlight.js/commit/373b9d862401162e832ce77305e49b859e110f9c"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/@highlightjs/cdn-assets"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/highlight.js"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-12-04T16:46:46Z",
    "nvd_published_at" : null
  }
}