Description
DOMPurify versions >=3.0.0 and before 3.4.8, when configured with SAFE_FOR_TEMPLATES together with a DOM output mode (RETURN_DOM, RETURN_DOM_FRAGMENT, or IN_PLACE), fail to strip template expressions (e.g. ${evil}, {{evil}}, <%evil%>) inside <template> element content. The final normalization/scrub pass (_scrubTemplateExpressions) uses a NodeIterator and node.normalize() that do not descend into template.content, so expressions that only form after adjacent text nodes merge survive sanitization. This bypasses SAFE_FOR_TEMPLATES and can allow a downstream template engine to evaluate attacker-supplied expressions. The string output path is not affected.
Published: 2026-07-23
Score: 5.1 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

DOMPurify, when configured with SAFE_FOR_TEMPLATES and a DOM output mode such as RETURN_DOM, does not strip template expressions (e.g., ${evil}, {{evil}}, <%evil%>) inside the content of <template> elements. The sanitizer uses node.normalize() without descending into template.content, allowing expressions that are formed after adjacent text nodes merge to survive. This weakness (CWE‑79) enables an attacker to inject expressions that a downstream template engine may evaluate, potentially leading to code execution or other unintended behavior. The vulnerability is limited to DOM output modes and does not affect the string output path.

Affected Systems

All versions of cure53 DOMPurify from 3.0.0 up to and including 3.4.7, which are vulnerable. Versions 3.4.8 and later contain a fix. The vulnerability is independent of operating system or runtime; it is tied only to the configuration of DOMPurify in client‑side or server‑side JavaScript.

Risk and Exploitability

The CVSS score is 5.1, indicating a moderate impact. The EPSS score is less than 1%, suggesting a low likelihood of exploitation in the near term. The vulnerability is not listed in the CISA KEV catalog. Exploitation requires a configuration that uses SAFE_FOR_TEMPLATES with a DOM output mode and an attacker’s input that includes template expressions inside a <template> element. The attack would most likely be performed through any untrusted data passing through DOMPurify before being fed into a template engine. Because the vulnerability operates at rendering time, the attack surface is limited to environments that both sanitize and render template content on the same side of the application. However, if the template engine evaluates expressions in a sandbox that grants access to the environment, the impact could be substantial.

Generated by OpenCVE AI on August 3, 2026 at 21:32 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade DOMPurify to version 3.4.8 or later to receive the patch that removes the injection bug.
  • Re‑evaluate use of SAFE_FOR_TEMPLATES together with DOM output modes; if possible, disable the DOM output mode or remove the SAFE_FOR_TEMPLATES configuration until a reliable solution is in place.
  • Review downstream template rendering to ensure no untrusted expressions are evaluated; consider adding an additional sanitization layer for template content or restricting the source of content that reaches the template engine.

Generated by OpenCVE AI on August 3, 2026 at 21:32 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-gvmj-g25r-r7wr DOMPurify: SAFE_FOR_TEMPLATES bypass - template expressions survive sanitization inside <template> content when using DOM output modes
History

Thu, 23 Jul 2026 21:45:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Thu, 23 Jul 2026 13:30:00 +0000

Type Values Removed Values Added
Description DOMPurify versions >=3.0.0 and before 3.4.8, when configured with SAFE_FOR_TEMPLATES together with a DOM output mode (RETURN_DOM, RETURN_DOM_FRAGMENT, or IN_PLACE), fail to strip template expressions (e.g. ${evil}, {{evil}}, <%evil%>) inside <template> element content. The final normalization/scrub pass (_scrubTemplateExpressions) uses a NodeIterator and node.normalize() that do not descend into template.content, so expressions that only form after adjacent text nodes merge survive sanitization. This bypasses SAFE_FOR_TEMPLATES and can allow a downstream template engine to evaluate attacker-supplied expressions. The string output path is not affected.
Title DOMPurify before 3.4.8 Template Expression Injection via RETURN_DOM
First Time appeared Cure53
Cure53 dompurify
Weaknesses CWE-79
CPEs cpe:2.3:a:cure53:dompurify:*:*:*:*:*:*:*:*
Vendors & Products Cure53
Cure53 dompurify
References
Metrics cvssV3_1

{'score': 6.1, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N'}

cvssV4_0

{'score': 5.1, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N'}


Subscriptions

Cure53 Dompurify
cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-07-23T18:02:48.345Z

Reserved: 2026-07-23T11:03:13.092Z

Link: CVE-2026-65900

cve-icon Vulnrichment

Updated: 2026-07-23T18:02:22.277Z

cve-icon NVD

Status : Analyzed

Published: 2026-07-23T14:18:04.843

Modified: 2026-07-28T15:52:37.367

Link: CVE-2026-65900

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-03T21:45:03Z

Weaknesses
  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')