CVE-2026-41148
Published:May 11, 2026
Updated:May 12, 2026
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" (https://mermaid.live/edit#pako:eNpFjzFvgzAQhf-KdVNbEcBgMHhtlkqtOnSJKi8ONsYKBmRMlRTx3-skanvTfbp7996t0IxSAYPZC6_2Rmgn7O4rQ00v5nmvWnRG29OKjqI5aTcug9wZK7RiaHH9A4fO-4kliVXSiFibqbvEzWjvnHxo_fI6vR3e6cGXyX2qTcvhcYMItDMSmHeLisAqZ8UVYeUDQhx8p6ziwEIrhTtx4MNVM4nhcxztrywE0h2wVvRzoGWS_z_8rahBKvcckntgmN5OAFvhDIzUNCZZQXCR5nVaZkUEF2BVFpOcEkoxxhUuyRbB980yjStapKHqoKFlhvPtB7BFZEU) Patches This has been patched in: - "v11.15.0" (https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0) (see "e9b0f34d8d82a6260077764ee45e1d7d90957a0f" (https://github.com/mermaid-js/mermaid/commit/e9b0f34d8d82a6260077764ee45e1d7d90957a0f)) - "v10.9.6" (https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6) (see "8fead23c59166b7bab6a39eac81acebee2859102" (https://github.com/mermaid-js/mermaid/commit/8fead23c59166b7bab6a39eac81acebee2859102)) Workarounds Setting """securityLevel": "sandbox""" (https://mermaid.js.org/config/schema-docs/config.html#securitylevel) 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.
Affected Packages
mermaid (CDN_JS):
Affected version(s) >=11.0.0-alpha.1 <11.15.0Fix Suggestion:
Update to version 11.15.0mermaid (CDN_JS):
Affected version(s) >=0.1.0 <10.9.6Fix Suggestion:
Update to version 10.9.6https://github.com/mermaid-js/mermaid.git (GITHUB):
Affected version(s) >=mermaid@11.0.1 <mermaid@11.15.0Fix Suggestion:
Update to version mermaid@11.15.0https://github.com/mermaid-js/mermaid.git (GITHUB):
Affected version(s) >=v10.9.0 <v10.9.6Fix Suggestion:
Update to version v10.9.6mermaid (NPM):
Affected version(s) >=11.0.0-alpha.1 <11.15.0Fix Suggestion:
Update to version 11.15.0mermaid (NPM):
Affected version(s) >=0.2.11 <10.9.6Fix Suggestion:
Update to version 10.9.6Related Resources (7)
Do you need more information?
Contact UsCVSS v4
Base Score:
5.3
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
CVSS v3
Base Score:
4.7
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
REQUIRED
Scope
CHANGED
Confidentiality
NONE
Integrity
LOW
Availability
NONE
Weakness Type (CWE)
Improper Control of Generation of Code ('Code Injection')