Mermaid CVE-2026-41149
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
ReconCraft stateDiagram-v2 with injected classDef payload
-
DeliverySubmit to platform rendering user-supplied diagrams
-
ExploitVictim browser loads page and triggers Mermaid rendering
-
InstallUnsanitized CSS value injects </style></svg> sequence
-
C2Injected HTML escapes SVG into parent document
-
ExecuteFull-viewport overlay renders over page content
-
ImpactVictim 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 |
| 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 |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – 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
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
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-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.
Primary rating from Vendor (https://github.com/mermaid-js/mermaid).
CVSS VectorVendor: https://github.com/mermaid-js/mermaid
Lifecycle Timeline
3DescriptionCVE.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:::xssPatches
- v11.15.0 (see 37ff937f1da2e19f882fd1db01235db4d01f4056)
- v10.9.6 (see 4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3)
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
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
Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.
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.
GHSA-ghcm-xqfw-q4vr
NVD
CVE.org
EPSS
Vulnrichment
VulDB
Exploit-DB