5.3medium
Mermaid: Improper sanitization of `classDef` in state diagrams leads to HTML injection
- Severity
- 5.3medium CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.40% (higher than 36% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-ghcm-xqfw-q4vr
Description
Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Versions 10.9.5 and earlier, as well as 11.0.0-alpha.1 through 11.14.0, are vulnerable to HTML injection under the default configuration. Specifically, the classDef directive in Mermaid state diagrams permits DOM injection that escapes the SVG context. However, <script> tags are stripped, which prevents cross-site scripting (XSS). This issue has been fixed in versions 10.9.6 and 11.15.0. If developers are unable to immediately upgrade, they can work around this issue by setting "securityLevel": "sandbox", which prevents the issue by rendering the mermaid diagram in a sandboxed <iframe>.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| mermaid-js mermaid | >= 11.0.0-alpha.1, < 11.15.0, < 10.9.6 | CVE List |
| mermaid (npm) | from 11.0.0-alpha.1 before 11.15.0, before 10.9.6 | GitHub Advisory Database |
All scores
| GitHub_M | 5.3medium CVSS:4.0 | 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 |
| GitHub | medium CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Versions 10.9.5 and earlier, as well as 11.0.0-alpha.1 through 11.14.0, are vulnerable to HTML injection under the default configuration. Specifically, the classDef directive in Mermaid state diagrams permits DOM injection that escapes the SVG context. However, <script> tags are stripped, which prevents cross-site scripting (XSS). This issue has been fixed in versions 10.9.6 and 11.15.0. If developers are unable to immediately upgrade, they can work around this issue by setting "securityLevel": "sandbox", which prevents the issue by rendering the mermaid diagram in a sandboxed <iframe>.
GitHub Advisory Database
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:::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 <iframe>.
Credits
Thanks to @zsxsoft from @KeenSecurityLab for reporting this vulnerability.
NVD (es)
Mermaid es una herramienta de JavaScript que utiliza texto inspirado en Markdown para crear y modificar diagramas y gráficos. Las versiones 10.9.5 y anteriores, así como de la 11.0.0-alpha.1 a la 11.14.0, son vulnerables a la inyección de HTML bajo la configuración predeterminada. Específicamente, la directiva classDef en los diagramas de estado de Mermaid permite la inyección de DOM que escapa del contexto SVG. Sin embargo, las etiquetas <script> son eliminadas, lo que previene el cross-site scripting (XSS). Este problema ha sido solucionado en las versiones 10.9.6 y 11.15.0. Si los desarrolladores no pueden actualizar de inmediato, pueden solucionar este problema configurando 'securityLevel': 'sandbox', lo que previene el problema al renderizar el diagrama de mermaid en un <iframe> en un sandbox.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-41149 changed 2026-05-23 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-ghcm-xqfw-q4vr changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-41149 changed 2026-07-23 | Public domain |