Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CVE–2020–26237 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

debricked[bot]
Copy link

@debricked debricked bot commented Jun 30, 2021

CVE–2020–26237

Vulnerable dependency:     highlight.js (npm)    9.18.1

Vulnerable dependency:     @types/highlight.js (npm)    9.12.3

Vulnerability details

Description

Modification of Assumed-Immutable Data (MAID)

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

NVD

Highlight.js is a syntax highlighter written in JavaScript. Highlight.js versions before 9.18.2 and 10.1.2 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. 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.

GitHub

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:

CVSS details - 6.8

 

CVSS3 metrics
Attack Vector Network
Attack Complexity Low
Privileges Required Low
User interaction Required
Scope Changed
Confidentiality None
Integrity High
Availability None
References

    (parser) use null prototype objects for languages/aliases (#2636) · highlightjs/highlight.js@7241013 · GitHub
    use null prototype objects for languages/aliases by night · Pull Request #2636 · highlightjs/highlight.js · GitHub
    Prototype Pollution · Advisory · highlightjs/highlight.js · GitHub
    highlight.js - npm
    [SECURITY] [DLA 2511-1] highlight.js security update
    NVD - CVE-2020-26237
    Prototype Pollution in highlight.js · CVE-2020-26237 · GitHub Advisory Database · GitHub
    highlight.js/VERSION_10_BREAKING_CHANGES.md at main · highlightjs/highlight.js · GitHub
    highlight.js/VERSION_10_UPGRADE.md at main · highlightjs/highlight.js · GitHub
    highlight.js/SUPPORTED_LANGUAGES.md at main · highlightjs/highlight.js · GitHub
    GitHub - highlightjs/highlight.js: JavaScript syntax highlighter with language auto-detection and zero dependencies.
    Issues · highlightjs/highlight.js · GitHub
    highlight.js/AUTHORS.txt at master · highlightjs/highlight.js · GitHub
    highlight.js/LICENSE at main · highlightjs/highlight.js · GitHub
    Actions · highlightjs/highlight.js · GitHub
    (parser) Deprecate useBR · Issue #2559 · highlightjs/highlight.js · GitHub
    highlight.js/SECURITY.md at main · highlightjs/highlight.js · GitHub

 

Related information

📌 Remember! Check the changes to ensure they don't introduce any breaking changes.
📚 Read more about the CVE

 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants