Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessCraft diagram with `:not(&)` CSS payload in fontFamily/themeCSS init param
-
DeliverySubmit to application accepting user-supplied Mermaid diagrams
-
ExploitVictim views page and browser triggers diagram render
-
ExecutionStylis processes CSS without namespace enforcement in unpatched version
-
PersistInjected CSS escapes SVG scope and applies to host page globally
-
ImpactDeface page UI or exfiltrate DOM attributes via CSS :has() selectors
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that the target application renders user-controllable Mermaid diagram content under the default Mermaid configuration, specifically without |
| Impact | The vendor-assigned CVSS 4.0 score of 5.3 (Medium) correctly captures the core risk profile: network-reachable (AV:N), low complexity (AC:L), no privileges required (PR:N), but passive user interaction needed (UI:P - a victim must render the diagram). EPSS at 0.05% (15th percentile) is very low and the vulnerability is not in the CISA KEV, indicating no confirmed widespread exploitation. The 'RCE' tag present in the source intelligence is a mislabel - the commit diff and advisory description confirm impact is CSS injection enabling page defacement and DOM attribute exfiltration, not arbitrary code execution; security teams should not escalate based on that tag. Real-world risk is meaningful specifically for platforms that render user-supplied Mermaid diagrams with default configuration (wikis, collaborative documentation, Markdown renderers), where the CSS breakout can enable phishing overlays, UI redressing, or CSS-based side-channel data leakage. Risk is substantially mitigated by the |
| Exploit ScenarioDerived | An attacker submits a malicious Mermaid diagram containing a crafted |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jul 23, 2026
CSS scoping bypass in Mermaid's default configuration allows injected styles to escape the diagram SVG container and apply globally to the host page via the fontFamily, themeCSS, and altFontFamily initialization options. Affected are npm/mermaid versions up to 10.9.5 and 11.0.0-alpha.1 through 11.14.0 when rendered with default settings - covering any web application that renders user-supplied diagram definitions, such as wikis and documentation platforms. An attacker who can influence diagram initialization parameters can achieve page defacement and DOM attribute exfiltration via CSS :has() selectors; a public proof-of-concept demo exists on mermaid.live, though no CISA KEV listing or widespread exploitation is recorded, and the EPSS of 0.05% (15th percentile) confirms low current exploitation activity.
RemediationAI
Upgrade to mermaid v11.15.0 (v11 line) or v10.9.6 (v10 line), both confirmed fixed releases per the GitHub advisory GHSA-87f9-hvmw-gh4p; patch commits are https://github.com/mermaid-js/mermaid/commit/64769738d5b59211e1decb471ffbaca8afec51aa (v11) and https://github.com/mermaid-js/mermaid/commit/a9d9f0d8eb790349121508688cd338253fd80d76 (v10). If immediate upgrade is not feasible, set the secure configuration array in your Mermaid config to block user modification of fontFamily, themeCSS, altFontFamily, and themeVariables - note this disables legitimate diagram-level styling customization. Alternatively, set "securityLevel": "sandbox" to render diagrams inside an isolated iframe, which fully prevents CSS escape to the host page; this may affect certain diagram rendering features and requires proper iframe CSP configuration to be effective. See https://mermaid.js.org/config/schema-docs/config.html#securitylevel for securityLevel documentation.
Affected VersionsENISA
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 2 packages in npm, euvd
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Mermaid (pkg:npm/mermaid) is a JavaScript diagramming library that uses the stylis CSS preprocessor to scope diagram styles under a unique SVG ID such as #mermaid-xxx. The root cause is CWE-94 (Improper Control of Generation of Code): stylis treats & as a scope reference that resolves to the diagram's root selector, and when Mermaid compiles user-supplied strings from fontFamily, themeCSS, or altFontFamily options, it previously did not enforce that &-containing selectors remain bounded by the diagram namespace. The pseudo-class :not(&) in stylis matches any element that is not the diagram root - effectively the entire host page - allowing global style injection. Additionally, global CSS at-rules (@font-face, @keyframes, @counter-style) are hoisted to the document top level by stylis, further widening the injection surface. The fix (commits 64769738 and a9d9f0d8) introduces a stylis middleware in mermaidAPI.ts that iterates every compiled CSS rule's props array and prepends the diagram namespace to any selector not already starting with it, ensuring :not(&) and similar constructs can never resolve outside the SVG element.
Know when the next one hits your stack
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:L
Network-reachable with no privileges; victim must render the diagram (UI:R); CSS escapes diagram scope to host page (S:C); limited confidentiality via :has() exfiltration (C:L) and integrity via defacement (I:L); no availability impact.
Primary rating from Vendor (https://github.com/mermaid-js/mermaid).
CVSS VectorVendor: https://github.com/mermaid-js/mermaid
Lifecycle Timeline
2DescriptionCVE.org
Impact
Mermaid's default configuration allows injecting CSS that applies outside of the Mermaid diagram via the fontFamily, themeCSS, and altFontFamily configuration options.
Live demo: mermaid.live
Example code:
%%{init: {"fontFamily": "x;a{b} :not(&){background:green !important} c{d}"}}%%
flowchart LR
A --> BThe injected CSS exploits stylis's & (scope reference) handling. :not(&) escapes the #mermaid-xxx automatic scoping, applying styles to all page elements. Global at-rules (@font-face, @keyframes, @counter-style) are also injectable as stylis hoists them to top level.
This allows page defacement and DOM attribute exfiltration via CSS :has() selectors.
Patches
- v11.15.0 (see 64769738d5b59211e1decb471ffbaca8afec51aa)
- v10.9.6 (see a9d9f0d8eb790349121508688cd338253fd80d76)
Workarounds
If you can't upgrade mermaid, you can set the secure config value in the mermaid config to avoid allowing diagrams to modify fontFamily, themeCSS, altFontFamily, and themeVariables.
Setting "securityLevel": "sandbox" will also prevent this.
Credits
Reported by @zsxsoft on behalf of @KeenSecurityLab
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
EUVD-2026-33324
GHSA-87f9-hvmw-gh4p
NVD
CVE.org
EPSS
VulDB
Exploit-DB