dompurify
3.5.0 · 22 Nov 2026(MPL-2.0 OR Apache-2.0)106.1M / weekRepositorynpmAtom feed
0.9.0 is the newest release of 0.6.x.
In short
2 security4 changed
- Security
Fixed a possible security issue based on a newly spotted Firefox bug (explanation below)
- Security
The security issue is caused by a non-standard behavior of Gecko (the Firefox browser-engine) and a peculiar way of working with
innerHTML-assignments.
Security
25 advisories affect 0.6.7; 3.4.17 fixes them
- CriticalDOMPurify vulnerable to tampering by prototype polutionGHSA-p3vf-v8qc-cwcr · 31 Oct 2024Fixed in 2.4.2
- CriticalCross-Site Scripting in dompurifyGHSA-mjjq-c88q-qhr6 · 3 Sep 2020Fixed in 2.0.7
- HighDOMpurify has a nesting-based mXSSGHSA-gx9m-whjm-85jf · 11 Oct 2024Fixed in 2.5.0
- HighDOMPurify allows tampering by prototype pollutionGHSA-mmhx-hmjr-r674 · 16 Sep 2024Fixed in 2.5.4
- ModerateDOMPurify: IN_PLACE hook removal leaves a detached subtree executable, causing XSSGHSA-55q2-fjhq-7xh7 · 7 Aug 2026Fixed in 3.4.13
20 more
- ModerateDOMPurify: Permanent `ALLOWED_ATTR` pollution via `setConfig()` bypassing the hook clone-guard (incomplete fix of the 3.4.7 hook-pollution patch)GHSA-cmwh-pvxp-8882 · 18 Jun 2026Fixed in 3.4.11
- ModerateDOMPurify IN_PLACE Sanitization Bypass via Attached Shadow Root Inside <template>.contentGHSA-rp9w-3fw7-7cwq · 15 Jun 2026Fixed in 3.4.7
- ModerateDOMPurify: Hook mutation of `data.allowedTags` / `data.allowedAttributes` permanently pollutes `DEFAULT_ALLOWED_TAGS` / `DEFAULT_ALLOWED_ATTR`GHSA-76mc-f452-cxcm · 15 Jun 2026Fixed in 3.4.7
- ModerateDOMPurify: Cross-realm IN_PLACE sanitization leaves executable markup intact via realm-bound `instanceof` checksGHSA-hpcv-96wg-7vj8 · 15 Jun 2026Fixed in 3.4.6
- ModerateDOMPurify: IN_PLACE mode preserves attributes of a clobbered root element, allowing XSS via attacker-controlled root DOMGHSA-r47g-fvhr-h676 · 15 Jun 2026Fixed in 3.4.6
- ModerateDOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)GHSA-h7mw-gpvr-xq4m · 22 Apr 2026Fixed in 3.4.0
- ModerateDOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluationGHSA-39q2-94rc-95cp · 16 Apr 2026Fixed in 3.4.0
- ModerateDOMPurify ADD_ATTR predicate skips URI validationGHSA-cjmm-f4jc-qw8r · 3 Apr 2026Fixed in 3.3.2
- ModerateDOMPurify USE_PROFILES prototype pollution allows event handlersGHSA-cj63-jhhr-wcxv · 3 Apr 2026Fixed in 3.3.2
- ModerateDOMPurify is vulnerable to mutation-XSS via Re-Contextualization GHSA-h8r8-wccr-v5f2 · 27 Mar 2026Fixed in 3.3.2
- ModerateDOMPurify allows Cross-site Scripting (XSS)GHSA-vhxf-7vqr-mrjg · 14 Feb 2025Fixed in 3.2.4
- ModerateDOMPurify Open Redirect vulnerabilityGHSA-8hgg-xxm5-3873 · 14 Nov 2023Fixed in 1.0.11
- ModerateCross-site Scripting in dompurifyGHSA-63q7-h895-m982 · 18 Dec 2020Fixed in 2.0.17
- ModerateCross-Site Scripting in dompurifyGHSA-chqj-j4fh-rw7m · 28 Aug 2020Fixed in 2.0.3
- LowDOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)GHSA-mrv2-3pqr-j5jr · 22 Oct 2026Fixed in 3.4.17
- LowDOMPurify: SMIL attributeName=href guard is skipped when PARSER_MEDIA_TYPE is application/xhtml+xmlGHSA-c6gr-qvv4-5v3f · 22 Oct 2026Fixed in 3.4.17
- LowDOMPurify: IN_PLACE returns a force-removed rawtext root whose text carries attacker markup — pure HTML reparse executesGHSA-6688-9rhm-gjv2 · 5 Oct 2026Fixed in 3.4.16
- LowDOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses `afterSanitizeElements` for allowed custom elements.GHSA-c2j3-45gr-mqc4 · 21 Jul 2026Fixed in 3.4.12
- LowDOMPurify: Trusted Types policy survives `clearConfig()` and can poison later `RETURN_TRUSTED_TYPE` outputGHSA-vxr8-fq34-vvx9 · 15 Jun 2026Fixed in 3.4.9
- LowDOMPurify: `IN_PLACE` mode trusts attacker-controlled `nodeName` on live non-form nodes, allowing script retention and XSS via attacker-supplied DOM objectsGHSA-x4vx-rjvf-j5p4 · 15 Jun 2026Fixed in 3.4.7
Release note
Security Release Please update!
- Security
Fixed a possible security issue based on a newly spotted Firefox bug (explanation below)
Replaced
document.implementationbyDOMParser.parseFromString()Changed location of
purify.jsfrom/to/srcExtended the range of tested browsers on BrowserStack
Details about the Security Issue
Problem:
bugzilla.mozilla.org/show_bug.cgi
Attack Scenario:
The bug only manifested itself if the sanitized HTML DOMPurify created would be written to a document using document.write() or alike. Applications, that set the sanitized HTML by using innerHTML or outerHTML are not affected at all. Applications that do not allow SVG are also not affected at all.
The security issue is caused by a non-standard behavior of Gecko (the Firefox browser-engine) and a peculiar way of working with innerHTML-assignments. The following code snippets illustrate the issue:
<script>
// This is SAFE (but shouldn't be!)
document.body.innerHTML='<svg><p><style><img src="</style><img src=x onerror=alert(1)//">'
</script>
<script>
// This is UNSAFE
document.write('<svg><p><style><img src="</style><img src=x onerror=alert(1)//">')
</script>Users who install this latest release are not affected by the bug anymore as DOMPurify fixes around the problem and mitigates the issue by not trusting Gecko's innerHTML implementation any much longer. Instead of the combination of document.implementation and doc.body.outerHTML, DOMPurify is now using the DOMParser feature available in all modern browsers.
This change is expected to be non-breaking, no API changes or other side-effects are expected.
Thanks @mozfreddyb for assisting with this fix.
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.