- Severity: HIGH
- CVE: CVE-2026-144292
- Ecosystems: npm
- Packages: dompurify
### Summary
With `SAFE_FOR_TEMPLATES: true`, DOMPurify 3.4.18 returns a string that contains no `{{` or `}}`, yet becomes a live `{{…}}` expression as soon as it is assigned to `innerHTML`. A template engine that compiles that DOM (verified with Vue 3 in-DOM templates and AngularJS 1.8.3) evaluates the attacker’s expression, giving arbitrary JavaScript execution.
The attacker controls only the markup passed to `sanitize()`. The only configuration required is `SAFE_FOR_TEMPLATES: true`, which is a protective option used for its documented purpose.
Reproduced on DOMPurify 3.4.18 (npm `latest`) in Chromium 156, Firefox 157 and WebKit 27.2. The plain `{{…}}` case is still scrubbed correctly, so this is a gap in the existing protection.
### Details
SAFE_FOR_TEMPLATES is enforced in two places in `src/purify.ts`, and neither accounts for how the returned string is parsed a second time by the consumer.
1. Per text node, during the walk (around line 2122):
“`ts
/* Sanitize element content to be template-safe */
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
const content = _stripTemplateExpressions(currentNode.textContent);
…
“`
2. After serialization, a tree scrub that only runs when the serialized output contains a marker (around line 2872):
“`ts
if (
SAFE_FOR_TEMPLATES &&
regExpTest(EXPRESSIONS.TMPL_MARKER_SERIALIZED, serializedHTML)
) {
_scrubOwnCharacterData(body);
serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;…
Source: GitHub Security Advisories · 2026-12-03