dompurify
3.5.0 · 22 Nov 2026(MPL-2.0 OR Apache-2.0)106.1M / weekRepositorynpmAtom feed
Upgrading dompurify From 3.3.3 to 3.5.0
20 releases in betweenevery note read
Before you upgrade
Tick each one off as you go- Breaking3.4.18
- Breaking3.4.7
- Breaking3.4.1
Security
Fixes 17 advisories affecting 3.3.3
- DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluationmoderate · GHSA-39q2-94rc-95cp
- DOMPurify: IN_PLACE hook removal leaves a detached subtree executable, causing XSSmoderate · GHSA-55q2-fjhq-7xh7
- DOMPurify: IN_PLACE returns a force-removed rawtext root whose text carries attacker markup — pure HTML reparse executeslow · GHSA-6688-9rhm-gjv2
- DOMPurify: Hook mutation of `data.allowedTags` / `data.allowedAttributes` permanently pollutes `DEFAULT_ALLOWED_TAGS` / `DEFAULT_ALLOWED_ATTR`moderate · GHSA-76mc-f452-cxcm
- DOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses `afterSanitizeElements` for allowed custom elements.low · GHSA-c2j3-45gr-mqc4
- DOMPurify: SMIL attributeName=href guard is skipped when PARSER_MEDIA_TYPE is application/xhtml+xmllow · GHSA-c6gr-qvv4-5v3f
- DOMPurify: Permanent `ALLOWED_ATTR` pollution via `setConfig()` bypassing the hook clone-guard (incomplete fix of the 3.4.7 hook-pollution patch)moderate · GHSA-cmwh-pvxp-8882
- DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM modemoderate · GHSA-crv5-9vww-q3g8
- DOMPurify: SAFE_FOR_TEMPLATES bypass - template expressions survive sanitization inside <template> content when using DOM output modeslow · GHSA-gvmj-g25r-r7wr
- DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)moderate · GHSA-h7mw-gpvr-xq4m
- DOMPurify: Cross-realm IN_PLACE sanitization leaves executable markup intact via realm-bound `instanceof` checksmoderate · GHSA-hpcv-96wg-7vj8
- 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)low · GHSA-mrv2-3pqr-j5jr
- DOMPurify: IN_PLACE mode preserves attributes of a clobbered root element, allowing XSS via attacker-controlled root DOMmoderate · GHSA-r47g-fvhr-h676
- DOMPurify IN_PLACE Sanitization Bypass via Attached Shadow Root Inside <template>.contentmoderate · GHSA-rp9w-3fw7-7cwq
- DOMPurify: Prototype Pollution to XSS Bypass via CUSTOM_ELEMENT_HANDLING Fallbackmoderate · GHSA-v9jr-rg53-9pgp
- DOMPurify: Trusted Types policy survives `clearConfig()` and can poison later `RETURN_TRUSTED_TYPE` outputlow · GHSA-vxr8-fq34-vvx9
- DOMPurify: `IN_PLACE` mode trusts attacker-controlled `nodeName` on live non-form nodes, allowing script retention and XSS via attacker-supplied DOM objectslow · GHSA-x4vx-rjvf-j5p4
- 3.5.0
This release contains security fixes and a few behavior changes, see below.
- 3.4.3
Fixed the template regexes to be more robust against ReDoS attacks, thanks @aleung27
- 3.4.1
Strengthened the fast-check fuzz harness with explicit XSS invariants, an expanded seed-payload corpus, an additional idempotence property for
SANITIZE_NAMED_PROPS, and a negative-control assertion ensuring the invariants actually fire - 3.4.0
Fixed a prototype pollution via
CUSTOM_ELEMENT_HANDLING, thanks @trace37labs - 3.4.0
Fixed an issue with
USE_PROFILESprototype pollution, thanks @christos-eth
Release by release
- Security
This release contains security fixes and a few behavior changes, see below.
- New
Added in-depth hardening against clobbering for
IN_PLACE - New
Added regression tests for all of the above
- Fixed
Fixed a further
SAFE_FOR_TEMPLATESbypass where nested tags could reassemble expressions on reparse, thanks @e1abrador
- Security
- Breaking
Removed several entries from the SVG tag allow-list that are attributes and not elements, thanks @hackvertor
- New
Added a console warning when
USE_PROFILESis combined withALLOWED_TAGSorALLOWED_ATTR, thanks @rugk - Fixed
Fixed a
SAFE_FOR_TEMPLATESbypass where the final scrub cut through tags and let a template expression form on reparse, thanks @e1abrador - Fixed
Fixed a direct property read in the clobbering check, thanks @trace37labs
- Fixed
Fixed a hook-widened allow-list carrying over when the config object received by a hook was passed back to
sanitize()
- Breaking
- New
Added a purify-edge test runner as a compatibility check, thanks @anzal1
- Fixed
Fixed an issue with
IN_PLACE,SAFE_FOR_TEMPLATESand shadow roots, thanks @manus-pi - Fixed
Fixed
IN_PLACEhandling of nodes that hooks or custom elements tough during sanitization, thanks @uttej-badwane - Fixed
Fixed the SMIL
attributeNameguard in XHTML mode, thanks @Koukyosyumei
- New
- Fixed
Fixed a problem with
IN_PLACEnode removal when working with hooks, thanks @manus-pi - Fixed
Fixed a problem with
IN_PLACEsanitization and raw-text roots, thanks @h-t-m - Fixed
Fixed a problem with ESM default exports landing in CommonJS declarations, thanks @ssi02014
- Fixed
- New
Added better clobbering hardening when XML content is involved, thanks @gnyselcuk
- New
Added several smaller hardening and edge-case improvements, thanks @leechristensen
- New
- New
Added the SVG
pointer-eventsandvector-effectpresentation attributes to the allow-list, thanks @Jaybhade - Fixed
Fixed an issue with possible bypasses when risky tags are allow-listed, thanks @AlirezaRouhbakhsh
- Fixed
Fixed a couple of edge cases with mixed document contexts, thanks @fishjojo1
- New
- Fixed
Fixed an issue with hook removal during
IN_PLACEsanitization, thanks @koyokr - Fixed
Fixed an issue with hooks potentially bypassing the clone guard, thanks @AkshayjainG
- Fixed
Fixed an issue with DOM clobbering via
ownerDocumentduringIN_PLACE, thanks @AkshayjainG
- Fixed
- New
Added support for a few new SVG attributes, thanks @cbn-falias & @Develop-KIM
- Fixed
Fixed an issue where a hook would not get called for custom elements, thanks @Rikuxx0
- New
47 other lines we could not sort, mostly version bumps
- 3.5.0
Reworked the CI setup: one always-on workflow with a single required check, a read-only build job for the SLSA provenance, and a check that the tagged
dist/matches a clean build - 3.5.0
Extended the Sigstore signatures to all four bundles covered by the provenance
- 3.5.0
Updated the README, SECURITY.md and wiki
- 3.5.0
Updated several dependencies
- 3.5.0
SAFE_FOR_TEMPLATESis guaranteed for string input. For DOM node input andIN_PLACEit is best effort, because a tree the HTML parser did not build can change shape when it is parsed again - 3.5.0
A name passing
CUSTOM_ELEMENT_HANDLING.tagNameCheckis only kept in HTML. Inside SVG or MathML it is not a custom element and is now removed - 3.5.0
When a DOM node is passed in, a
textareaortitleholding an element child and a void element holding children are removed. The HTML parser never produces these, so string input is not affected - 3.5.0
A
sanitize()call made from a hook no longer changes how the rest of the outer call behaves. Code that relied on the old side effect needs to pass the config explicitly - 3.5.0
IN_PLACEnow throws when a hook or custom element keeps putting a removed node back, instead of returning the node or running indefinitely - 3.4.18
Refactored the code base: removed dead code and redundant helpers, shortened comments
1 internal line (docs, tests, tooling) left out.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.