GHSA-55q2-fjhq-7xh7: XSS

Published Aug 7, 2026
·
Updated

Summary

During INPLACE sanitization, a hook that removes an element can leave that element's detached descendants executable. A descendant image can retain its attacker-provided onload handler and fire after sanitize() returns, even though the returned root is clean and the image remains disconnected from the document.

Details

In DOMPurify 3.4.12, sanitizeElements() in src/purify.ts:1862-1904 runs the beforeSanitizeElements or uponSanitizeElement hook and returns immediately when the hook detached the current node. The return does not call neutralizeSubtree(currentNode).

The detached subtree is not added to DOMPurify.removed, so the post-walk INPLACE neutralization cannot reach it. If the browser queued a resource event while the application constructed the detached dirty root, a descendant can therefore retain its handler and execute after sanitization.

The hook only rejects the containing element and does not add or approve the event handler. DOMPurify's ordinary removal path de-arms the same queued event; only the hook-detachment early return skips the existing subtree neutralization.

PoC

Load the published dompurify@3.4.12 dist/purify.js before this script in Chromium:

html <div id="result">not fired</div> <script> const root = document.createElement('div'); root.innerHTML = <footer> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onload="result.textContent = 'XSS after sanitize'"> </footer> <div>safe</div>;

DOMPurify.setConfig({ ALLOWEDTAGS: ['div', '#text', 'footer'], INPLACE: true }); DOMPurify.addHook('uponSanitizeElement', node => { if (node.tagName === 'FOOTER') node.remove(); });

DOMPurify.sanitize(root); document.body.append(root); </script>

sanitize() returns with no handler execution and the returned root contains only the safe div. After the event loop advances, the original image remains disconnected but its retained onload changes the page to XSS after sanitize.

As the claim-matched control, use the same detached input with ALLOWEDTAGS: ['div', '#text'] and no hook. DOMPurify's ordinary removal path removes the original image's handler, the returned root is still <div>safe</div>, and the marker does not fire.

Impact

In an application that uses INPLACE with the documented element-removal hook pattern, an attacker who can supply HTML can execute JavaScript in the integrating application's origin after the application sanitizes and renders that content.

The required non-default configuration is INPLACE plus a hook that removes a containing element. The hook does not add or approve the event handler, and the dirty root never needs to be connected before sanitization.

Suggested fix

Reuse the existing neutralizeSubtree(currentNode) helper before returning from both hook-detachment branches in sanitizeElements(). Add regressions for beforeSanitizeElements and uponSanitizeElement that retain a reference to a descendant resource element and verify that its event handler is removed after the hook detaches its ancestor.

Affected Software

1 affected componentFixes available
npm/dompurify<=3.4.12
3.4.13

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/dompurify to a version that resolves this vulnerability.

    Fixed in 3.4.13

Event History

Aug 7, 2026
Advisory Published
via GitHub·03:30 PM
Data Sourced
via GitHub·03:30 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of GHSA-55q2-fjhq-7xh7?

The severity of GHSA-55q2-fjhq-7xh7 is rated at 58.

2

What vulnerability does GHSA-55q2-fjhq-7xh7 address?

GHSA-55q2-fjhq-7xh7 addresses a Cross-Site Scripting (XSS) vulnerability in the DOMPurify library.

3

How do I fix GHSA-55q2-fjhq-7xh7?

To fix GHSA-55q2-fjhq-7xh7, ensure you update the DOMPurify library to the latest version that addresses this issue.

4

Which software is affected by GHSA-55q2-fjhq-7xh7?

The software affected by GHSA-55q2-fjhq-7xh7 is the DOMPurify library for Node.js.

5

What could happen if GHSA-55q2-fjhq-7xh7 is not resolved?

If GHSA-55q2-fjhq-7xh7 is not resolved, it could allow attackers to execute arbitrary scripts through detached elements in sanitized HTML.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203