{"id":"CVE-2026-41149","aliases":["CVE-2026-41149","GHSA-ghcm-xqfw-q4vr"],"related":[],"kind":"vulnerability","state":"published","title":"Mermaid: Improper sanitization of `classDef` in state diagrams leads to HTML injection","summary":"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>.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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>.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nUnder the default configuration, Mermaid state diagram's `classDef` allow DOM injection that escapes the SVG, although `<script>` tags are removed, preventing XSS.\n\n#### Proof-of-concept\n\n```\nstateDiagram-v2\n  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\n  [*] --> A:::xss\n```\n\n### Patches\n\n- [v11.15.0](https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0) (see [37ff937f1da2e19f882fd1db01235db4d01f4056](https://github.com/mermaid-js/mermaid/commit/37ff937f1da2e19f882fd1db01235db4d01f4056))\n- [v10.9.6](https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6) (see [4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3](https://github.com/mermaid-js/mermaid/commit/4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3))\n\n### Workarounds\n\nIf you can not update to a patched version, 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>`.\n\n### Credits\n\nThanks to @zsxsoft from @KeenSecurityLab for reporting this vulnerability.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-05-11T19:36:46.000Z","modified":"2026-09-10T03:51:05.683Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","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","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","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","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","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","rating":"MEDIUM"}],"cwes":["CWE-94"],"affected":[{"ranges":[{"version":">= 11.0.0-alpha.1, < 11.15.0","status":"affected"},{"version":"< 10.9.6","status":"affected"}],"vendor":"mermaid-js","product":"mermaid","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"11.0.0-alpha.1","status":"affected","fixed":"11.15.0"}],"ecosystem":"npm","package":"mermaid","purl":"pkg:npm/mermaid","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"10.9.6"}],"ecosystem":"npm","package":"mermaid","purl":"pkg:npm/mermaid","source":"ghsa"}],"references":[{"url":"https://github.com/mermaid-js/mermaid/security/advisories/GHSA-ghcm-xqfw-q4vr","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/37ff937f1da2e19f882fd1db01235db4d01f4056","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/4e2d512bf5bf6f9de1a8f0a48da78dc4d09ac4f3","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41149","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mermaid-js/mermaid","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6","tags":["web"],"sources":["ghsa"]},{"url":"https://mermaid.js.org/config/schema-docs/config.html#securitylevel","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-05-23T03:21:57.740Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-41149","url":"https://www.cve.org/CVERecord?id=CVE-2026-41149","licence":"CVE Terms of Use","modified":"2026-05-23T03:22:44.013Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ghcm-xqfw-q4vr","url":"https://github.com/advisories/GHSA-ghcm-xqfw-q4vr","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:05.683Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-41149","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41149","licence":"Public domain","modified":"2026-07-23T11:10:00.120Z"}],"updatedAt":"2026-11-25T22:59:22.214Z","epss":{"score":0.00401,"percentile":0.36417,"date":"2026-12-01T12:00:22.000Z"}}