Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

DOMPurify: IN_PLACE hook removal leaves a detached subtree executable, causing XSS

0
Medium
Published: 08/07/2026 (08/07/2026, 15:30:47 UTC)
Source: GCVE Database
Product: dompurify

Description

DOMPurify versions prior to 3.4.13 contain a vulnerability in the IN_PLACE sanitization mode where a hook that removes an element can leave detached descendant elements executable. This allows an attacker who can supply HTML to execute JavaScript via retained event handlers on detached subtrees after sanitization completes. The issue arises because the sanitization process skips neutralizing the subtree of a detached node when a hook removes it, leaving event handlers intact on disconnected elements.

CVSS v4.0

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
Low
User Interaction
Passive
Vuln. Confidentiality
None
Vuln. Integrity
None
Vuln. Availability
None
Subsq. Confidentiality
Low
Subsq. Integrity
Low
Subsq. Availability
None
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Affected software

npmghsa
dompurify
Affected versions
<3.4.13

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 08/08/2026, 15:44:13 UTC

Technical Analysis

In DOMPurify 3.4.12, during IN_PLACE sanitization, the _sanitizeElements() function runs hooks such as uponSanitizeElement and returns immediately if the hook detaches the current node. However, it does not call _neutralizeSubtree() on the detached node, leaving any descendant elements with attacker-controlled event handlers executable after sanitize() returns. This detached subtree is not tracked for neutralization, so queued resource events like onload on images can fire, resulting in cross-site scripting (XSS) despite the returned sanitized root being clean and disconnected from the document. The vulnerability requires the non-default IN_PLACE configuration combined with a hook that removes a containing element, but does not add or approve event handlers. A proof-of-concept demonstrates that an image's onload handler fires after sanitization, modifying page content. The suggested fix is to call _neutralizeSubtree() on detached nodes before returning from hook-detachment branches in _sanitizeElements().

Potential Impact

An attacker able to supply HTML to an application using DOMPurify with IN_PLACE mode and an element-removal hook can execute arbitrary JavaScript in the application's origin after sanitization. This results in a cross-site scripting (XSS) vulnerability despite the sanitized output appearing clean. The vulnerability affects only the non-default IN_PLACE configuration combined with hooks that remove elements. There are no known exploits in the wild. The impact is moderate due to the specific configuration required and the need for attacker-controlled HTML input.

Mitigation Recommendations

A patch is available in DOMPurify version 3.4.13 that fixes this issue by ensuring the detached subtree is neutralized before returning from hook-detachment branches. Users should upgrade to version 3.4.13 or later. If upgrading is not immediately possible, avoid using the IN_PLACE configuration with hooks that remove elements until patched. The vendor advisory confirms a fix is available.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-55q2-fjhq-7xh7
Osv Schema Version
1.4.0
Aliases
[]
Ecosystems
["npm"]
Database Specific Severity
MODERATE
Cvss Version
4.0

Threat ID: 6a774343bf8831d539b47b7c

Added to database: 08/08/2026, 14:54:59 UTC

Last enriched: 08/08/2026, 15:44:13 UTC

Last updated: 08/08/2026, 16:02:47 UTC

Views: 5

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses