DOMPurify SAFE_FOR_TEMPLATES bypass: split template expressions survive in attached shadow root content on DOM output
Affects dompurifySource GCVE Database
CVSS 2.3 Low : upgrade to 3.4.17 when convenient.
Data as of 19 Nov 2026, 00:51 UTC
- Patch
- Available – fixed in 3.4.17
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:NWhat to do
Upgrade dompurify to 3.4.17.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| npmdompurify | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
A fix for this vulnerability is available in DOMPurify version 3.4.17. Users should upgrade to this version or later to ensure the post-walk safety net properly handles attached shadow roots. Until upgraded, applications should avoid enabling SAFE_FOR_TEMPLATES with DOM-returning modes on DOM nodes containing attached shadow roots that are later evaluated as templates.
Description
A vulnerability in DOMPurify when configured with SAFE_FOR_TEMPLATES and a DOM-returning mode allows template expressions split across text nodes in attached shadow roots to survive sanitization. This occurs because the post-walk safety net does not recurse into shadow roots, enabling attackers who supply DOM nodes with shadow roots to inject expressions that are later evaluated by template engines. Exploitation requires specific non-default configurations and attacker control over DOM nodes with attached shadow roots. The vulnerability is fixed in version 3.4.17.
References
- github.com/cure53/DOMPurify/security/advisories/GHSA-cg2g-xh64-v4q7 (opens in a new tab)
- github.com/cure53/DOMPurify/pull/1672 (opens in a new tab)
- github.com/cure53/DOMPurify/commit/a77a3e78b59f72fa4d1c83f22e121ad9cc7d3575 (opens in a new tab)
- github.com/cure53/DOMPurify (opens in a new tab)
- github.com/cure53/DOMPurify/releases/tag/3.4.17 (opens in a new tab)