CVE-2022-23647: Cross-site Scripting in Prism

prismjs Updated 02 Oct 2025

Summary

22/02/2022
Yes i
High
7.5

CVE-2022-23647: Cross-site Scripting in Prism. Affects prismjs versions >= 1.14.0, < 1.27.0. Fixed in 1.27.0. How to fix ↓

Also tracked for

The same CVE-2022-23647 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Prism is an open-source syntax highlighter that allows developers to add code highlighting to their websites. It provides a Command Line plugin that enables the execution of commands within code blocks. However, this plugin was vulnerable to a Cross-site Scripting (XSS) attack. The plugin did not properly escape its output, allowing attackers to inject malicious code into the DOM. It is important to note that server-side usage of Prism is not affected, and websites that do not use the Command Line plugin are also not impacted.

Vulnerability Detail

The vulnerability in Prism's Command Line plugin allowed attackers to execute XSS attacks. By exploiting this vulnerability, an attacker could inject arbitrary HTML or JavaScript code into the affected website, potentially leading to unauthorized access, data theft, or other malicious activities. The lack of proper output escaping in the plugin allowed the attacker's input text to be inserted into the DOM as HTML code, making it executable by the browser.

How To Fix

Latest published version: 1.30.0 as of 23 Oct 2026

npm install prismjs@1.30.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.27.0

This is the first release that contains the fix.

npm install prismjs@1.27.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating Prism is not immediately feasible, a workaround is to avoid using the Command Line plugin on untrusted inputs. Additionally, all code blocks that use the Command Line plugin should be sanitized to remove any HTML code text. This can be achieved by stripping out any HTML tags or using a library or function specifically designed for HTML sanitization.

Conclusion

In conclusion, the Cross-site Scripting vulnerability in Prism's Command Line plugin could allow attackers to execute malicious code on affected websites. It is crucial to update Prism to version 1.27.0 or later to mitigate this vulnerability. If immediate updating is not possible, developers should follow the recommended workarounds and sanitize code blocks using the Command Line plugin. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for prismjs →

Share this vulnerability

FAQ

Prism versions 1.14.0 to 1.26.0 are affected by this vulnerability. Updating to version 1.27.0 or later is recommended.

No, server-side usage of Prism is not impacted by this vulnerability. Only websites that use the Command Line plugin are affected.

There are no known instances of this vulnerability being actively exploited in the wild. However, it is important to promptly update Prism to mitigate the risk of potential attacks.

Yes, the CVSS score for this vulnerability is 7.5, indicating a high severity level.

Yes, you can refer to the GitHub pull request (https://github.com/PrismJS/prism/pull/3341) for more details on the fix implemented in version 1.27.0.

Related vulnerabilities

Recent vulnerabilities recorded for prismjs.

How To Fix

Latest published version: 1.30.0 as of 23 Oct 2026

npm install prismjs@1.30.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.27.0

This is the first release that contains the fix.

npm install prismjs@1.27.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback