Mermaid CVE-2026-41148
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSubmit diagram with malicious classDef value
-
DeliveryJison regex captures string without restriction
-
ExploitString passed unsanitized to style.innerHTML
-
ExecutionInjected `}` closes CSS selector, appending attacker-controlled rules
-
PersistVictim loads page, browser applies injected CSS
-
ImpactCSS url() callbacks or :has() selectors exfiltrate DOM data to attacker server
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 Mermaid diagrams from user-controlled input and has not configured |
| Impact | The CVSS 4.0 score of 5.3 (Medium) correctly characterizes the bounded impact: the attack is network-accessible with no authentication required and low complexity, but requires a victim to view the rendered diagram (UI:P), and the direct impact is limited to low-integrity modification of the vulnerable system and low subsequent-system integrity/confidentiality effects. EPSS at 0.06% (18th percentile) indicates low observed exploitation probability, consistent with no KEV listing. However, a functional public PoC with a live demo is confirmed, which meaningfully lowers the bar for exploitation beyond what the low EPSS implies - EPSS reflects historical scanning patterns, not manual exploitation scenarios. The intelligence feed tags this as 'RCE', which appears to be a mislabeling; confirmed impact is CSS injection with no JavaScript execution pathway. Real-world risk is highest for platforms that render user-supplied Mermaid diagrams without sandboxing (wikis, documentation sites, collaborative tools), where CSS |
| Exploit ScenarioDerived | An attacker submits a Mermaid diagram containing |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jul 23, 2026
CSS injection in Mermaid's diagram rendering engine (npm/mermaid v11.14.0 and earlier, v10.9.5 and earlier) allows attackers who can supply diagram input to inject arbitrary CSS rules into the host page. The flaw exists because classDef style strings are captured by an unrestricted Jison regex and written unsanitized to style.innerHTML, enabling page defacement, user tracking via CSS url() callbacks, and DOM attribute exfiltration via CSS :has() selectors. A public proof-of-concept with a live demo is confirmed in the GHSA advisory; no CISA KEV listing at time of analysis.
RemediationAI
Upgrade to Mermaid v11.15.0 (commit e9b0f34d8d82a6260077764ee45e1d7d90957a0f) or v10.9.6 (commit 8fead23c59166b7bab6a39eac81acebee2859102) per the release pages at https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0 and https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6. If immediate patching is not feasible, set "securityLevel": "sandbox" in the Mermaid configuration (documented at https://mermaid.js.org/config/schema-docs/config.html#securitylevel), which renders diagrams inside a sandboxed <iframe> and fully prevents injected CSS from reaching the host page; note this changes rendering behavior and may break integrations that depend on parent-page stylesheet access. No other confirmed compensating controls are available from the advisory data.
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 uses a Jison-based parser for state diagrams (stateDiagram.jison:83) where the rule <CLASSDEFID>[^\n]* captures any content on the line following a classDef keyword without restriction. The captured value flows unsanitized through addStyleClass() → createCssStyles() → assignment to style.innerHTML in mermaidAPI.ts:418. Because the string is interpolated directly into a CSS rule, injecting a } character terminates the generated selector block and allows arbitrary CSS rules to be appended to the host page's stylesheet. This affects state diagrams and any other diagram type that routes user-controlled style strings through createCssStyles. CWE-94 (Improper Control of Generation of Code) is the root cause class; the specific manifestation is CSS injection rather than script execution. The affected packages are pkg:npm/mermaid across both the v10 and v11 release branches.
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-accessible with no auth (PR:N), requires victim to view the diagram page (UI:R), and scope changes (S:C) as injected CSS escapes the diagram component to affect the host page; CSS exfiltration yields low confidentiality and integrity impact.
Primary rating from Vendor (https://github.com/mermaid-js/mermaid).
CVSS VectorVendor: https://github.com/mermaid-js/mermaid
Lifecycle Timeline
2DescriptionCVE.org
Details
The state diagram and any other diagram type that routes user-controlled style strings through createCssStyles parser for Mermaid v11.14.0 and earlier captures classDef values with an unrestricted regex:
// packages/mermaid/src/diagrams/state/parser/stateDiagram.jison:83
<CLASSDEFID>[^\n]* { this.popState(); return 'CLASSDEF_STYLEOPTS' }The value passes unsanitized through addStyleClass() -> createCssStyles() -> style.innerHTML (mermaidAPI.ts:418). A } in the value closes the generated CSS selector, and everything after becomes a new CSS rule on the page.
PoC
stateDiagram-v2
classDef x }*{ background-image: url("http://media.giphy.com/media/SggILpMXO7Xt6/giphy.gif")}Live demo: <https://mermaid.live/edit#pako:eNpFjzFvgzAQhf-KdVNbEcBgMHhtlkqtOnSJKi8ONsYKBmRMlRTx3-skanvTfbp7996t0IxSAYPZC6_2Rmgn7O4rQ00v5nmvWnRG29OKjqI5aTcug9wZK7RiaHH9A4fO-4kliVXSiFibqbvEzWjvnHxo_fI6vR3e6cGXyX2qTcvhcYMItDMSmHeLisAqZ8UVYeUDQhx8p6ziwEIrhTtx4MNVM4nhcxztrywE0h2wVvRzoGWS_z_8rahBKvcckntgmN5OAFvhDIzUNCZZQXCR5nVaZkUEF2BVFpOcEkoxxhUuyRbB980yjStapKHqoKFlhvPtB7BFZEU>
Patches
This has been patched in:
- v11.15.0 (see e9b0f34d8d82a6260077764ee45e1d7d90957a0f)
- v10.9.6 (see 8fead23c59166b7bab6a39eac81acebee2859102)
Workarounds
Setting "securityLevel": "sandbox" will prevent this, by rendering the mermaid diagram in a sandboxed <iframe>.
Impact
Enables page defacement, user tracking via url() callbacks, and DOM attribute exfiltration via CSS :has() selectors.
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.
GHSA-xcj9-5m2h-648r
NVD
CVE.org
EPSS
VulDB
Exploit-DB