Skip to content

Upgrading dompurify 2 to 3

Breaking2.5.9 → 3.4.17Breaking1Security70Platform1Deprecated1New18Changed18Fixed51Other43

Fetching 50 releases from GitHub…40 / 50
BreakingUpgrade verdict

1 breaking change and a platform requirement change and 69 security fixes.

  • Content inside SVG foreignObject elements is no longer treated as an allowed HTML entry point, so it may be sanitized away.
  • Testing now covers Node 23.x instead of Node 17.x.
  • DOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)
  • DOMPurify SAFE_FOR_TEMPLATES bypass: split template expressions survive in attached shadow root content on DOM output modes
Top 5 of 72 that need code or config changes

Adds @types/trusted-types ^2.0.7.

Installs 1 package in all (was 0).

Breaking1
Removes the foreignObject element from the list of HTML entry-points.
foreignObject
Security69
DOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)
High
DOMPurify SAFE_FOR_TEMPLATES bypass: split template expressions survive in attached shadow root content on DOM output modes
Critical
DOMPurify: SMIL attributeName=href guard is skipped when PARSER_MEDIA_TYPE is application/xhtml+xml
Low
DOMPurify: IN_PLACE: node-removing afterSanitize hook leaves detached subtree event handlers armed, causing DOM XSS
Low
DOMPurify: IN_PLACE returns a force-removed rawtext root whose text carries attacker markup — pure HTML reparse executes
Low
Adds better clobbering hardening when XML content is involved.
Adds several smaller hardening and edge-case improvements.
Fixes possible bypasses when risky tags are allow-listed.
Fixes hooks potentially bypassing the clone guard.
Fixes DOM clobbering via ownerDocument during IN_PLACE sanitization.
ownerDocumentIN_PLACE
DOMPurify: IN_PLACE hook removal leaves a detached subtree executable, causing XSS
Moderate
Hardens the handling of hooks removing elements.
Hardens the handling of declarative partial updates.
DOMPurify: CUSTOM_ELEMENT_HANDLING bypasses afterSanitizeElements for allowed custom elements.
Low
DOMPurify: Permanent ALLOWED_ATTR pollution via setConfig() bypassing the hook clone-guard (incomplete fix of the 3.4.7 hook-pollution patch)
Moderate
DOMPurify: Trusted Types policy survives clearConfig() and can poison later RETURN_TRUSTED_TYPE output
Low
DOMPurify: SAFE_FOR_TEMPLATES bypass - template expressions survive sanitization inside <template> content when using DOM output modes
Low
Hardens handling of Shadow Roots when using IN_PLACE.
IN_PLACE
DOMPurify: Hook mutation of data.allowedTags / data.allowedAttributes permanently pollutes DEFAULT_ALLOWED_TAGS / DEFAULT_ALLOWED_ATTR
Moderate · CVSS 6.1
DOMPurify IN_PLACE Sanitization Bypass via Attached Shadow Root Inside <template>.content
Moderate
Hardens checks for cross-realm IN_PLACE and Shadow DOM sanitization.
IN_PLACE
DOMPurify: Cross-realm IN_PLACE sanitization leaves executable markup intact via realm-bound instanceof checks
Moderate · CVSS 6.1
DOMPurify: IN_PLACE mode preserves attributes of a clobbered root element, allowing XSS via attacker-controlled root DOM
Moderate · CVSS 6.1
Fixes a bypass caused by the new HTML element selectedcontent added in 3.4.4.
selectedcontent
Security release for an issue introduced in 3.4.4; users should upgrade immediately.
DOMPurify XSS via selectedcontent re-clone
High · CVSS 8.2
Adds stronger checks for cross-realm windows.
Fixes the template regexes to be more robust against ReDoS attacks.
DOMPurify: Prototype Pollution to XSS Bypass via CUSTOM_ELEMENT_HANDLING Fallback
CUSTOM_ELEMENT_HANDLINGModerate · CVSS 6.9
Fixes ADD_TAGS function form bypassing FORBID_TAGS.
ADD_TAGSFORBID_TAGS
Fixes ADD_ATTR predicates skipping URI validation.
ADD_ATTR
Fixes prototype pollution via USE_PROFILES.
USE_PROFILES
Fixes a possible mXSS issue via Re-Contextualization.
Fixes an issue with closing tags leading to possible mXSS.
DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM mode
Moderate · CVSS 6.8
DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)
Moderate
DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluation
Moderate
Fixes a possible sanitizer bypass caused by jsdom's faulty raw-text tag parsing.
Fixes a prototype pollution issue when working with custom elements.
Fixes lenient config parsing in _isValidAttribute.
_isValidAttribute
DOMPurify USE_PROFILES prototype pollution allows event handlers
Moderate
DOMPurify contains a Cross-site Scripting vulnerability
Moderate · CVSS 6.1
DOMPurify ADD_ATTR predicate skips URI validation
Moderate
DOMPurify is vulnerable to mutation-XSS via Re-Contextualization
Moderate
Improves handling of potentially risky content inside CDATA elements.
CDATA
Improves the regular expression for raw-text elements to cover textareas.
textarea
DOMPurify contains a Cross-site Scripting vulnerability
Moderate · CVSS 6.1
Adds better config hardening against prototype pollution.
Removes the script that caused the fake CVE-2025-48050 entry.
Adds a stricter check to the mXSS detection regex.
Fixes a conditional and config dependent mXSS-style bypass reported by @nsysean.
DOMPurify allows Cross-site Scripting (XSS)
Moderate · CVSS 4.5
Fixes two conditional sanitizer bypasses discovered by @parrot409 and @Slonser.
Updates the attribute clobbering checks to prevent future bypasses, thanks @parrot409.
Fixes a possible bypass when a rather specific custom elements config is set.
Fixes an issue with comment detection and possible bypasses under specific config settings.
Fixes an issue with the execution logic of attribute hooks to prevent bypasses.
Fixes several mXSS variations found by @kevin-mizu and @Ry0taK.
Adds better hardening against Prototype Pollution attacks, thanks @kevin-mizu.
DOMPurify allows tampering by prototype pollution
High · CVSS 7.0
DOMpurify has a nesting-based mXSS
High · CVSS 10.0
Fixes a mutation XSS (mXSS) variation found by @kevin-mizu.
Fixes a mutation XSS (mXSS) variation found by Adam Kues of Assetnote.
Fixes an mXSS sanitiser bypass reported by @icesfont.
Adds code to track element nesting depth.
Enforces a maximum element nesting depth of 255.
Adds coverage tests and necessary clobbering protections.
Fixes another conditional bypass caused by Processing Instructions.
Fixes two possible bypasses when sanitizing an XML document and later using it in HTML.
Platform1
Adds Node 23.x to tested runtimes and removes Node 17.x.
Deprecated1
Flags this release as deprecated and directs users to DOMPurify 3.4.5 instead.