CVE-2026-144292: DOMPurify SAFE_FOR_TEMPLATES bypass: nested <form> makes a template expression reassemble when sanitized output is reparsed
DOMPurify is a DOM-only cross-site scripting sanitizer for HTML, MathML, and SVG. Prior to 3.5.0, DOMPurify.sanitize() with SAFEFORTEMPLATES can return attacker-controlled markup whose brace fragments remain separated during sanitization but become adjacent when nested form elements are reparsed through innerHTML. A template engine that compiles the reparsed DOM can evaluate the reconstructed expression, allowing arbitrary JavaScript execution in the page origin. Plain unsplit template expressions remain scrubbed, and exploitation requires the sanitized output to be reparsed and compiled by a template engine. This issue is fixed in version 3.5.0.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
DOMPurifyto a version that resolves this vulnerability.Fixed in 3.5.0
Event History
Frequently Asked Questions
Which applications are realistically exposed to this issue?
Applications using DOMPurify versions before 3.5.0 with SAFE_FOR_TEMPLATES enabled are exposed only if they subsequently reparse sanitized output through innerHTML and compile that reparsed DOM with a template engine. Applications that do not perform that reparse-and-compile flow are not described as affected.
What must an attacker control for exploitation?
An attacker must be able to supply markup that survives sanitization with template-expression brace fragments separated, then causes those fragments to become adjacent after nested form elements are reparsed. The resulting reconstructed expression must be processed by a template engine capable of evaluating it.
Are ordinary template expressions removed by SAFE_FOR_TEMPLATES vulnerable?
No. Plain, unsplit template expressions remain scrubbed; the bypass depends on fragments being reassembled during reparsing.
What should be done to remediate the issue?
Upgrade DOMPurify to version 3.5.0. If upgrading is not immediately possible, avoid reparsing sanitized output through innerHTML before it is compiled by a template engine.