Ecosyste.ms: Advisories

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

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXZmcmMtN3I3Yy13OW14

Prototype Pollution in highlight.js

Impact

Affected versions of this package are vulnerable to Prototype Pollution. A malicious HTML code block can be crafted that will result in prototype pollution of the base object's prototype during highlighting. If you allow users to insert custom HTML code blocks into your page/app via parsing Markdown code blocks (or similar) and do not filter the language names the user can provide you may be vulnerable.

The pollution should just be harmless data but this can cause problems for applications not expecting these properties to exist and can result in strange behavior or application crashes, i.e. a potential DOS vector.

If your website or application does not render user provided data it should be unaffected.

Patches

Versions 9.18.2 and 10.1.2 and newer include fixes for this vulnerability. If you are using version 7 or 8 you are encouraged to upgrade to a newer release.

Workarounds

Patch your library

Manually patch your library to create null objects for both languages and aliases:

const HLJS = function(hljs) {
  // ...
  var languages = Object.create(null);
  var aliases = Object.create(null);

Filter out bad data from end users:

Filter the language names that users are allowed to inject into your HTML to guarantee they are valid.

References

For more information

If you have any questions or comments about this advisory:

Permalink: https://github.com/advisories/GHSA-vfrc-7r7c-w9mx
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXZmcmMtN3I3Yy13OW14
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: over 3 years ago
Updated: about 1 year ago


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

Identifiers: GHSA-vfrc-7r7c-w9mx, CVE-2020-26237
References: Repository: https://github.com/highlightjs/highlight.js
Blast Radius: 33.9

Affected Packages

npm:highlight.js
Dependent packages: 11,299
Dependent repositories: 700,734
Downloads: 30,865,066 last month
Affected Version Ranges: >= 10.0.0, < 10.1.2, < 9.18.2
Fixed in: 10.1.2, 9.18.2
All affected 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, 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, 10.0.0, 10.0.1, 10.0.2, 10.0.3, 10.1.0, 10.1.1
All unaffected versions: 9.18.2, 9.18.3, 9.18.4, 9.18.5, 10.1.2, 10.2.0, 10.2.1, 10.3.0, 10.3.1, 10.3.2, 10.4.0, 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