npm / dompurify
dompurify
What changed in dompurify 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
dompurify 369 changes
Breaking changes 3
The function form of ADD_TAGS no longer bypasses FORBID_TAGS.
The default forbidden-content list was extended, affecting which content DOMPurify blocks by default.
The ESM import syntax was corrected, so developers may need to update their imports.
Security 48
Fixed the SMIL attributeName guard in XHTML mode.
Hardened smaller edge cases involving isValidAttribute().
Hardened smaller edge cases involving literal-text elements.
Hardened smaller namespace-related edge cases.
Fixed node removal with IN_PLACE when hooks are used.
Fixed IN_PLACE sanitization for raw-text roots.
Added several smaller hardening and edge-case improvements.
Improved clobbering hardening when XML content is involved.
Fixed possible bypasses when risky tags are allow-listed.
Fixed hooks potentially bypassing the clone guard.
Fixed hook removal during IN_PLACE sanitization.
Fixed DOM clobbering through ownerDocument during IN_PLACE sanitization.
Handling of declarative partial updates was hardened.
Hooks are now called for custom elements.
Handling of hooks that remove elements was hardened.
Fixed a leaky configuration issue affecting hooks configured through setConfig.
DOMPurify: Trusted Types policy survives
clearConfig()and can poison laterRETURN_TRUSTED_TYPEoutputDOMPurify: SAFE_FOR_TEMPLATES bypass - template expressions survive sanitization inside <template> content when using DOM output modes
Fixed the node iterator for better template scrubbing.
Removed a problem that could lead to permanent hook pollution.
Hardened Shadow Root handling when using IN_PLACE.
DOMPurify: Cross-realm IN_PLACE sanitization leaves executable markup intact via realm-bound
instanceofchecksDOMPurify: IN_PLACE mode preserves attributes of a clobbered root element, allowing XSS via attacker-controlled root DOM
Fixed several DOM Clobbering issues when using IN_PLACE mode.
Hardened checks for cross-realm IN_PLACE usage and Shadow DOM sanitization.
Fixed a bypass caused by the new HTML element selectedcontent introduced in 3.4.4; upgrade immediately because this is a security release.
Made template regexes more robust against ReDoS attacks.
Fixed URI validation for attributes allowed through the ADD_ATTR callback.
The annotation-xml check now handles mixed-case variants in XHTML mode, preventing bypass of basic custom-element exclusion.
Permissive custom-element handling now correctly strips on-handlers from HTML-spec-reserved custom element names.
The root-node check now guards against non-string nodeName values to improve DOM-clobbering robustness.
ADD_ATTR function configuration no longer leaks into subsequent array-based calls.
ADD_ATTR predicates now perform URI validation instead of skipping it.
ADD_TAGS function configuration no longer leaks into subsequent array-based calls.
An issue involving closing tags that could enable mXSS was fixed.
DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)
DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM mode
DOMPurify: Prototype Pollution to XSS Bypass via CUSTOM_ELEMENT_HANDLING Fallback
DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluation
FORBID_TAGS now takes precedence over ADD_TAGS when both configure allowed and forbidden tags.
An issue that could enable mXSS through Re-Contextualization was fixed.
SAFE_FOR_TEMPLATES scrubbing now also applies when using the RETURN_DOM path.
Fixed a prototype pollution issue when working with custom elements.
DOMPurify ADD_ATTR predicate skips URI validation
DOMPurify contains a Cross-site Scripting vulnerability
DOMPurify is vulnerable to mutation-XSS via Re-Contextualization
DOMPurify USE_PROFILES prototype pollution allows event handlers
Fixed a possible bypass caused by faulty raw-text tag parsing in jsdom.
Performance 1
Improved sanitizer performance by hoisting mXSS probe regexes and testing textContent before innerHTML.
Behavior and default changes 3
Added the SVG pointer-events presentation attribute to the allow-list.
Added the SVG vector-effect presentation attribute to the allow-list.
Support was added for a few new SVG attributes.
Tooling 1
Added a deterministic micro-benchmark harness with a comparison mode for evaluating performance changes.
Fixes and other changes 13
Fixed IN_PLACE handling of nodes that hooks or custom elements tough during sanitization.
Fixed an issue involving IN_PLACE, SAFE_FOR_TEMPLATES and shadow roots during sanitization.
Fixed ESM default exports appearing in CommonJS declarations.
Fixed edge cases involving mixed document contexts.
Handling of IN_PLACE sanitization was further improved.
Handling of Trusted Types config options was further improved.
Fixed an issue with handling of Trusted Types policies.
Improved handling of nested Shadow DOM trees and related iteration issues.
Fixed source maps that referred to non-existing files.
Repeated sanitization no longer repeatedly prefixes already-prefixed id and name values.
Several minor MathML attribute handling problems and typos were fixed.
Fixed a Node 20 engine requirement that caused hiccups.
Fixed lenient config parsing in _isValidAttribute.