CVE-2020-15138: Prismjs Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-wvhm-4hhf-97x9
CVSS 7.1
CWE-79
Published
Advisory Summary

CVE-2020-15138 is a HIGH (CVSS 7.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Prismjs libraries in the npm ecosystem. The issue involves cross-site scripting in prism. Remediation is available by upgrading affected packages to version 1.21.0.

CVE-2020-15138 at a Glance

CVE Identifier CVE-2020-15138
GHSA Identifier GHSA-wvhm-4hhf-97x9
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Prismjs
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2020-15138

To remediate this vulnerability, upgrade all affected Prismjs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

prismjs fixed: 1.21.0
npm install prismjs@1.21.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls prismjs

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2020-15138, inspect your project dependencies using npm:

npm ls prismjs

Analyze the terminal output to locate any version of Prismjs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.21.0), your application is affected.

Note: The npm ls prismjs command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Prismjs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The easing preview of the Previewers plugin has an XSS vulnerability that allows attackers to execute arbitrary code in Safari and Internet Explorer. This impacts all Safari and Internet Explorer users of Prism >=v1.1.0 that use the _Previewers_ plugin (>=v1.10.0) or the _Previewer: Easing_ plugin (v1.1.0 to v1.9.0). ### Patches This problem is patched in v1.21.0. ### Workarounds To workaround the issue without upgrading, [disable the easing preview](https://prismjs.com/plugins/previewers/#disabling-a-previewer) on all impacted code blocks. You need Prism v1.10.0 or newer to apply this workaround. ### References The vulnerability was introduced by this [commit](https://github.com/PrismJS/prism/commit/4303c940d3d3a20e8ce7635bf23331c75060f5c5) on Sep 29, 2015 and fixed by [Masato Kinugawa](https://twitter.com/kinugawamasato) (#2506). ### For more information If you have any questions or comments about this advisory, please [open an issue](https://github.com/PrismJS/prism/issues).

CVE-2020-15138 Affected Prismjs Versions

1 component(s)
Fixed Versions:
1.21.0
Product / Package Ecosystem Affected Versions Fixed Version
prismjs
npm
≥ 1.1.0
< 1.21.0
1.21.0

References

Frequently Asked Questions

What is CVE-2020-15138?
CVE-2020-15138 is a security vulnerability in Prismjs involving Cross-Site Scripting in Prism under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Prismjs versions are affected?
Affected versions include releases prior to 1.21.0 across affected packages: prismjs.
What version fixes CVE-2020-15138?
Upgrading to 1.21.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is prismjs affected?
Yes, prismjs is affected in releases prior to 1.21.0. Upgrade your dependency to 1.21.0 or later.
What is the CVSS score of CVE-2020-15138?
CVE-2020-15138 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2020-15138?
CVE-2020-15138 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2020-15138?
Run the dependency tree command: 'npm ls prismjs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wvhm-4hhf-97x9",
  "modified" : "2021-01-07T23:41:49Z",
  "published" : "2020-08-07T22:28:30Z",
  "aliases" : [ "CVE-2020-15138" ],
  "summary" : "Cross-Site Scripting in Prism",
  "details" : "### Impact\nThe easing preview of the Previewers plugin has an XSS vulnerability that allows attackers to execute arbitrary code in Safari and Internet Explorer.\n\nThis impacts all Safari and Internet Explorer users of Prism >=v1.1.0 that use the _Previewers_ plugin (>=v1.10.0) or the _Previewer: Easing_ plugin (v1.1.0 to v1.9.0).\n\n### Patches\nThis problem is patched in v1.21.0.\n\n### Workarounds\nTo workaround the issue without upgrading, [disable the easing preview](https://prismjs.com/plugins/previewers/#disabling-a-previewer) on all impacted code blocks. You need Prism v1.10.0 or newer to apply this workaround.\n\n### References\nThe vulnerability was introduced by this [commit](https://github.com/PrismJS/prism/commit/4303c940d3d3a20e8ce7635bf23331c75060f5c5) on Sep 29, 2015 and fixed by [Masato Kinugawa](https://twitter.com/kinugawamasato) (#2506).\n\n### For more information\nIf you have any questions or comments about this advisory, please [open an issue](https://github.com/PrismJS/prism/issues).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "prismjs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.1.0"
      }, {
        "fixed" : "1.21.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PrismJS/prism/security/advisories/GHSA-wvhm-4hhf-97x9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-15138"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PrismJS/prism/pull/2506/commits/7bd7de05edf71112a3a77f87901a2409c9c5c20c"
  }, {
    "type" : "WEB",
    "url" : "https://prismjs.com/plugins/previewers/#disabling-a-previewer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-07T16:19:07Z",
    "nvd_published_at" : null
  }
}