Packages

dompurify

3.5.0 · 22 Nov 2026(MPL-2.0 OR Apache-2.0)106.1M / weekRepositorynpmAtom feed

Your version

0.6.7

17 Sep 2015Where it was published

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

20 more

Release note

  • Security Release Please update!

  • Security

    Fixed a possible security issue based on a newly spotted Firefox bug (explanation below)

  • Replaced document.implementation by DOMParser.parseFromString()

  • Changed location of purify.js from / to /src

  • Extended 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.