CVE-2026-41239: DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM mode

CVE-2026-41239 · Severity: medium · CVSS 6.8 · Published 2026-04-23

DOMPurify is a widely-used HTML sanitizer that removes potentially malicious code from user-supplied content. When configured with SAFE_FOR_TEMPLATES and RETURN_DOM modes, it fails to strip template expressions (like {{...}}) from certain HTML structures, allowing attackers to inject XSS code that executes in template-evaluating frameworks like Vue 2. This can lead to arbitrary JavaScript execution and compromise of user sessions or data.

Technologies: dompurify (npm). Vendors: npm.

Quick answers

Is CVE-2026-41239 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-41239 being exploited in the wild.
How severe is CVE-2026-41239?
Medium severity, with a CVSS score of 6.8, published 23 April 2026.
Which products and versions are affected?
dompurify (npm) >= 1.0.10, < 3.4.0, SEMVER:introduced=1.0.10,fixed=3.4.0.
Is there a fix for CVE-2026-41239?
Yes. dompurify (npm): upgrade to 3.4.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-41239 attacked?
It is attacked over the network.
Am I affected by CVE-2026-41239?
Check whether you run 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.0 or later
    npm install dompurify@3.4.0

Technical details

DOMPurify has a two-pass sanitization strategy: per-node filtering during DOM traversal and a final string scrub after serialization. However, in RETURN_DOM and RETURN_DOM_FRAGMENT modes, the function returns early before the second pass runs. An attacker can exploit this by splitting template expression delimiters across multiple text nodes (e.g., { &lt;disallowed-tag&gt; } {payload} &lt;/disallowed-tag&gt; }) so that no single node contains the complete {{ pattern; the per-node pass misses it. When DOMPurify removes the disallowed tags, adjacent text nodes merge, reconstituting the template expression. The resulting DOM is then mounted into a framework like Vue 2 which compiles and executes the injected code. The fix normalizes text nodes before returning in RETURN_DOM mode, ensuring the final string scrub catches reconstructed expressions.

Affected products

  • Cure53 DOMPurify <3.4.0

Identifiers

  • CVE-2026-41239
  • GHSA-crv5-9vww-q3g8

Timeline

  • 2026-04-22: disclosed
  • 2026-04-20: patched: Patched in version 3.4.0

References

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