--- title: "Shadow DOM" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/xss-cross-site-scripting/shadow-dom.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/xss-cross-site-scripting/shadow-dom.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Shadow DOM Shadow DOM encapsulates DOM and CSS implementation details, but **it is not a security boundary** for script already executing in the same origin/realm. It creates useful assessment surfaces when applications mix **closed roots**, **Declarative Shadow DOM (DSD)**, and HTML parsing/sanitizing APIs.[[3]](#references) ## Why attackers care - `mode: "closed"` only hides the root from `element.shadowRoot`; code running in the same JS realm can still intercept its creation.[[1]](#references) - DSD allows HTML such as `` to create real shadow roots during parsing. - Newer sinks such as `Element.setHTMLUnsafe()` and `ShadowRoot.setHTMLUnsafe()` can materialize DSD from attacker-controlled HTML. - Some sanitizers still treat `