Skip to main content

Mermaid CVE-2026-41159

| EUVDEUVD-2026-33324 MEDIUM
Code Injection (CWE-94)
2026-05-11 https://github.com/mermaid-js/mermaid GHSA-87f9-hvmw-gh4p
5.3
CVSS 4.0 · Vendor: https://github.com/mermaid-js/mermaid
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft diagram with `:not(&)` CSS payload in fontFamily/themeCSS init param
  2. Delivery
    Submit to application accepting user-supplied Mermaid diagrams
  3. Exploit
    Victim views page and browser triggers diagram render
  4. Execution
    Stylis processes CSS without namespace enforcement in unpatched version
  5. Persist
    Injected CSS escapes SVG scope and applies to host page globally
  6. Impact
    Deface 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 securityLevel: sandbox and without the secure config option enabled. The attacker must be able to influence the fontFamily, themeCSS, or altFontFamily initialization parameters - either through diagram frontmatter syntax (%%{init: {...}}%%) embedded in user-supplied diagram text, or via application-level configuration that accepts user input for these fields. A victim user must passively view (render) the page containing the malicious diagram in a browser (CVSS UI:P). Exploitation is blocked if: the application sanitizes or strips diagram initialization options before rendering; securityLevel: sandbox is set (isolates rendering to an iframe); or the secure array config is set (prevents user override of the vulnerable parameters). The CVSS vector PR:N reflects that no account or authentication is required to supply diagram content in typical default-configured deployments.

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 securityLevel: sandbox workaround. The delta between CVSS 5.3 and actual organizational risk depends almost entirely on whether user-controlled diagram input reaches a renderer in default mode.

Exploit ScenarioDerived

An attacker submits a malicious Mermaid diagram containing a crafted fontFamily initialization parameter - for example %%{init: {"fontFamily": "x;a{b} :not(&){background:green !important} c{d}"}}%% - to a wiki or documentation platform that renders user-supplied diagram definitions. When any user views the page, the injected CSS bypasses stylis scoping and applies globally, defacing the page or using CSS :has() selectors to exfiltrate DOM attributes such as hidden form values or data attributes to an attacker-controlled endpoint. A working proof-of-concept is publicly accessible via the mermaid.live demo linked in the advisory.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – 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

mermaid < 10.9.6
mermaid 11.0.0-alpha.1, < 11.15.0

Affected Packages

npm mermaid fix: 10.9.6, 11.15.0
euvd mermaid_11_0_0_alpha_1 fix: 11.15.0

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

Vendor (https://github.com/mermaid-js/mermaid) PRIMARY 5.3 MEDIUM
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
vuln.today AI 6.1 MEDIUM

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.

3.1 AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
4.0 AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N
SUSE MEDIUM
Red Hat 5.4 MEDIUM

Primary rating from Vendor (https://github.com/mermaid-js/mermaid).

CVSS VectorVendor: https://github.com/mermaid-js/mermaid

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
Passive
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
Low
Vulnerable system: Availability
None
Subsequent system: Confidentiality
Low
Subsequent system: Integrity
Low
Subsequent system: Availability
Low

Lifecycle Timeline

2
CVSS changed
May 29, 2026 - 15:22 NVD
5.3 (MEDIUM)
CVE Published
May 11, 2026 - 19:37 nvd
MEDIUM

DescriptionCVE.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 --> B

The 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

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

EPSS Score
0.0%
Top 85% exploitable
Prevalence
Medium
widely used diagramming library in docs, wikis, and dev tools
Threat Intel
1
1 source
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS GHSA Vendor GitHub VulDB

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.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

26
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +26
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

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.

Vendor StatusVendor

SUSE

Severity: Medium

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy