# CVE-2021-3801: PrismJS regular expression denial of service

Source: https://junglewise.ai/threats/cve-2021-3801-prismjs-regular-expression-denial-of-service  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-09-20. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2021-3801 · Severity: low · CVSS 3.1 · Published 2021-09-20

PrismJS is a popular syntax highlighting library used by web applications and documentation sites. A crafted HTML comment can trigger a ReDoS (regular expression denial of service) attack that causes the application to consume excessive CPU, potentially making the site slow or unresponsive to users.

Technologies: [prismjs (npm)](https://junglewise.ai/threats/technologies/prismjs). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2021-3801 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2021-3801 being exploited in the wild.

**How severe is CVE-2021-3801?** Low severity, with a CVSS score of 3.1, published 20 September 2021.

**Which products and versions are affected?** prismjs (npm) SEMVER:introduced=0,fixed=1.25.0.

**Is there a fix for CVE-2021-3801?** Yes. prismjs (npm): upgrade to 1.25.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2021-3801 attacked?** It is attacked over the network.

**Am I affected by CVE-2021-3801?** Check whether you run prismjs (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- prismjs (npm): upgrade to 1.25.0 or later

  ```sh
  npm install prismjs@1.25.0
  ```


## Technical details

The vulnerability is a regular expression denial of service (ReDoS) in the Markup language component of PrismJS. The vulnerable regex pattern in HTML comment parsing contains catastrophic backtracking that can be triggered by a specially crafted HTML comment input. An attacker who can control HTML input processed by PrismJS (e.g., via user comments, imported content, or markdown processing) can cause the application to hang or consume excessive CPU resources. The fix was patched in version 1.25.0 by correcting the regex pattern to eliminate the backtracking vulnerability.

## Affected products

- PrismJS prismjs before 1.25.0

## Identifiers

- CVE-2021-3801
- GHSA-hqhp-5p83-hx96

## Timeline

- 2021-09-15: disclosed: NVD published
- 2021-09-20: advisory: GitHub Security Advisory published
- 2021-09-16: patched: Fix released in version 1.25.0

## References

- [https://github.com/prismjs/prism/commit/0ff371bb4775a131634f47d0fe85794c547232f9](https://github.com/prismjs/prism/commit/0ff371bb4775a131634f47d0fe85794c547232f9)

## Related threats

- [PrismJS DOM Clobbering vulnerability](https://junglewise.ai/threats/cve-2024-53382-prismjs-dom-clobbering-vulnerability)
- [PrismJS Prism cross-site scripting in Command Line plugin](https://junglewise.ai/threats/cve-2022-23647-prismjs-prism-cross-site-scripting-in-command-line-plugin)
- [PrismJS Prism regular expression denial of service](https://junglewise.ai/threats/cve-2021-32723-prismjs-prism-regular-expression-denial-of-service)
- [PrismJS regular expression denial of service](https://junglewise.ai/threats/cve-2021-23341-prismjs-regular-expression-denial-of-service)
- [PrismJS cross-site scripting in easing preview](https://junglewise.ai/threats/cve-2020-15138-prismjs-cross-site-scripting-in-easing-preview)
