chore(deps): update dependency dompurify@<3.3.2 to v3.4.0 [security]#2573
Open
renovate[bot] wants to merge 1 commit intomainfrom
Open
chore(deps): update dependency dompurify@<3.3.2 to v3.4.0 [security]#2573renovate[bot] wants to merge 1 commit intomainfrom
renovate[bot] wants to merge 1 commit intomainfrom
Conversation
2c276ce to
d64b565
Compare
d64b565 to
2c276ce
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.3.2→3.4.0DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluation
GHSA-39q2-94rc-95cp
More information
Details
Summary
In
src/purify.ts:1117-1123,ADD_TAGSas a function (viaEXTRA_ELEMENT_HANDLING.tagCheck) bypassesFORBID_TAGSdue to short-circuit evaluation.The condition:
When
tagCheck(tagName)returnstrue, the entire condition isfalseand the element is kept —FORBID_TAGS[tagName]is never evaluated.Inconsistency
This contradicts the attribute-side pattern at line 1214 where
FORBID_ATTRexplicitly wins first:For tags, FORBID should also take precedence over ADD.
Impact
Applications using both
ADD_TAGSas a function andFORBID_TAGSsimultaneously get unexpected behavior — forbidden tags are allowed through. Config-dependent but a genuine logic inconsistency.Suggested Fix
Check
FORBID_TAGSbeforetagCheck:Affected Version
v3.3.3 (commit 883ac15)
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM mode
CVE-2026-41239 / GHSA-crv5-9vww-q3g8
More information
Details
Summary
mainat883ac15, introduced in v1.0.10 (7fc196db)SAFE_FOR_TEMPLATESstrips{{...}}expressions from untrusted HTML. This works in string mode but not withRETURN_DOMorRETURN_DOM_FRAGMENT, allowing XSS via template-evaluating frameworks like Vue 2.Technical Details
DOMPurify strips template expressions in two passes:
purify.ts:1179-1191):purify.ts:1679-1683). This is the safety net that catches expressions that only form after the DOM settles.The
RETURN_DOMpath returns before pass #2 ever runs (purify.ts:1637-1661):The payload
{<foo></foo>{constructor.constructor('alert(1)')()}<foo></foo>}exploits this:TEXT("{")→<foo>→TEXT("{payload}")→<foo>→TEXT("}")— no single node contains{{, so pass #1 misses it<foo>is not allowed, so DOMPurify removes it but keeps surrounding text.outerHTMLreads them as{{payload}}, which Vue 2 compiles and executesReproduce
Open the following html in any browser and
alert(1)pops up.Impact
Any application that sanitizes attacker-controlled HTML with
SAFE_FOR_TEMPLATES: trueandRETURN_DOM: true(orRETURN_DOM_FRAGMENT: true), then mounts the result into a template-evaluating framework, is vulnerable to XSS.Recommendations
Fix
normalize()merges the split text nodes, then the same regex from the string path catches the expression. Placed before the fragment logic, this fixes bothRETURN_DOMandRETURN_DOM_FRAGMENT.if (RETURN_DOM) { + if (SAFE_FOR_TEMPLATES) { + body.normalize(); + let html = body.innerHTML; + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => { + html = stringReplace(html, expr, ' '); + }); + body.innerHTML = html; + } + if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument);Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)
CVE-2026-41240 / GHSA-h7mw-gpvr-xq4m
More information
Details
There is an inconsistency between FORBID_TAGS and FORBID_ATTR handling when function-based ADD_TAGS is used.
Commit c361baa added an early exit for FORBID_ATTR at line 1214:
The same fix was not applied to FORBID_TAGS. At line 1118-1123, when EXTRA_ELEMENT_HANDLING.tagCheck returns true, the short-circuit evaluation skips the FORBID_TAGS check entirely:
This allows forbidden elements to survive sanitization with their attributes intact.
PoC (tested against current HEAD in Node.js + jsdom):
Confirmed affected: iframe, object, embed, form. The src/action/data attributes survive because attribute sanitization runs separately and allows these URLs.
Compare with FORBID_ATTR which correctly wins:
Suggested fix: add FORBID_TAGS early exit before the tagCheck evaluation, mirroring line 1214:
This requires function-based ADD_TAGS in the config, which is uncommon. But the asymmetry with the FORBID_ATTR fix is clear, and the impact includes iframe and form injection with external URLs.
Reporter: Koda Reef
Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
DOMPurify: Prototype Pollution to XSS Bypass via CUSTOM_ELEMENT_HANDLING Fallback
CVE-2026-41238 / GHSA-v9jr-rg53-9pgp
More information
Details
Summary
DOMPurify versions 3.0.1 through 3.3.3 (latest) are vulnerable to a prototype pollution-based XSS bypass. When an application uses
DOMPurify.sanitize()with the default configuration (noCUSTOM_ELEMENT_HANDLINGoption), a prior prototype pollution gadget can inject permissivetagNameCheckandattributeNameCheckregex values intoObject.prototype, causing DOMPurify to allow arbitrary custom elements with arbitrary attributes — including event handlers — through sanitization.Affected Versions
Object.create(null)for initialization, no|| {}reassignment)|| {}reassignment was introduced in the 3.0.0→3.0.1 refactorRoot Cause
In
purify.jsat line 590, during config parsing:When no
CUSTOM_ELEMENT_HANDLINGis specified in the config (the default usage pattern),cfg.CUSTOM_ELEMENT_HANDLINGisundefined, and the fallback{}is used. This plain object inherits fromObject.prototype.Lines 591-598 then check
cfg.CUSTOM_ELEMENT_HANDLING(the original config property) — which isundefined— so the conditional blocks that would settagNameCheckandattributeNameCheckfrom the config are never entered.As a result,
CUSTOM_ELEMENT_HANDLING.tagNameCheckandCUSTOM_ELEMENT_HANDLING.attributeNameCheckresolve via the prototype chain. If an attacker has pollutedObject.prototype.tagNameCheckandObject.prototype.attributeNameCheckwith permissive values (e.g.,/.*/), these polluted values flow into DOMPurify's custom element validation at lines 973-977 and attribute validation, causing all custom elements and all attributes to be allowed.Impact
DOMPurify.sanitize(userInput)call is affected.Proof of Concept
Tested configurations that are vulnerable:
DOMPurify.sanitize(input)DOMPurify.sanitize(input, {})DOMPurify.sanitize(input, { CUSTOM_ELEMENT_HANDLING: null })DOMPurify.sanitize(input, { CUSTOM_ELEMENT_HANDLING: {} })Suggested Fix
Change line 590 from:
To:
The
create(null)function (already used elsewhere in DOMPurify, e.g., inclone()) creates an object with no prototype, preventing prototype chain inheritance.Alternative application-level mitigation:
Applications can protect themselves by always providing an explicit
CUSTOM_ELEMENT_HANDLINGin their config:Timeline
Credit
https://github.com/trace37labs
Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
cure53/DOMPurify (dompurify@<3.3.2)
v3.4.0: DOMPurify 3.4.0Compare Source
Most relevant changes:
FORBID_TAGSnot winning overADD_TAGS, thanks @kodareef5ADD_ATTR/ADD_TAGSfunction leaking into subsequent array-based calls, thanks @1Jesper1SAFE_FOR_TEMPLATESscrub inRETURN_DOMpath, thanks @bencalifCUSTOM_ELEMENT_HANDLING, thanks @trace37labsADD_TAGSfunction form bypassingFORBID_TAGS, thanks @eddieranADD_ATTRpredicates skipping URI validation, thanks @christos-ethUSE_PROFILESprototype pollution, thanks @christos-ethPublished Advisories are here:
https://github.com/cure53/DOMPurify/security/advisories?state=published
v3.3.3: DOMPurify 3.3.3Compare Source
Configuration
📅 Schedule: (UTC)
🚦 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.