{"id":"CVE-2026-75838","aliases":["CVE-2026-75838","GHSA-55q2-fjhq-7xh7"],"related":[],"kind":"vulnerability","state":"published","title":"DOMPurify before 3.4.13 Cross-Site Scripting via IN_PLACE hook","summary":"DOMPurify before 3.4.13 contains a cross-site scripting vulnerability in IN_PLACE sanitization where element-removal hooks fail to neutralize detached subtrees. Attackers can supply HTML with event handlers on descendant elements that execute after sanitization completes, even though the returned root appears clean.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"DOMPurify before 3.4.13 contains a cross-site scripting vulnerability in IN_PLACE sanitization where element-removal hooks fail to neutralize detached subtrees. Attackers can supply HTML with event handlers on descendant elements that execute after sanitization completes, even though the returned root appears clean.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nDuring `IN_PLACE` 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.\n\n### Details\n\nIn 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)`.\n\nThe detached subtree is not added to `DOMPurify.removed`, so the post-walk `IN_PLACE` 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.\n\nThe 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.\n\n### PoC\n\nLoad the published `dompurify@3.4.12` `dist/purify.js` before this script in Chromium:\n\n```html\n<div id=\"result\">not fired</div>\n<script>\nconst root = document.createElement('div');\nroot.innerHTML = `\n  <footer>\n    <img src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n         onload=\"result.textContent = 'XSS after sanitize'\">\n  </footer>\n  <div>safe</div>`;\n\nDOMPurify.setConfig({\n  ALLOWED_TAGS: ['div', '#text', 'footer'],\n  IN_PLACE: true\n});\nDOMPurify.addHook('uponSanitizeElement', node => {\n  if (node.tagName === 'FOOTER') node.remove();\n});\n\nDOMPurify.sanitize(root);\ndocument.body.append(root);\n</script>\n```\n\n`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`.\n\nAs the claim-matched control, use the same detached input with `ALLOWED_TAGS: ['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.\n\n### Impact\n\nIn an application that uses `IN_PLACE` 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.\n\nThe required non-default configuration is `IN_PLACE` 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.\n\n### Suggested fix\n\nReuse 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"DOMPurify antes de la versión 3.4.13 contiene una vulnerabilidad de cross-site scripting en la sanitización IN_PLACE donde los ganchos de eliminación de elementos no logran neutralizar subárboles desprendidos. Los atacantes pueden proporcionar HTML con manejadores de eventos en elementos descendientes que se ejecutan después de que la sanitización se completa, aunque la raíz devuelta parezca limpia.","source":"nvd"}],"published":"2026-08-07T15:30:47.000Z","modified":"2026-10-22T22:10:00.250Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"3.4.13","status":"affected"},{"type":"semver","version":"3.4.13","status":"unaffected"}],"vendor":"cure53","product":"DOMPurify","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.4.13"}],"ecosystem":"npm","package":"dompurify","purl":"pkg:npm/dompurify","source":"ghsa"}],"references":[{"url":"https://github.com/cure53/DOMPurify/security/advisories/GHSA-55q2-fjhq-7xh7","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/dompurify-before-cross-site-scripting-via-in-place-hook","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/cure53/DOMPurify/pull/1557","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/cure53/DOMPurify/commit/3067f7746769","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/cure53/DOMPurify","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/cure53/DOMPurify/releases/tag/3.4.13","tags":["web"],"sources":["ghsa"]}],"credits":["koyokr"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-08-18T13:36:33.246Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-75838","url":"https://www.cve.org/CVERecord?id=CVE-2026-75838","licence":"CVE Terms of Use","modified":"2026-08-18T13:38:34.515Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-55q2-fjhq-7xh7","url":"https://github.com/advisories/GHSA-55q2-fjhq-7xh7","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:13.069Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-75838","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-75838","licence":"Public domain","modified":"2026-10-22T22:10:00.250Z"}],"updatedAt":"2026-11-25T22:59:33.441Z","epss":{"score":0.00394,"percentile":0.35684,"date":"2026-12-01T12:00:22.000Z"}}