Skip to main content

Mermaid CVE-2026-50159

| EUVDEUVD-2026-54243 MEDIUM
Code Injection (CWE-94)
2026-08-06 https://github.com/mermaid-js/mermaid GHSA-6x64-9x62-f2gx
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
    Supply malicious themeCSS in diagram source
  2. Delivery
    Mermaid compileCSS expands sibling combinator to page scope
  3. Exploit
    CSS rules escape SVG container
  4. Execution
    Styles applied to sibling DOM elements
  5. Impact
    Attacker-controlled visual overlay rendered on host page

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 two simultaneous conditions: first, the application must render user-supplied Mermaid diagram source that includes attacker-controlled CSS properties - specifically via themeCSS, fontFamily, altFontFamily, or themeVariables config fields in the diagram definition; second, the rendered Mermaid <svg> element must have one or more sibling DOM elements in its parent container (i.e., it is not the only child). Default Mermaid integration via mermaid.run() or mermaid.initialize() places the SVG as an only child, which directly prevents exploitation - the vendor explicitly states 'most users of mermaid would not be affected.' Exploitation is limited to deployments where developers manually insert the SVG output into the DOM in a shared container. JavaScript execution is not achievable via this vector regardless of configuration. Authentication requirements are not confirmed from available data as no CVSS vector is provided.

Impact

No CVSS vector was provided with this CVE, so all metric assessments are inferred. The vulnerability is not listed in CISA KEV and no public exploit tooling exists, though the advisory publishes a functional proof-of-concept CSS payload. EPSS data is not available. Real-world risk is meaningfully constrained by the exploitation precondition: the SVG must have sibling DOM elements, which is explicitly a non-default condition - standard use of mermaid.run() or mermaid.initialize() places the SVG as an only child, blocking exploitation. This significantly narrows the affected population to applications that manually insert Mermaid SVG output into the DOM alongside other content. The impact ceiling is also bounded: no JavaScript execution, no session hijacking, no data exfiltration beyond conditional CSS-based probing. Risk is relevant to documentation platforms, wikis, or collaboration tools rendering untrusted Mermaid input, but is substantially lower than the 'RCE' tag suggests. The tag labeling in the source intelligence appears to be erroneous and should not drive prioritization.

Exploit ScenarioDerived

An attacker submits a Mermaid diagram with a malicious themeCSS value - for example, & + * { position:fixed !important; inset:0 !important; background:red !important; width:100vw !important; height:100vh !important; } - to a platform that renders user-provided diagrams and inserts the SVG adjacent to page content. The sibling combinator in the injected CSS expands to target the next DOM sibling of the SVG, overlaying the entire page viewport with attacker-controlled styling, enabling phishing-style visual deception or suppression of legitimate page content. A functional proof-of-concept payload demonstrating this exact attack is published in the GitHub security advisory.

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

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

Alert me

AnalysisAIv1 – Aug 06, 2026

CSS injection in the Mermaid JavaScript diagramming library (npm) allows sibling CSS combinators (~ and +) to escape the diagram's SVG container and apply attacker-controlled styles to adjacent DOM elements on the host page. Affected are applications using Mermaid below v11.16.1 or below v10.9.8 that render user-supplied diagram source and where the SVG element has sibling nodes in the DOM - a non-default condition. An attacker supplying malicious diagram content can perform UI redressing, hide legitimate page content, or create phishing-style visual overlays; the vendor explicitly confirms JavaScript execution is not possible via this vector. No public exploit tool is identified at time of analysis, though a working proof-of-concept payload is embedded in the GitHub security advisory.

RemediationAI

Upgrade to Mermaid v11.16.1 (v11 users) or v10.9.8 (v10 users); release pages are at https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.16.1 and https://github.com/mermaid-js/mermaid/releases/tag/v10.9.8 respectively. The underlying fix is in commits 12d472c9ed43f94814b110da8d7a9ae6dd5266ed (v11) and 7e83f1533318b307764d961906a73377266f4c5e (v10). If upgrading is not immediately possible, three workarounds are available with no known functional side effects: (1) wrap any manually-inserted Mermaid SVG in a dedicated container with no other children (e.g., <div><svg>...</svg></div>) - this is the lowest-overhead mitigation and directly eliminates the sibling selector escape path; (2) replace manual SVG insertion with mermaid.run() or mermaid.initialize(), which apply the wrapper automatically; or (3) set securityLevel: 'sandbox' in Mermaid config to enforce stronger isolation, noting this may restrict some diagram theming features, or set the secure config key to block user-controlled themeCSS, fontFamily, altFontFamily, and themeVariables properties specifically.

Affected VersionsENISA

mermaid < 10.9.8
mermaid 11.0.0-alpha.1, < 11.16.1

Affected Packages

npm mermaid fix: 10.9.8, 11.16.1
euvd mermaid_11_0_0_alpha_1 fix: 11.16.1

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 widely-used JavaScript library that converts diagram syntax into SVG rendered in the browser. Its compileCSS middleware scopes all CSS rules to the diagram's SVG by prefixing selectors with the element's unique ID (e.g., #mermaid-123). However, CSS nesting syntax causes sibling combinators to expand unexpectedly: & ~ * { ... } becomes #svgId ~ *, a valid selector that targets all DOM elements following the SVG - outside the diagram boundary entirely. CWE-94 (Improper Control of Generation of Code) is the assigned root cause class, reflecting that user-controlled diagram input influences CSS generation in a way that escapes the intended scope. The fix in PR #8022 (commit 12d472c9) addresses the sibling combinator handling in compileCSS. Note that input metadata tags this as 'RCE,' which is explicitly contradicted by the advisory stating JavaScript execution is not achievable through this vector.

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 5.4 MEDIUM

AV:N as diagram is submitted over the network; AC:H because exploitation requires non-default SVG-sibling DOM layout; S:C as CSS escapes SVG scope to host page; no availability impact.

3.1 AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N
4.0 AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N
SUSE MEDIUM
Red Hat 4.3 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

1
CVSS changed
Aug 06, 2026 - 22:22 NVD
5.3 (MEDIUM)

DescriptionCVE.org

Summary

Mermaid does not fully restrict CSS to the rendered SVG subtree. Although selectors are prefixed with #mermaid-X, sibling (~ and +) combinators can still escape the Mermaid container and inject styles to DOM elements adjacent to the diagram <svg>.

Most users of mermaid would not be affected by this, as mermaid adds its <svg> as an only child of it's parent element. However, you may be affected if you manually insert the <svg> (or other elements) into the DOM yourself.

Details

Mermaid namespaces CSS through with a middleware intended to scope all rules to the diagram's SVG element. CSS nesting expands & ~ * { ... } to #svgId ~ *, which selects all sibling elements following the SVG in the DOM, outside the diagram boundary.

Impact

An attacker able to supply diagram source to a page (e.g., user-generated content rendered by Mermaid) could inject CSS rules affecting sibling elements to the diagram <svg> on the host page. This can be used for UI redressing, hiding content, conditional CSS-based probing, or phishing-style visual manipulation.

JavaScript execution is not possible via this vector.

Patches

This has been patched in https://github.com/mermaid-js/mermaid/commit/12d472c9ed43f94814b110da8d7a9ae6dd5266ed and released in Mermaid v11.16.1.

A backport has been made for the v10 branch in 7e83f1533318b307764d961906a73377266f4c5e and was released in Mermaid v10.9.8

Workarounds

If you are inserting the <svg> into the DOM yourself, you can wrap it in an element with no other children, e.g. <div><svg>...</svg></div> or element.innerHTML = svg. Alternatively, you can use mermaid.run() or mermaid.initialize() which will do this for you.

Setting "securityLevel": "sandbox" will also prevent this, or setting the secure config value in the mermaid config to avoid allowing diagrams to modify fontFamily, themeCSS, altFontFamily, and themeVariables.

To test, you can try using a themeCSS with & + * { /* my CSS here */} and see if it's applied outside of your mermaid <svg>.

mermaid-example
---
config:
  themeCSS: |-
    & + * { background:red !important; width:100vw !important; height:100vh !important; position:fixed !important; inset:0 !important; }
---
info

References

  • GHSA-87f9-hvmw-gh4p/CVE-2026-41159 (related vulnerability)
  • https://github.com/mermaid-js/mermaid/commit/12d472c9ed43f94814b110da8d7a9ae6dd5266ed
  • https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.16.1
  • https://github.com/mermaid-js/mermaid/commit/7e83f1533318b307764d961906a73377266f4c5e
  • https://github.com/mermaid-js/mermaid/releases/tag/v10.9.8

Threat Intelligence Overview

EPSS Score
0.6%
Top 56% exploitable
Prevalence
Medium
popular JavaScript diagramming library used in documentation platforms and wikis
Threat Intel
1
1 sources
Data Quality
8 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment 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.6%
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
None
System Exposure· derived
Open
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

27
Low Medium High Critical
KEV: 0
EPSS: +1
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: Moderate

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