Skip to main content

Mermaid CVE-2026-41149

MEDIUM
Code Injection (CWE-94)
2026-05-11 https://github.com/mermaid-js/mermaid GHSA-ghcm-xqfw-q4vr
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. Recon
    Craft stateDiagram-v2 with injected classDef payload
  2. Delivery
    Submit to platform rendering user-supplied diagrams
  3. Exploit
    Victim browser loads page and triggers Mermaid rendering
  4. Install
    Unsanitized CSS value injects </style></svg> sequence
  5. C2
    Injected HTML escapes SVG into parent document
  6. Execute
    Full-viewport overlay renders over page content
  7. Impact
    Victim exposed to attacker-controlled UI

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 three concurrent conditions: (1) the target application renders Mermaid state diagrams under the default securityLevel configuration - not "sandbox" or "strict" mode; (2) untrusted users can supply or influence the diagram source text that is subsequently rendered in a victim's browser; and (3) the victim's browser renders the page containing the malicious diagram. Exploitation is NOT possible when securityLevel is set to "sandbox" (iframe isolation prevents SVG-to-parent DOM escape) or when diagram source is fully controlled by trusted parties. JavaScript execution is blocked by existing <script> tag stripping, limiting impact to HTML/CSS DOM injection without script execution. The SSVC 'not automatable' designation confirms that mass exploitation is not achievable without a platform-level delivery mechanism targeting specific rendering contexts.

Impact

The CVSS 4.0 score of 5.3 (Medium) is reasonable given AV:N/PR:N (no authentication barrier) offset by UI:P (passive victim interaction required to render the diagram) and partial impact metrics. EPSS at 0.04% (14th percentile) reflects very low current exploitation probability, consistent with the absence of a CISA KEV listing. SSVC categorizes exploitation as 'poc' and automatable as 'no,' meaning this vulnerability cannot be mass-exploited without a social or platform delivery mechanism - the attacker must induce a specific victim to render a malicious diagram. The real-world risk is highest for collaborative platforms that render user-supplied Mermaid source (wikis, documentation sites, CI/CD dashboards, GitHub-adjacent tools) where the injected full-viewport overlay enables convincing phishing overlays or clickjacking. The 'RCE' tag present in the source metadata is not supported by the advisory - this is DOM/HTML injection only, and JavaScript execution via script tags is confirmed blocked. Despite the partial impact ceiling, the visual severity of the PoC (full-page black overlay reading 'HACKED') makes this a credible social engineering vector on affected platforms.

Exploit ScenarioDerived

An attacker submits a crafted stateDiagram-v2 containing a classDef whose CSS value embeds </style></svg> to escape SVG context, followed by a full-viewport <div> overlay styled with position:fixed; z-index:2147483647 that covers the entire page with attacker-controlled content. When a victim views the page on a wiki or documentation platform that renders user-submitted Mermaid diagrams using the default securityLevel, the injected HTML renders over all page content, enabling phishing credential capture or UI redressing. A working proof-of-concept producing this effect is published in the GitHub Security Advisory GHSA-ghcm-xqfw-q4vr.

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

HTML injection in Mermaid's state diagram classDef parser allows escape from the SVG rendering context into the parent document DOM, affecting npm/mermaid through v11.14.0 and through v10.9.5 under the default securityLevel configuration. By embedding SVG/style-closing sequences inside CSS property values, an attacker can inject arbitrary HTML and CSS that overlays the full browser viewport - enabling UI redressing and phishing-style attacks on any platform that renders user-supplied diagrams. A public proof-of-concept is available per SSVC assessment; however, <script> tag stripping is confirmed to prevent classic XSS, and no CISA KEV active exploitation has been recorded.

RemediationAI

Upgrade the npm/mermaid package to v11.15.0 for consumers on the v11 branch, or to v10.9.6 for consumers on the v10 branch; these are the vendor-confirmed fixed versions per the GitHub Security Advisory. The v11 patch commit is https://github.com/mermaid-js/mermaid/commit/37ff937f1da2e19f882fd1db01235db4d01f4056 and the v10 patch commit is https://github.com/mermaid-js/mermaid/commit/4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3. If immediate upgrade is not feasible, set the Mermaid configuration option securityLevel to "sandbox" (documented at https://mermaid.js.org/config/schema-docs/config.html#securitylevel), which renders diagrams inside a sandboxed <iframe>, containing any injection within the iframe boundary and preventing DOM escape into the parent document. Note that sandbox mode may restrict cross-frame interactivity and some Mermaid features that rely on parent-document access - validate application behavior after enabling this option.

Affected Packages

npm mermaid fix: 10.9.6, 11.15.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in npm

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Mermaid (npm/mermaid) is a JavaScript library that parses text-based diagram definitions and renders them as inline SVG in the browser. The vulnerability resides in the state diagram renderer's handling of classDef directives, which define named CSS classes applied to diagram nodes via syntax like classDef className fill:color. The library interpolated user-supplied CSS property values directly into SVG markup as raw strings rather than through the browser's CSSOM API, allowing injection of closing tag sequences such as </style></svg> that terminate the SVG context and permit arbitrary HTML insertion into the parent document. The fix (commit 37ff937f for v11, 4e2d512b for v10) replaces string-based CSS generation with CSSOM manipulation - setting CSS properties programmatically via JavaScript rather than innerHTML-style string injection - which structurally eliminates this injection class. CWE-94 (Improper Control of Generation of Code) applies: user input is reflected into a generated markup context without sanitization.

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

Network-delivered injection requires passive user rendering (UI:R); injection escapes SVG into parent document context (S:C); limited integrity impact only, no confidentiality or availability impact.

3.1 AV:N/AC:L/PR:N/UI:R/S:C/C:N/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:L
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

3
CVSS changed
May 26, 2026 - 19:37 NVD
5.3 (MEDIUM)
CVE Published
May 11, 2026 - 19:36 cve.org
MEDIUM 5.3
CVE Published
May 11, 2026 - 19:36 nvd
MEDIUM

DescriptionCVE.org

Impact

Under the default configuration, Mermaid state diagram's classDef allow DOM injection that escapes the SVG, although <script> tags are removed, preventing XSS.

Proof-of-concept
stateDiagram-v2
  classDef xss fill:red</style></svg><style>*{x:x;y:y;overflow:visible!important;contain:none!important;transform:none!important;filter:none!important;clip-path:none!important}</style><div style="x:x;y:y;color:red;font:5em/1 monospace;display:grid;place-items:center;z-index:2147483647;width:100vw;height:100vh;position:fixed;top:0;left:0;background:black">HACKED</div><svg><style>a:b
  [*] --> A:::xss

Patches

Workarounds

If you can not update to a patched version, setting "securityLevel": "sandbox" will prevent this, by rendering the mermaid diagram in a sandboxed <iframe>.

Credits

Thanks to @zsxsoft from @KeenSecurityLab for reporting this vulnerability.

Threat Intelligence Overview

EPSS Score
0.0%
Top 86% exploitable
Prevalence
High
widely embedded JS diagramming library in wikis, docs, and CI platforms
Threat Intel
1
1 source
Data Quality
7 sources
Confidence: High
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.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
Poc
System Exposure· derived
Open
Automatable
No
Human Impact· derived
High
Technical Impact
Partial

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

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

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.

Affected Products (CPE)CVE.org

pkg:npm/mermaid
pkg:npm/mermaid

Vendor StatusVendor

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