Skip to content

GHSA-vfrc-7r7c-w9mx CVE-2020-26237

Prototype Pollution in highlight.js

High npm
Severity
5.8 / 10
High · CVSS 3.1
Exploit chance (EPSS)
1.33%
Chance of exploitation in the next 30 days. Higher than 71.03% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-471 Modification of Assumed-Immutable Data (MAID)
Fix
9.18.2
Upgrade highlight.js to this version or later

Description

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:

Affected versions

npm

PackageVulnerableFixed in
highlight.js
< 9.18.2
9.18.2
highlight.js
>= 10.0.0, < 10.1.2
10.1.2

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

highlight.js npm → 9.18.2

npm
npm install highlight.js@9.18.2
yarn
yarn add highlight.js@9.18.2
pnpm
pnpm add highlight.js@9.18.2

Severity breakdown

CVSS 3.1 5.8

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

Attack vector
Network
Attack complexity
High
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
None
Integrity
High
Availability
None

Weakness

CWE-471: Modification of Assumed-Immutable Data (MAID)

The product does not properly protect an assumed-immutable element from being modified by an attacker.

How to prevent it
  • Architecture and Design, Operation, Implementation: When the data is stored or transmitted through untrusted sources that could modify the data, implement integrity checks to detect unauthorized modification, or store/transmit the data in a trusted location that is free from external influence.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-7wwv-vh3v-89cq
ReDOS vulnerabities: multiple grammars
Medium Also affects highlight.js
GHSA-4487-j8r4-4g2f
Forge: verifyCertificateChain() removes trusted CA certificates with the same subject from the CA store
Low Same weakness, CWE-471
GHSA-gvp8-978c-rx2q
PyJWT.decode() reintroduces options-dict mutation, enabling silent claim-verification bypass on dict reuse
Medium Same weakness, CWE-471
GHSA-633r-hq9m-c4ff
vm2: vm.freeze()/vm.readonly() bypass via accessor descriptor
Medium Same weakness, CWE-471
GHSA-cmwh-pvxp-8882
DOMPurify: Permanent `ALLOWED_ATTR` pollution via `setConfig()` bypassing the hook clone-guard (incomplete fix of the 3.4.7 hook-pollution patch)
Medium Same weakness, CWE-471
GHSA-4w2j-2rg4-5mjw
vm2 vulnerable to Arbitrary Code Execution
Critical Same weakness, CWE-471
GHSA-jcrj-gmr6-p5j8
Moodle Allows Modification of Constants
Medium Same weakness, CWE-471
GHSA-hhvc-g5hv-48c6
Write to immutable memory region in TensorFlow
Medium Same weakness, CWE-471
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor