Executive brief
DOMPurify is a popular library used to clean HTML and prevent malicious scripts from running in web applications. A flaw in its 'IN_PLACE' optimization mode allows malicious code to bypass security checks if the content comes from a different window or iframe. If an application uses this specific setting to process content from other frames, an attacker could execute unauthorized scripts (Cross-Site Scripting), potentially leading to data theft or account takeover.
Technical details
A vulnerability exists in DOMPurify's IN_PLACE sanitization mode due to an improper cross-realm check. The private _isNode() function utilizes an 'instanceof Node' check which fails when the provided element originates from a different window or realm (such as an iframe's contentDocument). When this check fails, DOMPurify incorrectly stringifies the element to '[object HTMLDivElement]', resets the IN_PLACE flag to false, and returns the original, unsanitized DOM node to the caller. An attacker can exploit this by providing a malicious element from a cross-window context, which will bypass all sanitization filters. While the vendor initially considered this an edge case, version 3.4.4 was later released to address the issue.
Affected products
- cure53 DOMPurify <= 3.3.3
Timeline
- 2026-04-01: advisory: GHSA-4w3q-35jp-p934 published
- 2026-07-23: disclosed: CVE-2026-65904 published
- 2026-07-23: patched: Version 3.4.4 listed as unaffected/patched in VulnCheck data