CVE-2026-49978: DOMPurify IN_PLACE Sanitization Bypass via Attached Shadow Root Inside <template>.content
DOMPurify is a DOM-only cross-site scripting sanitizer for HTML, MathML, and SVG. Prior to 3.4.7, DOMPurify INPLACE sanitization could skip shadow contents attached to an element inside <template>.content, allowing attacker-controlled markup such as event handlers, JavaScript URLs, or scripts to survive and execute when an application cloned and inserted the sanitized template. This issue is fixed in version 3.4.7.
Other sources
If the HTML you give it contains a <template> element, and inside that template there's an element with a shadow DOM attached to it, DOMPurify quietly skips over the shadow contents. Whatever the attacker put in there - an image with an onerror handler, a link with a javascript: URL, even a full script - survives untouched. The moment the application uses that template the way templates are meant to be used (cloning it and inserting the result into the page), the malicious payload comes along and runs as if it had never been sanitized. From there an attacker gets everything XSS normally gets them: session cookies, stored tokens, the ability to act as the user, and the ability to leave persistent payloads behind for the next person who visits.
advisory.pdf
poc.html
— GitHub
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2026-49978?
CVE-2026-49978 has a severity rating of 71.
What type of vulnerability is CVE-2026-49978?
CVE-2026-49978 is classified as a Cross-Site Scripting (XSS) vulnerability.
How does CVE-2026-49978 occur?
CVE-2026-49978 occurs when HTML containing a <template> element with a shadow DOM is processed by DOMPurify.
What are the potential exploits of CVE-2026-49978?
Exploits of CVE-2026-49978 may include injecting scripts through images with onerror handlers or malicious links.
How do I fix CVE-2026-49978?
To fix CVE-2026-49978, ensure that shadow DOM contents are properly sanitized by updating to a patched version of DOMPurify.