npm
CVE-2026-116804
DOMPurify SAFE_FOR_TEMPLATES bypass: split template expressions survive in attached shadow root content on DOM output modes
- Severity
- Critical
- Published
- 22 Oct 2026
- Last changed
- 27 Oct 2026
- Added to UpHeron
- 23 Oct 2026
- Fixed in
- 3.4.17
- Exploit chance
- 0.2% in the next 30 daysHigher than 7% of CVEs. EPSS by FIRST, 19 Nov 2026
- Weakness
- Cross-site scripting (CWE-79)
- Also known as
- GHSA-cg2g-xh64-v4q7
- Sources
- OSV.dev and GitHub
Description
When DOMPurify is configured with SAFE_FOR_TEMPLATES: true together with a DOM-returning mode (RETURN_DOM: true, RETURN_DOM_FRAGMENT: true, or IN_PLACE: true), template expressions such as {{...}}, ${...}, and <%...%> survive sanitization inside the text content of an attached shadow root. The post-walk safety net _scrubTemplateExpressions (src/purify.ts:1717) was extended to recurse into .content, but it never recurses into attached shadow roots. An attacker who can supply a DOM node carrying a shadow root (the IN_PLACE and shadow-aware RETURN_DOM surfaces) can split an expression across text nodes separated by disallowed elements; after those elements are removed the fragments become adjacent and serialize into a complete expression that a downstream template engine will evaluate.
SAFE_FOR_TEMPLATES neutralizes template expressions through two mechanisms: a per-text-node strip during the main walk (_stripTemplateExpressions, applied in _sanitizeElements at src/purify.ts:2246), and…
Affected software
| Software | Affected versions |
|---|---|
dompurifynpm · osv:npm:dompurify |
|
About dompurify
- Weekly downloads (npm)
- 100,045,636npm, 15 Nov 2026
Vulnerabilities in dompurify
- In our list
- 3
- Published in the last 12 months
- 3
- Critical, last 12 months
- 1
- High, last 12 months
- 1
- Known exploited
- 0
- CVE-2026-116803DOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)High 22 Oct 2026
- CVE-2026-116802DOMPurify: SMIL attributeName=href guard is skipped when PARSER_MEDIA_TYPE is application/xhtml+xmlLow 22 Oct 2026
References
- CVE.org https://www.cve.org/CVERecord?id=CVE-2026-116804
- GitHub Advisory Database https://github.com/advisories/GHSA-cg2g-xh64-v4q7