Vulnerabilities in pkg:npm/@highlightjs/cdn-assets
PACKAGEGHSA-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.
pkg:npm/@highlightjs/cdn-assets
Vulnerability advisories affecting package pkg:npm/@highlightjs/cdn-assets. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-7wwv-vh3v-89cq | - | MODERATE | ReDOS vulnerabities: multiple grammars |
GHSA-7wwv-vh3v-89cq at a Glance
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.
npm install highlight.js@10.4.1
npm install @highlightjs/cdn-assets@10.4.1
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
GHSA-7wwv-vh3v-89cq Affected ReDOS vulnerabities Versions
2 component(s)| 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?
Which ReDOS vulnerabities versions are affected?
What version fixes GHSA-7wwv-vh3v-89cq?
Is highlight.js affected?
Is @highlightjs/cdn-assets affected?
What CWE is associated with GHSA-7wwv-vh3v-89cq?
How can I check npm dependencies for GHSA-7wwv-vh3v-89cq?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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
}
}