DOMPurify SAFE_FOR_TEMPLATES bypass: nested <form> reassembles template expressions on reparse, enabling XSS/RCE in template engines (CVE-2026-144292)
Severity: high · Patch status: patched · Since 2026-11-23 · CVE-2026-144292
A bypass of DOMPurify's SAFEFORTEMPLATES protection (CVE-2026-144292) was disclosed affecting all versions before 3.5.0. Crafted markup with nested <form elements causes the sanitizer to return a string containing no {{ or }} markers, yet when the sanitized output is assigned to innerHTML, the HTML parser drops the inner <form tag and merges adjacent text fragments into a live {{…}} template expression. Template engines that compile the resulting DOM — verified with Vue 3 in-DOM templates and AngularJS 1.8.3 — evaluate the attacker-controlled expression, yielding arbitrary JavaScript execution. The per-node and post-serialization scrubs both miss the case because the guarantee is not stable under a second parse. Public PoC works on Chromium, Firefox and WebKit. Fixed in DOMPurify 3.5.0.
What to do
- Upgrade dompurify to 3.5.0 or later immediately
- Audit apps using SAFE_FOR_TEMPLATES with template engines (Vue in-DOM templates, AngularJS) that compile sanitized HTML
- As interim mitigation, avoid assigning sanitized output via innerHTML into template-compiled DOM, or strip nested <form> elements from sanitized output
- Add regression checks for template-expression reassembly in sanitization pipelines
Fixed versions
Sources
All live incidents on Threat Watch