Update npm package dompurify to v3.4.0 [SECURITY]#8634
Update npm package dompurify to v3.4.0 [SECURITY]#8634hash-worker[bot] wants to merge 1 commit intomainfrom
dompurify to v3.4.0 [SECURITY]#8634Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
PR SummaryLow Risk Overview This change is intended to pull in upstream security fixes for DOM sanitization used in places like the Prism snippet renderer that sanitizes HTML before Reviewed by Cursor Bugbot for commit 5b6fab9. Bugbot is set up for automated code reviews on this repo. Configure here. |
🤖 Augment PR SummarySummary: Updates 🤖 Was this summary useful? React with 👍 or 👎 |
This PR contains the following updates:
3.3.2->3.4.0Warning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
GitHub Vulnerability Alerts
CVE-2026-0540
DOMPurify 3.1.3 through 3.3.1 and 2.5.3 through 2.5.8, fixed in 2.5.9 and 3.3.2, contain a cross-site scripting vulnerability that allows attackers to bypass attribute sanitization by exploiting five missing rawtext elements (noscript, xmp, noembed, noframes, iframe) in the
SAFE_FOR_XMLregex. Attackers can include payloads like</noscript><img src=x onerror=alert(1)>in attribute values to execute JavaScript when sanitized output is placed inside these unprotected rawtext contexts.GHSA-h8r8-wccr-v5f2
Description
A mutation-XSS (mXSS) condition was confirmed when sanitized HTML is reinserted into a new parsing context using
innerHTMLand special wrappers. The vulnerable wrappers confirmed in browser behavior arescript,xmp,iframe,noembed,noframes, andnoscript. The payload remains seemingly benign afterDOMPurify.sanitize(), but mutates during the second parse into executable markup with an event handler, enabling JavaScript execution in the client (alert(1)in the PoC).Vulnerability
The root cause is context switching after sanitization: sanitized output is treated as trusted and concatenated into a wrapper string (for example,
<xmp> ... </xmp>or other special wrappers) before being reparsed by the browser. In this flow, attacker-controlled text inside an attribute (for example</xmp>or equivalent closing sequences for each wrapper) closes the special parsing context early and reintroduces attacker markup (<img ... onerror=...>) outside the original attribute context. DOMPurify sanitizes the original parse tree, but the application performs a second parse in a different context, reactivating dangerous tokens (classic mXSS pattern).PoC
http://localhost:3001.Wrapper en sinktoxmp.Sanitize + Render.Sanitized responsestill contains the</xmp>sequence insidealt.<img src="x" onerror="alert('expoc')">.alert('expoc')is triggered.{ "name": "expoc", "version": "1.0.0", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node server.js", "dev": "node server.js" }, "keywords": [], "author": "", "license": "ISC", "description": "", "dependencies": { "dompurify": "^3.3.1", "express": "^5.2.1", "jsdom": "^28.1.0" } }Evidence
daft-video.webm
Why This Happens
This is a mutation-XSS pattern caused by a parse-context mismatch:
xmpraw-text behavior).</xmp>) gains structural meaning in parse 2 and alters DOM structure.Sanitization is not a universal guarantee across all future parsing contexts. The sink design reintroduces risk.
Remediation Guidance
innerHTML.textContent,createElement,setAttribute) over string-based HTML composition.xmp,script, etc.).</xmp>,</noscript>, similar parser-breakout markers).Reported by Oscar Uribe, Security Researcher at Fluid Attacks. Camilo Vera and Cristian Vargas from the Fluid Attacks Research Team have identified a mXSS via Re-Contextualization in DomPurify 3.3.1.
Following Fluid Attacks Disclosure Policy, if this report corresponds to a vulnerability and the conditions outlined in the policy are met, this advisory will be published on the website over the next few days (the timeline may vary depending on maintainers' willingness to attend to and respond to this report) at the following URL: https://fluidattacks.com/advisories/daft
Acknowledgements: Camilo Vera and Cristian Vargas.
GHSA-cjmm-f4jc-qw8r
Summary
DOMPurify allows
ADD_ATTRto be provided as a predicate function viaEXTRA_ELEMENT_HANDLING.attributeCheck. When the predicate returnstrue,_isValidAttributeshort-circuits the attribute check before URI-safe validation runs. An attacker who supplies a predicate that accepts specific attribute/tag combinations can then sanitize input such as<a href="javascript:alert(document.domain)">and have thejavascript:URL survive, because URI validation is skipped for that attribute while other checks still pass. The provided PoC acceptshreffor anchors and then triggers a click inside an iframe, showing that the sanitized payload executes despite the protocol bypass.Impact
Predicate-based allowlisting bypasses DOMPurify's URI validation, allowing unsafe protocols such as
javascript:to reach the DOM and execute whenever the link is activated, resulting in DOM-based XSS.Credits
Identified by Cantina’s Apex (https://www.cantina.security).
GHSA-cj63-jhhr-wcxv
Summary
When
USE_PROFILESis enabled, DOMPurify rebuildsALLOWED_ATTRas a plain array before populating it with the requested allowlists. Because the sanitizer still looks up attributes viaALLOWED_ATTR[lcName], anyArray.prototypeproperty that is polluted also counts as an allowlisted attribute. An attacker who can setArray.prototype.onclick = true(or a runtime already subject to prototype pollution) can thus force DOMPurify to keep event handlers such asonclickeven when they are normally forbidden. The provided PoC sanitizes<img onclick=...>withUSE_PROFILESand adds the sanitized output to the DOM; the polluted prototype allows the event handler to survive and execute, turning what should be a blocklist into a silent XSS vector.Impact
Prototype pollution makes DOMPurify accept dangerous event handler attributes, which bypasses the sanitizer and results in DOM-based XSS once the sanitized markup is rendered.
Credits
Identified by Cantina’s Apex (https://www.cantina.security).
GHSA-39q2-94rc-95cp
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)
Release Notes
cure53/DOMPurify (dompurify)
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: Branch creation - "" (UTC), Automerge - "before 4am every weekday,every weekend" (UTC).
🚦 Automerge: Enabled.
♻ 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 has been generated by Renovate Bot.