Template Injection Affecting dompurify package, versions <3.5.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.51% (45th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-DOMPURIFY-23401145
  • published3 Dec 2026
  • disclosed1 Dec 2026
  • credite1abrador

Introduced: 1 Dec 2026

NewCVE-2026-140391  (opens in a new tab)
CWE-1336  (opens in a new tab)
CWE-79  (opens in a new tab)

How to fix?

Upgrade dompurify to version 3.5.0 or higher.

Overview

dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

Affected versions of this package are vulnerable to Template Injection in the serialized output of sanitize() when SAFE_FOR_TEMPLATES: true is set. An attacker can execute arbitrary JavaScript in a template engine (demonstrated with in-DOM Vue 3 templates and AngularJS) by submitting markup, such as a sequence of nested <form> elements or an element whose removal leaves end tags without a matching start tag, that contains no {{...}}, ${...}, or <%...%> sequence in the sanitized string but reassembles one once the output is reparsed, for example by assignment to innerHTML.

This requires only that the application use SAFE_FOR_TEMPLATES for its documented purpose, with no other non-default configuration.

The fix for the end-tag-removal variant shipped in 3.4.18, but the nested-form variant remains exploitable in that release and is fixed only starting in 3.5.0.

CVSS Base Scores

version 4.0
version 3.1