CVE-2026-41149
JSON

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 packageVersionsReported by
mermaid-js mermaid>= 11.0.0-alpha.1, < 11.15.0, < 10.9.6CVE List
mermaid (npm)from 11.0.0-alpha.1 before 11.15.0, before 10.9.6GitHub Advisory Database

All scores

GitHub_M5.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:L
GitHubmedium CVSS:4.0CVSS: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

CWE-94

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

SourceRecordLicence
CVE ListCVE-2026-41149 changed 2026-05-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-ghcm-xqfw-q4vr changed 2026-09-10CC-BY-4.0
NVDCVE-2026-41149 changed 2026-07-23Public domain