CVE-2021-23341: Denial of service in prismjs
Summary
CVE-2021-23341: Denial of service in prismjs. Affects prismjs versions < 1.23.0. Fixed in 1.23.0. How to fix ↓
Also tracked for
- node-prismjs · Debian:11
The same CVE-2021-23341 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Prismjs is an open-source syntax highlighter that is widely used for code syntax highlighting on websites. It provides a lightweight and extensible solution for highlighting code in various programming languages. However, versions of Prismjs prior to 1.23.0 are vulnerable to a Regular Expression Denial of Service (ReDoS) attack. This vulnerability affects the prism-asciidoc, prism-rest, prism-tap, and prism-eiffel components.
Vulnerability Detail
The vulnerability arises due to insufficient input validation in the affected components. An attacker can exploit this vulnerability by providing specially crafted input that triggers a ReDoS attack. This can lead to a denial of service condition, where the affected application becomes unresponsive or crashes. ReDoS attacks are particularly dangerous as they can consume excessive CPU resources and cause significant performance degradation.
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.23.0
This is the first release that contains the fix.
npm install prismjs@1.23.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to apply the recommended fix by upgrading to the latest version of Prismjs.
Conclusion
The vulnerability in Prismjs versions prior to 1.23.0 can be exploited to cause a denial of service condition. It is crucial for developers to upgrade to the latest version of Prismjs and ensure that all dependencies are up to date. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for prismjs →
FAQ
Prismjs is an open-source syntax highlighter used for code syntax highlighting on websites.
A ReDoS (Regular Expression Denial of Service) attack is a type of vulnerability where a maliciously crafted input can cause a regular expression matching algorithm to exhibit exponential time complexity, leading to a denial of service condition.
The affected components in Prismjs are prism-asciidoc, prism-rest, prism-tap, and prism-eiffel.
The vulnerability can result in a denial of service condition, where the affected application becomes unresponsive or crashes. This can impact the availability and performance of the application.
To mitigate this vulnerability, it is recommended to upgrade to Prismjs version 1.23.0 or later. This version includes the necessary fixes to address the ReDoS vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for prismjs.