Ecosyste.ms: Advisories

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

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTd3d3Ytdmgzdi04OWNx

ReDOS vulnerabities: multiple grammars

Impact: Potential ReDOS vulnerabilities (exponential and polynomial RegEx backtracking)

oswasp:

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/[email protected]/build/highlight.js

All versions prior to 10.4.1 are vulnerable, including version 9.18.5.

Grammars with exponential backtracking issues:

And of course any aliases of those languages have the same issue. ie: hpp is no safer than cpp.

Grammars with polynomial backtracking issues:

And again: any aliases of those languages have the same issue. ie: ruby and rb share the same ruby issues.

Patches

Workarounds / Mitigations

References

For more information

If you have any questions or comments about this advisory:

Permalink: https://github.com/advisories/GHSA-7wwv-vh3v-89cq
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTd3d3Ytdmgzdi04OWNx
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: over 3 years ago
Updated: about 1 year ago


Identifiers: GHSA-7wwv-vh3v-89cq
References: Repository: https://github.com/highlightjs/highlight.js

Affected Packages

npm:@highlightjs/cdn-assets
Dependent packages: 22
Dependent repositories: 192
Downloads: 270,297 last month
Affected Version Ranges: < 10.4.1
Fixed in: 10.4.1
All affected versions: 10.0.0, 10.0.1, 10.0.2, 10.0.3, 10.1.0, 10.1.1, 10.1.2, 10.2.0, 10.2.1, 10.3.0, 10.3.1, 10.3.2, 10.4.0
All unaffected versions: 10.4.1, 10.5.0, 10.6.0, 10.7.0, 10.7.1, 10.7.2, 10.7.3, 11.0.0, 11.0.1, 11.1.0, 11.2.0, 11.3.0, 11.3.1, 11.4.0, 11.5.0, 11.5.1, 11.6.0, 11.7.0, 11.8.0, 11.9.0
npm:highlight.js
Dependent packages: 11,299
Dependent repositories: 700,734
Downloads: 30,168,812 last month
Affected Version Ranges: >= 9.0.0, < 10.4.1
Fixed in: 10.4.1
All affected versions: 9.0.0, 9.1.0, 9.2.0, 9.3.0, 9.4.0, 9.5.0, 9.6.0, 9.7.0, 9.8.0, 9.9.0, 9.10.0, 9.11.0, 9.12.0, 9.13.0, 9.13.1, 9.14.1, 9.14.2, 9.15.1, 9.15.2, 9.15.5, 9.15.6, 9.15.7, 9.15.8, 9.15.9, 9.15.10, 9.16.1, 9.16.2, 9.17.0, 9.17.1, 9.18.0, 9.18.1, 9.18.2, 9.18.3, 9.18.4, 9.18.5, 10.0.0, 10.0.1, 10.0.2, 10.0.3, 10.1.0, 10.1.1, 10.1.2, 10.2.0, 10.2.1, 10.3.0, 10.3.1, 10.3.2, 10.4.0
All unaffected versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.2.0, 7.0.1, 7.1.0, 7.2.0, 7.3.0, 7.4.0, 7.5.0, 8.0.0, 8.1.0, 8.2.0, 8.3.0, 8.4.0, 8.5.0, 8.6.0, 8.7.0, 8.8.0, 8.9.0, 8.9.1, 10.4.1, 10.5.0, 10.6.0, 10.7.0, 10.7.1, 10.7.2, 10.7.3, 11.0.0, 11.0.1, 11.1.0, 11.2.0, 11.3.0, 11.3.1, 11.4.0, 11.5.0, 11.5.1, 11.6.0, 11.7.0, 11.8.0, 11.9.0