# DOMPurify IN_PLACE mode XSS via rawtext element text content

Source: https://junglewise.ai/threats/dompurify-in-place-returns-a-force-removed-rawtext-root-whose-text-16d9ac9e  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-05. Updated: 2026-10-06  
License: CC BY 4.0 with a link back

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](https://junglewise.ai/threats/technologies/cure53-dompurify), [dompurify (npm)](https://junglewise.ai/threats/technologies/dompurify). Vendors: [Cure53](https://junglewise.ai/threats/vendors/cure53), [npm](https://junglewise.ai/threats/vendors/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

  ```sh
  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 &lt;style&gt;) 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., "&lt;/style&gt;&lt;img src=x onerror=...&gt;"). 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

- [https://github.com/cure53/DOMPurify/security/advisories/GHSA-6688-9rhm-gjv2](https://github.com/cure53/DOMPurify/security/advisories/GHSA-6688-9rhm-gjv2)
- [https://github.com/cure53/DOMPurify/pull/1636](https://github.com/cure53/DOMPurify/pull/1636)

## Related threats

- [DOMPurify SAFE_FOR_TEMPLATES bypass via shadow root content](https://junglewise.ai/threats/cve-2026-116804-dompurify-from-3-4-4-before-3-4-17-contains-a-safe-for-templates)
- [DOMPurify DOM XSS in IN_PLACE hook-detached subtrees](https://junglewise.ai/threats/cve-2026-116803-dompurify-before-3-4-17-contains-a-cross-site-scripting)
- [DOMPurify cross-site scripting in SMIL attributeName guard bypass](https://junglewise.ai/threats/cve-2026-116802-dompurify-before-3-4-17-contains-a-cross-site-scripting)
- [DOMPurify SAFE_FOR_TEMPLATES bypass in shadow root content](https://junglewise.ai/threats/dompurify-safe-for-templates-bypass-split-template-expressions-survive-c23665cf)
- [DOMPurify IN_PLACE event handler bypass when hook removes parent or sibling](https://junglewise.ai/threats/dompurify-in-place-hook-that-removes-a-parent-or-sibling-leaves-the-3ea5d18f)
