DOMPurify IN_PLACE mode XSS via rawtext element text content

Severity: info · Published 2026-10-05

DOMPurify is a widely-used HTML sanitization library that cleans untrusted markup before displaying it in web pages. When the IN_PLACE mode is enabled, DOMPurify can return malicious code within style element text that survives sanitization; if an application then serializes and re-parses this content, the attacker's JavaScript payload executes in the page. This bypasses the library's core security guarantee when using this specific configuration.

Technologies: Cure53 DOMPurify, dompurify (npm). Vendors: Cure53, npm.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Informational severity, published 5 October 2026.
Which products and versions are affected?
Cure53 DOMPurify 3.4.0 through 3.4.15; dompurify (npm) SEMVER:introduced=0,fixed=3.4.16.
Is there a fix for This vulnerability?
Yes. dompurify (npm): upgrade to 3.4.16 or later. Until then: Avoid re-serializing and re-parsing nodes returned from IN_PLACE mode sanitization; instead, append the returned node directly to the DOM without an intermediate round-trip through innerHTML or outerHTML. If re-serialization is unavoidable, re-sanitize the HTML string with IN_PLACE disabled (using RETURN_DOM or RETURN_DOM_FRAGMENT mode) before re-insertion. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run Cure53 DOMPurify or dompurify (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • dompurify (npm): upgrade to 3.4.16 or later
    npm install dompurify@3.4.16

Avoid re-serializing and re-parsing nodes returned from IN_PLACE mode sanitization; instead, append the returned node directly to the DOM without an intermediate round-trip through innerHTML or outerHTML. If re-serialization is unavoidable, re-sanitize the HTML string with IN_PLACE disabled (using RETURN_DOM or RETURN_DOM_FRAGMENT mode) before re-insertion.

Technical details

The vulnerability exists in DOMPurify's handling of rawtext elements (like <style>) when IN_PLACE mode returns a force-removed node. While the library strips dangerous attributes from removed nodes, it fails to sanitize malicious text content embedded in the node itself (e.g., "</style><img src=x onerror=...>"). When this node is serialized and re-parsed in plain HTML context—no foreign-content wrapper needed—the text payload reopens tags and executes as live markup. The issue affects all 3.4.x versions through 3.4.15; it requires the attacker to control a Node passed to IN_PLACE mode and the application to subsequently serialize and reinject the result.

Affected products

  • Cure53 DOMPurify 3.4.0 through 3.4.15

Timeline

  • 2026-09-23: disclosed
  • 2026-10-05: patched: Version 3.4.16 released

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.