Mermaid: Improper sanitization of `classDef` in state diagrams leads to HTML injection
Moderate severity
GitHub Reviewed
Published
May 11, 2026
in
mermaid-js/mermaid
•
Updated May 12, 2026
Package
Affected versions
>= 11.0.0-alpha.1, <= 11.14.0
<= 10.9.5
Patched versions
11.15.0
10.9.6
Description
Published to the GitHub Advisory Database
May 11, 2026
Reviewed
May 11, 2026
Last updated
May 12, 2026
Impact
Under the default configuration, Mermaid state diagram's
classDefallow DOM injection that escapes the SVG, although<script>tags are removed, preventing XSS.Proof-of-concept
Patches
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.
References