CVE-2022-23647: Prismjs Cross-Site Scripting Vulnerability
HIGHCVE-2022-23647 is a HIGH (CVSS 7.5) 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.27.0.
CVE-2022-23647 at a Glance
Security Impact
CVSS: 7.5
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:C/C:H/I:L/A:L).
How to Fix CVE-2022-23647
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.
npm install prismjs@1.27.0
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-2022-23647, 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.27.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
CVE-2022-23647 Affected Prismjs Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
prismjs
|
npm |
≥ 1.14.0
< 1.27.0
|
1.27.0
|
References
Frequently Asked Questions
What is CVE-2022-23647?
Which Prismjs versions are affected?
What version fixes CVE-2022-23647?
Is prismjs affected?
What is the CVSS score of CVE-2022-23647?
What CWE is associated with CVE-2022-23647?
How can I check npm dependencies for CVE-2022-23647?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3949-f494-cm99",
"modified" : "2022-02-22T19:32:18Z",
"published" : "2022-02-22T19:32:18Z",
"aliases" : [ "CVE-2022-23647" ],
"summary" : "Cross-site Scripting in Prism",
"details" : "### Impact\nPrism's [Command line plugin](https://prismjs.com/plugins/command-line/) can be used by attackers to achieve an XSS attack. The Command line plugin did not properly escape its output, leading to the input text being inserted into the DOM as HTML code.\n\nServer-side usage of Prism is not impacted. Websites that do not use the Command Line plugin are also not impacted.\n\n### Patches\nThis bug has been fixed in v1.27.0.\n\n### Workarounds\nDo not use the Command line plugin on untrusted inputs, or sanitized all code blocks (remove all HTML code text) from all code blocks that use the Command line plugin.\n\n### References\n- https://github.com/PrismJS/prism/pull/3341",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "prismjs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.14.0"
}, {
"fixed" : "1.27.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/PrismJS/prism/security/advisories/GHSA-3949-f494-cm99"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23647"
}, {
"type" : "WEB",
"url" : "https://github.com/PrismJS/prism/pull/3341"
}, {
"type" : "WEB",
"url" : "https://github.com/PrismJS/prism/commit/e002e78c343154e1c0ddf9d6a0bb85689e1a5c7c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PrismJS/prism"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-02-22T19:32:18Z",
"nvd_published_at" : "2022-02-18T15:15:00Z"
}
}