Skip to content

GHSA-cgfm-xwp7-2cvr CVE-2022-25887

Sanitize-html Vulnerable To REDoS Attacks

High npm
Severity
7.5 / 10
High · CVSS 3.1
Exploit chance (EPSS)
1.55%
Chance of exploitation in the next 30 days. Higher than 75.10% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-1333 Inefficient Regular Expression Complexity
Fix
2.7.1
Upgrade sanitize-html to this version or later

Description

The package sanitize-html before 2.7.1 are vulnerable to Regular Expression Denial of Service (ReDoS) due to insecure global regular expression replacement logic of HTML comment removal.

Affected versions

npm

PackageVulnerableFixed in
sanitize-html
< 2.7.1
2.7.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

sanitize-html npm → 2.7.1

npm
npm install sanitize-html@2.7.1
yarn
yarn add sanitize-html@2.7.1
pnpm
pnpm add sanitize-html@2.7.1

Severity breakdown

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

Weakness

CWE-1333: Inefficient Regular Expression Complexity

The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.

How to prevent it
  • Architecture and Design: Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
  • System Configuration: Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
  • Implementation: Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
  • Implementation: Limit the length of the input that the regular expression will process.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-cv27-6wvh-8x7j
ApostropheCMS: Incomplete CVE-2026-53606: `meta http-equiv=refresh` `content` still ships `javascript:` / `data:` URLs
Medium Also affects sanitize-html
GHSA-374f-7chj-9948
ApostropheCMS sanitize-html: SMIL animation namespace-prefix bypass allows javascript: URI injection (XSS)
Low Also affects sanitize-html
GHSA-x3q4-9hxx-gx8m
ApostropheCMS sanitize-html: nonTextTags discard region ends early on an implied close, letting <noscript> content render
Medium Also affects sanitize-html
GHSA-c9rx-x947-fp3h
ApostropheCMS sanitize-html: unbounded recursion when re-sanitizing the fallback of a discarded iframe (stack overflow, nestingLimit not enforced)
Medium Also affects sanitize-html
GHSA-g8qq-57p8-ggw5
ApostropheCMS: Stored XSS via SVG SMIL URI-list scheme-policy bypass
Medium Also affects sanitize-html
GHSA-jxwj-j7wr-gfrw
ApostropheCMS: Mutation-XSS / allowedTags bypass via literal `</textarea/>` solidus close
Medium Also affects sanitize-html
GHSA-vccv-cmxp-4j9h
sanitize-html has incomplete URI scheme validation in that allows javascript: URIs through action, formaction, data, poster, and background attributes
Medium Also affects sanitize-html
GHSA-rpr9-rxv7-x643
Apostrophe has default XSS via `xmp` raw-text passthrough in `sanitize-html`
Critical Also affects sanitize-html
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor