All vulnerabilities

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…

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Affected software

SoftwareAffected versions
dompurifynpm · osv:npm:dompurify
  • From 3.4.4 before 3.4.17

About dompurify

Weekly downloads (npm)
100,045,636npm, 15 Nov 2026

References