---
id: "CVE-2026-116804"
kind: "vulnerability"
aliases: ["CVE-2026-116804"]
title: "DOMPurify: SAFE_FOR_TEMPLATES bypass lets template expressions survive sanitization"
severity: "medium"
cvss: 6.1
epss: null
exploited: false
status: "open"
category: "package"
products: []
ecosystems: []
tags: ["dompurify", "frontend", "javascript", "package", "web-apps"]
not_affected_if: ["default-config", "no-template-engine"]
published_at: "2026-10-27T00:17:12+00:00"
first_seen_at: "2026-10-27T00:25:55+00:00"
updated_at: "2026-10-27T00:26:37+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-116804", "first_seen_at": "2026-10-27T00:25:55+00:00"}]
---

# DOMPurify: SAFE_FOR_TEMPLATES bypass lets template expressions survive sanitization

DOMPurify versions 3.4.4 up to 3.4.17 fail to strip template expressions split across text nodes when RETURN_DOM, RETURN_DOM_FRAGMENT or IN_PLACE is used. A downstream template engine can then evaluate the merged expression, which enables cross-site scripting.

_Summary, check and fix written by a model from the sources; labelled as such._

## How to check

- Check the installed version with `npm ls dompurify` or by reading `node_modules/dompurify/package.json`.
- Search the code for `RETURN_DOM`, `RETURN_DOM_FRAGMENT` or `IN_PLACE` passed to `DOMPurify.sanitize`, and for `SAFE_FOR_TEMPLATES`.

## Fix

- Upgrade `dompurify` to `3.4.17` or later.
- If the upgrade is not possible, avoid the RETURN_DOM, RETURN_DOM_FRAGMENT and IN_PLACE modes on untrusted input, unknown for other workarounds.

## Timeline

- 2026-10-27T00:25:55+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-116804

## From the sources

DOMPurify from 3.4.4 before 3.4.17 contains a SAFE_FOR_TEMPLATES bypass that lets attackers preserve template expressions in attached shadow roots when using RETURN_DOM, RETURN_DOM_FRAGMENT, or IN_PLACE modes. Attackers can split expressions across text nodes separated by disallowed elements, which merge after removal and are evaluated by downstream template engines for cross-site scripting.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
