GitHub Advisoryadvisory · npm
GHSA-ghcm-xqfw-q4vr Mermaid: Improper sanitization of `classDef` in state diagrams leads to HTML injection
MEDIUM
Official page ↗
- Aliases
- CVE-2026-41149
- Ecosystem
- npm
- Packages
- mermaid
- Severity
- Moderate
- CVSS vector
- 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
- Weaknesses
- CWE-94
- Reviewed
- 2026-05-11
Affected packages
• npm mermaid: >= 11.0.0-alpha.1, < 11.15.0 → fixed in 11.15.0
• npm mermaid: < 10.9.6 → fixed in 10.9.6
Description
Impact
Under the default configuration, Mermaid state diagram's `classDef` allow DOM injection that escapes the SVG, although `` tags are removed, preventing XSS.
Proof-of-concept
```
stateDiagram-v2
classDef xss fill:red*{x:x;y:y;overflow:visible!important;contain:none!important;transform:none!important;filter:none!important;clip-path:none!important}HACKEDa:b
[*] --> A:::xss
```
Patches
• 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 ``.
Credits
Thanks to @zsxsoft from @KeenSecurityLab for reporting this vulnerability.
Related
Alias · CVE (1)
- CVE-2026-41149 Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. vulnerability
Weakness · CWE (1)
- CWE-94 Improper Control of Generation of Code weakness
References
- https://github.com/mermaid-js/mermaid/security/advisories/GHSA-ghcm-xqfw-q4vr web
- https://nvd.nist.gov/vuln/detail/CVE-2026-41149 advisory
- https://github.com/mermaid-js/mermaid/commit/37ff937f1da2e19f882fd1db01235db4d01f4056 web
- https://github.com/mermaid-js/mermaid/commit/4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3 web
- https://github.com/mermaid-js/mermaid package
- https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0 web
- https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6 web
- https://mermaid.js.org/config/schema-docs/config.html#securitylevel web