---
title: "GHSA-vfrc-7r7c-w9mx: Prototype Pollution in highlight.js"
description: "Moderate severity. Prototype Pollution in highlight.js. Affects highlight.js; fixed in 10.1.2."
url: https://inlinr.com/advisories/GHSA-vfrc-7r7c-w9mx
lang: en
---

[Packages](https://inlinr.com/packages) / [highlight.js](https://inlinr.com/packages/highlight.js) / [Security](https://inlinr.com/packages/highlight.js/security)

Moderate Vulnerability GHSA-vfrc-7r7c-w9mx CVE-2020-26237 Published 24 Nov 2020

# Prototype Pollution in highlight.js

Your version 

Affected releases · [highlight.js](https://inlinr.com/packages/highlight.js)

- 10.x 10.0.0 – 10.1.1 Fixed in 10.1.2
- 9.x 9.0.0 – 9.18.1 Fixed in 9.18.2
- 8.x and older 1.0.0 – 8.9.1 No fix, no longer updated

On 10.x, the newest line:

```
npm install highlight.js@10.1.2
```

Every release on a timeline

11.x 

1. Not affected

11.0.0 – 11.12.0  
18 releases, latest

10.x 

1. Affected

10.0.0 – 10.1.1  
6 releases
2. Fixed

10.1.2 – 10.7.3  
14 releases

9.x 

1. Affected

9.0.0 – 9.18.1  
31 releases
2. Fixed

9.18.2 – 9.18.5  
4 releases

8.x 

1. Affected

8.0.0 – 8.9.1  
11 releases

7.x 

1. Affected

7.0.1 – 7.5.0  
6 releases

1.x 

1. Affected

1.0.0 – 1.2.0  
8 releases

98 stable releases of highlight.js, oldest to newest, one row per major.

## What happens

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

- [What is Prototype Pollution?](https://codeburst.io/what-is-prototype-pollution-49482fc4b638 "https://codeburst.io/what-is-prototype-pollution-49482fc4b638")
- [#2636](https://github.com/highlightjs/highlight.js/pull/2636 "https://github.com/highlightjs/highlight.js/pull/2636")

For more information

If you have any questions or comments about this advisory:

- Please file an issue against [highlight.js](https://github.com/highlightjs/highlight.js/issues/ "https://github.com/highlightjs/highlight.js/issues/")

## How it is exploited

Exploitable over the network, with a low-privilege account and a user to do something.

- **Confidentiality**: none
- **Integrity**: high
- **Availability**: none

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

## References

- [Reference](https://github.com/highlightjs/highlight.js/security/advisories/GHSA-vfrc-7r7c-w9mx "https://github.com/highlightjs/highlight.js/security/advisories/GHSA-vfrc-7r7c-w9mx")  
github.com/highlightjs/highlight.js/security/ad…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2020-26237 "https://nvd.nist.gov/vuln/detail/CVE-2020-26237")  
nvd.nist.gov/vuln/detail/CVE-2020-26237
- [Pull request](https://github.com/highlightjs/highlight.js/pull/2636 "https://github.com/highlightjs/highlight.js/pull/2636")  
#2636
- [Fix commit](https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0 "https://github.com/highlightjs/highlight.js/commit/7241013ae011a585983e176ddc0489a7a52f6bb0")  
7241013
- [Package](https://github.com/highlightjs/highlight.js "https://github.com/highlightjs/highlight.js")  
github.com/highlightjs/highlight.js
- [Reference](https://lists.debian.org/debian-lts-announce/2020/12/msg00041.html "https://lists.debian.org/debian-lts-announce/2020/12/msg00041.html")  
lists.debian.org/debian-lts-announce/2020/12/ms…
- [Reference](https://www.npmjs.com/package/highlight.js "https://www.npmjs.com/package/highlight.js")  
npmjs.com/package/highlight.js
- [Reference](https://www.oracle.com/security-alerts/cpujul2022.html "https://www.oracle.com/security-alerts/cpujul2022.html")  
oracle.com/security-alerts/cpujul2022.html

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
