Dec 4, 2026·11 min read·4 visits
A flaw in DOMPurify prior to 3.5.0 allows attackers to bypass the SAFE_FOR_TEMPLATES option using nested <form> tags that split template delimiters across text nodes. Upon re-parsing via innerHTML, the browser drops the invalid form tags and joins the delimiters, enabling Client-Side Template Injection and arbitrary JavaScript execution.
DOMPurify prior to version 3.5.0 contains a sanitization bypass in the SAFE_FOR_TEMPLATES configuration mode. By embedding split template expression delimiters across invalid nested <form> elements, an attacker can evade character data scrubbing during initial sanitization. When the sanitized markup is subsequently re-parsed into the DOM via innerHTML, browser HTML5 parsing rules strip the nested <form> tags and concatenate the split text nodes, reconstructing executable template expressions that trigger Cross-Site Scripting (XSS) in client-side template engines.
DOMPurify is a widely deployed DOM-only XSS sanitizer for HTML, MathML, and SVG written in JavaScript. In addition to standard HTML sanitization, DOMPurify provides an optional configuration flag named SAFE_FOR_TEMPLATES. When enabled, this flag instructs the sanitizer to identify and strip character sequences associated with popular client-side and server-side template engines, including Mustache, Handlebars, AngularJS, Vue.js, Alpine.js, ERB, EJS, and ES6 template literals.
CVE-2026-144292 (also tracked as GHSA-hrxw-jjj6-2g2j) is a sanitization bypass affecting DOMPurify versions prior to 3.5.0 when operating with SAFE_FOR_TEMPLATES: true. The vulnerability is classified under CWE-79 (Improper Neutralization of Input During Web Page Generation) and CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine). The defect occurs because DOMPurify evaluates text nodes in isolation during its character data scrubbing pass without accounting for DOM mutations that occur when the serialized output is re-parsed by a browser.
An attacker can exploit this behavior by supplying markup that splits multi-character template delimiters (such as {{ and }}) across sibling elements inside nested <form> tags. During the initial sanitization pass, no individual text node contains a complete two-character delimiter sequence, allowing the fragments to pass through unmodified. When the consuming application assigns the sanitized HTML string to a DOM sink such as element.innerHTML, the browser's HTML5 parser drops the invalid nested <form> tags. This parser behavior causes the previously separated text nodes to become immediately adjacent.
If the resulting DOM subtree is subsequently processed or compiled by an active client-side template engine, the adjacent text fragments are evaluated as a unified template expression. This leads to Client-Side Template Injection (CSTI) and arbitrary JavaScript execution within the security context of the victim's browser session.
The root cause of CVE-2026-144292 lies in a discrepancy between how DOMPurify inspects text nodes during sanitization and how the HTML5 parsing algorithm restructures malformed markup upon re-serialization and re-parsing. Prior to version 3.5.0, DOMPurify enforced SAFE_FOR_TEMPLATES via two mechanisms: a pre-check on the serialized HTML string using TMPL_MARKER_SERIALIZED, and a node-by-node traversal in _scrubOwnCharacterData().
During the traversal in _scrubOwnCharacterData(), DOMPurify created a NodeIterator to visit every node in the sanitized DOM tree. For each node, it passed currentNode.data to _stripTemplateExpressions(), which tested the isolated string against regular expressions for template delimiters: MUSTACHE_EXPR (/{{[\w\W]*|^[\w\W]*}}/g), ERB_EXPR (/<%[\w\W]*|^[\w\W]*%>/g), and TMPLIT_EXPR (/\${[\w\W]*/g). Because each regular expression requires at least two contiguous delimiter characters (such as {{, }}, <%, %>, or ${), a single delimiter character like { at the end of one text node and { at the start of a subsequent text node did not trigger a match in either node.
This per-node isolation becomes exploitable due to Section 13.2.6.4.7 of the HTML5 Parsing Specification ('in body' insertion mode), which prohibits nested <form> elements. The specification maintains a form element pointer to track whether a <form> element is currently open. When the parser encounters a <form> start tag while the form element pointer is non-null, it registers a parse error and completely ignores the token. Furthermore, if an end tag </form> is encountered inside a nested child container (such as a <div>), the parser clears the form element pointer and closes the outer form, while leaving the <div> open.
When DOMPurify initially parses the input <form><div>{</form><form>{x}</form>}, the first </form> clears the form pointer, allowing the second <form> tag to be instantiated as a sibling node in the serialized output: <form><div>{</div></form><form>{x}</form>} or similar structural variations depending on the exact tag nesting. Crucially, during the first parse and serialization, the { and {x} characters remain separated by element boundaries. When the application passes this serialized output to innerHTML, the second HTML parsing pass drops the nested <form> tags, placing the text node containing { directly next to the text node containing {x}.
A secondary vector addressed in the same root cause analysis involves HTML5 table foster-parenting and NUL byte stripping. If loose text characters are placed directly inside a <table> or <tbody> element alongside non-table elements, the HTML parser foster-parents (hoists) those nodes in front of the <table> during parsing. Similarly, NUL bytes embedded between delimiter characters can be stripped by the parser, joining split markers into active template expressions.
In versions of DOMPurify prior to 3.5.0, the end of the _sanitize() function in src/purify.ts serialized the sanitized body element first, and only invoked _scrubOwnCharacterData(body) if the serialized string matched TMPL_MARKER_SERIALIZED:
// Vulnerable implementation in src/purify.ts (< 3.5.0)
const serialize = () => (WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML);
let serializedHTML = serialize();
if (
SAFE_FOR_TEMPLATES &&
regExpTest(EXPRESSIONS.TMPL_MARKER_SERIALIZED, serializedHTML)
) {
_scrubOwnCharacterData(body);
serializedHTML = serialize();
}Within the vulnerable _scrubOwnCharacterData() function, the sanitizer iterated over nodes without normalizing adjacent text nodes, without checking cross-node character boundaries, and without accounting for table foster-parenting:
// Vulnerable _scrubOwnCharacterData in src/purify.ts (< 3.5.0)
const _scrubOwnCharacterData = function (node: Element): void {
const walker = _createNodeIterator(node, true);
let currentNode = walker.nextNode() as CharacterData | null;
while (currentNode) {
currentNode.data = _stripTemplateExpressions(currentNode.data);
currentNode = walker.nextNode() as CharacterData | null;
}
};Commit d05b24333a25f6f2e949493749523563f15230e2 (Pull Request #1744) resolves the vulnerability through a multi-layered refactoring of src/purify.ts and src/regexp.ts. First, the conditional regex gating on serializedHTML was removed so that _scrubOwnCharacterData(body) always runs prior to serialization whenever SAFE_FOR_TEMPLATES is enabled. Second, the patch introduces _fosterTableContent(node) and node.normalize() before iterating over the character data, ensuring that any table elements subject to foster-parenting are reordered into their final DOM positions and adjacent text nodes are merged.
// Patched _scrubOwnCharacterData in src/purify.ts (3.5.0)
const _scrubOwnCharacterData = function (node: Element): void {
// 1. Replicate HTML parser foster-parenting for loose table content
_fosterTableContent(node);
// 2. Merge currently adjacent text nodes before iteration
node.normalize();
const walker = _createNodeIterator(node, true);
let previousText: CharacterData | null = null;
let currentNode = walker.nextNode() as CharacterData | null;
while (currentNode) {
let { data } = currentNode;
// 3. Strip NUL characters that could be dropped on reparse to join markers
if (regExpTest(EXPRESSIONS.NUL, data)) {
data = stringReplace(data, EXPRESSIONS.NUL, '');
currentNode.data = data;
}
// 4. Scrub complete template markers within the current node
if (regExpTest(EXPRESSIONS.TMPL_MARKER, data)) {
data = _stripTemplateExpressions(data);
currentNode.data = data;
}
// 5. Check boundary between the previous non-empty text node and current text node
if (data && _readNodeType(currentNode) === NODE_TYPE.text) {
if (previousText) {
const tail = previousText.data;
const boundary = tail[tail.length - 1] + data[0];
if (regExpTest(EXPRESSIONS.TMPL_MARKER, boundary)) {
previousText.data = _stripTemplateExpressions(tail + data[0]);
}
}
previousText = currentNode;
}
currentNode = walker.nextNode() as CharacterData | null;
}
};The critical defense against the nested <form> bypass is implemented in step 5 of the patched function. As the NodeIterator traverses all text nodes in document order, it maintains a reference to the last non-empty text node (previousText), regardless of what HTML element tags exist between previousText and currentNode. It then concatenates the last character of previousText.data (tail[tail.length - 1]) with the first character of the current text node (data[0]) to form a two-character boundary string. If boundary matches EXPRESSIONS.TMPL_MARKER (/{{|}}|<%|%>|\${/), DOMPurify scrubs previousText.data as if data[0] were appended to it, effectively stripping the leading delimiter character and breaking the template expression even if all intervening tags are later dropped during re-parsing.
This fix is comprehensive for two-character template delimiters because document order of text nodes is preserved across innerHTML re-parses once table foster-parenting is accounted for by _fosterTableContent(). By evaluating every sequential previousText to currentNode transition in document order, any pair of text nodes that could ever become adjacent after tag stripping has its boundary tested and neutralized.
Exploiting CVE-2026-144292 requires specific application preconditions reflected in the CVSS v4.0 vector (AT:P - Attack Requirements: Present). First, the target application must sanitize untrusted user input using DOMPurify with the SAFE_FOR_TEMPLATES: true configuration option. Second, the application must insert the resulting sanitized HTML string into the DOM using a sink that triggers the browser's HTML parser, such as innerHTML, outerHTML, or document.write(). Third, the DOM subtree containing the re-parsed markup must be processed by a client-side template engine such as AngularJS, Vue.js, Alpine.js, or Mustache.
To construct an exploit payload, the attacker splits both the opening {{ and closing }} delimiters across a nested <form> construct. The canonical proof-of-concept from the official DOMPurify test suite in commit d05b24333a25f6f2e949493749523563f15230e2 demonstrates how the split delimiters reunite after a single innerHTML re-parse:
// Proof of Concept demonstrating SAFE_FOR_TEMPLATES bypass in DOMPurify < 3.5.0
const dirty = '<form><div>{</form><form>{x}</form>}';
const reparsedText = (html) => {
const div = document.createElement('div');
div.innerHTML = html;
return div.textContent;
};
const clean = DOMPurify.sanitize(dirty, { SAFE_FOR_TEMPLATES: true });
console.log('Sanitized HTML:', clean);
console.log('Reparsed textContent:', reparsedText(clean));
// In DOMPurify < 3.5.0, reparsedText(clean) evaluates to: "{{x}}"
// In DOMPurify >= 3.5.0, reparsedText(clean) evaluates to: " "In a real-world attack against an application using AngularJS (1.x) or Vue.js dynamic template compilation, the attacker replaces the placeholder x with a sandbox escape or constructor traversal payload. For example, in an AngularJS 1.6+ environment where sanitized comments are injected into an active ng-app container via innerHTML, the attacker submits the following payload:
<form><div>{</form><form>{$on.constructor('alert(document.domain)')()}</form>}When DOMPurify (< 3.5.0) processes this input, the text node inside the <div> contains only {, the text node inside the second <form> contains {$on.constructor('alert(document.domain)')()}, and the trailing text node contains }. None of these three nodes match MUSTACHE_EXPR. However, once the application writes the sanitized string to containerElement.innerHTML and triggers AngularJS compilation, the nested <form> tag is discarded by the browser parser. The text inside the <div> collapses into {{$on.constructor('alert(document.domain)')()}}, causing the template compiler to execute the attacker's JavaScript payload.
Successful exploitation of CVE-2026-144292 results in arbitrary JavaScript execution (Cross-Site Scripting) within the victim's browser in the origin of the vulnerable web application. Because the attacker's code executes with full access to the application's Document Object Model (DOM) and JavaScript runtime environment, the attacker can read non-HttpOnly cookies, steal session tokens stored in localStorage or sessionStorage, exfiltrate sensitive page contents, and issue authenticated API requests on behalf of the victim.
Under CVSS v4.0, CVE-2026-144292 is assigned a base score of 7.6 (High) with the vector 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. The Attack Vector (AV:N) is Network and Privileges Required (PR:N) is None, as unauthenticated attackers can deliver payloads remotely via web inputs. Attack Requirements (AT:P) is Present because exploitation depends on the application both re-parsing the sanitized output via an HTML sink and compiling the resulting DOM with a client-side template engine. User Interaction (UI:P) is Passive, requiring only that a victim view a page rendering the stored or reflected payload.
Confidentiality (VC:H) and Integrity (VI:H) impacts to the vulnerable system (the client browser session and application origin) are rated High due to total compromise of the user's application context. Availability impact (VA:L) is Low, as script execution can disrupt page rendering or freeze the browser tab. Subsequent System impacts (SC:N/SI:N/SA:N) are rated None because the compromise is scoped to the browser's same-origin policy boundary.
According to the CISA Stakeholder-Specific Vulnerability Categorization (SSVC) assessment, exploitation status is rated as PoC (Proof of Concept available), Automatable is No, and Technical Impact is Total. The vulnerability is not currently listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.
The primary remediation for CVE-2026-144292 is to upgrade DOMPurify to version 3.5.0 or later. Version 3.5.0 incorporates commit d05b24333a25f6f2e949493749523563f15230e2, which enforces boundary-aware character data scrubbing, strips NUL characters, and normalizes table foster-parenting prior to serialization.
# Upgrade via npm
npm install dompurify@^3.5.0
# Upgrade via yarn
yarn upgrade dompurify@^3.5.0
# Upgrade via pnpm
pnpm update dompurify@^3.5.0> [!NOTE]
> As documented in DOMPurify's security guidelines, SAFE_FOR_TEMPLATES is designed solely as a defense-in-depth measure. Applications should avoid inserting untrusted, user-controlled HTML into DOM containers that are compiled by client-side template engines.
For applications where an immediate dependency upgrade is not feasible, developers can implement two effective workarounds. First, configure the client-side template engine to skip compilation on any DOM element that receives user-supplied HTML via innerHTML. In AngularJS, add the ng-non-bindable directive to the container element; in Vue.js, apply the v-pre directive; and in Alpine.js, use the x-ignore attribute.
Second, if SAFE_FOR_TEMPLATES must be relied upon prior to upgrading, developers can configure DOMPurify to return a DOM node directly rather than a serialized HTML string by passing { SAFE_FOR_TEMPLATES: true, RETURN_DOM: true } or { SAFE_FOR_TEMPLATES: true, RETURN_DOM_FRAGMENT: true }. Appending the returned DOM node via element.appendChild(cleanDom) avoids the secondary HTML parsing pass triggered by element.innerHTML = cleanString, preventing the browser parser from dropping nested <form> tags or foster-parenting table content after sanitization. Alternatively, stripping <form> and <table> elements via { FORBID_TAGS: ['form', 'table', 'tbody', 'thead', 'tfoot', 'tr'] } eliminates the structural mutation vectors utilized in this bypass.
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| Product | Affected Versions | Fixed Version |
|---|---|---|
DOMPurify cure53 | < 3.5.0 | 3.5.0 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-144292 (GHSA-hrxw-jjj6-2g2j) |
| CWE Classification | CWE-79 (Cross-site Scripting) / CWE-1336 (Template Injection) |
| CVSS v4.0 Score | 7.6 High (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) |
| Attack Vector | Network (Unauthenticated HTML input with SAFE_FOR_TEMPLATES enabled) |
| Affected Versions | DOMPurify < 3.5.0 |
| Patched Version | DOMPurify 3.5.0 |
| Impact | Client-Side Template Injection & Arbitrary JavaScript Execution (XSS) |
| Exploit & KEV Status | Public PoC Available / Not Listed in CISA KEV |
The software does not neutralize or incorrectly neutralizes user-controllable input before placing it in output used as a web page that is served to other users.
CVE-2026-137198 is a high-severity argument injection vulnerability (CWE-88) affecting the Node.js cross-spawn library in versions 6.0.6 and 7.0.4 through 7.0.6. On Windows systems, when commands are routed through cmd.exe (including batch files and npm cmd-shims in node_modules/.bin), cross-spawn fails to properly double contiguous sequences of two or more backslashes preceding a double quote or at the end of an argument. This parsing failure causes the argument's closing quotation mark to be escaped as a literal character, allowing attacker-controlled input to break out of quotation encapsulation and inject arbitrary command-line arguments or consume subsequent arguments.
CVE-2026-74870 is an information exposure vulnerability in the Python package openssl_encrypt affecting versions 1.4.7 and earlier. The diagnostic CLI subcommands 'hsm fido2-test' and 'hsm onlykey-test' unconditionally write full derived hardware cryptographic peppers as hexadecimal strings to standard error. Additionally, the FIDO2 hardware pepper plugin logs unredacted pseudo-random function (PRF) output to debug logs and user-facing error messages. While the diagnostic pepper is bound to a random per-invocation test salt and cannot directly decrypt stored files, the behavior exposes raw hardware-derived key material to terminal scrollbacks, session recordings, and CI/CD logs.
A validation logic bypass vulnerability exists in the Laravel Framework validation subsystem prior to versions 12.72.0 and 13.43.0. When validating nested attributes or wildcard arrays using the 'sometimes' rule, the framework uses the literal string '__missing__' as an in-band sentinel value to detect absent keys. An attacker who submits the literal string '__missing__' as the value for a nested attribute causes the validator to misinterpret the field as omitted, bypassing all subsequent validation rules while still returning the unvalidated string in the validated dataset.
CVE-2026-142643 is a type confusion vulnerability in the Laravel Framework validation subsystem (Illuminate\Validation\DatabasePresenceVerifier) affecting versions prior to 12.73.0 and 13.43.0. When processing JSON-encoded HTTP requests, the framework preserves native integer and boolean scalar types and passes them unchanged into SQL parameter bindings for 'exists' and 'unique' validation rules. On MySQL and MariaDB databases, comparing a string column against an integer value triggers implicit numeric type coercion, causing any non-numeric string entry to evaluate to zero. Consequently, an unauthenticated remote attacker can submit an integer zero or boolean false in a JSON payload to bypass record-existence validation rules without knowing a valid string identifier.
CVE-2026-142649 (also tracked as GHSA-h2hg-mfj4-rg7q) is an input validation bypass vulnerability affecting the validation subsystem of the Laravel web application framework (laravel/framework). Specifically, the validateIn method in src/Illuminate/Validation/Concerns/ValidatesAttributes.php performs non-strict comparisons when evaluating scalar input values against defined allowlists for the 'in', 'Rule::in', and 'not_in' validation rules. Because PHP's native in_array() function defaults to loose equality (==) when the third parameter ($strict) is omitted, numeric strings with non-canonical representations—such as leading or trailing whitespace, embedded newlines, leading zeros, positive signs, decimal points, or scientific notation—evaluate as equal to standard numeric allowlist entries. Furthermore, because Laravel's validated() and valid() accessor methods return the original, un-canonicalized input string rather than the matched allowlist token, unvalidated characters and unexpected string formats propagate directly into downstream business logic, database queries, and state enforcement checks.
An authenticated SQL injection vulnerability exists in Agenta prior to version 0.122.5 within the tracing database query layer. The full-text content filter handler in api/oss/src/dbs/postgres/tracing/utils.py interpolates user-supplied search strings directly into a SQLAlchemy text() construct without parameter binding or escaping. This flaw allows an authenticated user with read access to spans in a single project to execute arbitrary SQL conditions against the tracing database, bypassing project and tenant isolation boundaries to exfiltrate trace data across the entire platform.