{"id":"CVE-2026-41159","aliases":["CVE-2026-41159","GHSA-87f9-hvmw-gh4p"],"related":[],"kind":"vulnerability","state":"published","title":"Mermaid: Improper sanitization of configuration leads to CSS injection","summary":"Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Prior to 10.9.6 and 11.15.0,  Mermaid's default configuration allows injecting CSS that applies outside of the Mermaid diagram via the fontFamily, themeCSS, and altFontFamily configuration options. The injected CSS exploits stylis's & (scope reference) handling. :not(&) escapes the #mermaid-xxx automatic scoping, applying styles to all page elements. Global at-rules (@font-face, @keyframes, @counter-style) are also injectable as stylis hoists them to top level. This allows page defacement and DOM attribute exfiltration via CSS :has() selectors. This vulnerability is fixed in 10.9.6 and 11.15.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Prior to 10.9.6 and 11.15.0,  Mermaid's default configuration allows injecting CSS that applies outside of the Mermaid diagram via the fontFamily, themeCSS, and altFontFamily configuration options. The injected CSS exploits stylis's & (scope reference) handling. :not(&) escapes the #mermaid-xxx automatic scoping, applying styles to all page elements. Global at-rules (@font-face, @keyframes, @counter-style) are also injectable as stylis hoists them to top level. This allows page defacement and DOM attribute exfiltration via CSS :has() selectors. This vulnerability is fixed in 10.9.6 and 11.15.0.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nMermaid's default configuration allows injecting CSS that applies outside of the Mermaid diagram via the `fontFamily`, `themeCSS`, and `altFontFamily` configuration options.\n\nLive demo: [mermaid.live](https://mermaid.live/edit#pako:eNpNjktLxDAUhf9KvFBR6JS-60QQfODKlUvJ5k6TtsEmKTHFGUP-u-mI6Nmdy3fOPR56wwVQSBIvtXSUeAaD0e4ZlZxPDChhcLxFfwiEauOuLq_9Afv30ZpVczpaITS5kGox1qF2gfSeBwYhJAnThAyz-ewntI68vG5-0z3Z7e7IA9OQwmglB-rsKlJQwircLPgNZeAmocTPAi4GXGfHgOkQYwvqN2PUbzJuGSegA84f0a0LRyeeJI4W_xChubCPcbQD2pwbgHo4Aq2aKmvbqq3zoiu7pizqFE6RybN9VFfFY1HWXRVS-Dr_zLObrt7_V_gGGXZlGg)\n\nExample code:\n\n```\n%%{init: {\"fontFamily\": \"x;a{b} :not(&){background:green !important} c{d}\"}}%%\nflowchart LR\n    A --> B\n```\n\nThe injected CSS exploits stylis's `&` (scope reference) handling. `:not(&)` escapes the `#mermaid-xxx` automatic scoping, applying styles to all page elements. Global at-rules (`@font-face`, `@keyframes`, `@counter-style`) are also injectable as stylis hoists them to top level.\n\nThis allows page defacement and DOM attribute exfiltration via CSS `:has()` selectors.\n\n### Patches\n\n- [v11.15.0](https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.15.0) (see [64769738d5b59211e1decb471ffbaca8afec51aa](https://github.com/mermaid-js/mermaid/commit/64769738d5b59211e1decb471ffbaca8afec51aa))\n- [v10.9.6](https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6) (see [a9d9f0d8eb790349121508688cd338253fd80d76](https://github.com/mermaid-js/mermaid/commit/a9d9f0d8eb790349121508688cd338253fd80d76))\n\n### Workarounds\n\nIf you can't upgrade mermaid, you can set the [`secure`](https://mermaid.js.org/config/schema-docs/config.html#secure) config value in the mermaid config to avoid allowing diagrams to modify `fontFamily`, `themeCSS`, `altFontFamily`, and `themeVariables`.\n\nSetting [`\"securityLevel\": \"sandbox\"`](https://mermaid.js.org/config/schema-docs/config.html#securitylevel)  will also prevent this.\n\n### Credits\n\nReported by @zsxsoft on behalf of @KeenSecurityLab","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. Antes de las versiones 10.9.6 y 11.15.0, la configuración predeterminada de Mermaid permite inyectar CSS que se aplica fuera del diagrama de Mermaid a través de las opciones de configuración fontFamily, themeCSS y altFontFamily. El CSS inyectado explota el manejo de & (referencia de ámbito) de stylis. :not(&) escapa el alcance automático #mermaid-xxx, aplicando estilos a todos los elementos de la página. Las reglas globales at-rules (@font-face, @keyframes, @counter-style) también son inyectables, ya que stylis las eleva al nivel superior. Esto permite la desfiguración de la página y la exfiltración de atributos del DOM a través de selectores CSS :has(). Esta vulnerabilidad se corrige en las versiones 10.9.6 y 11.15.0.","source":"nvd"}],"published":"2026-05-11T19:37:00.000Z","modified":"2026-09-10T03:51:04.895Z","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"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"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"},{"ranges":[{"status":"affected","fixed":"10.9.6"},{"status":"affected","introduced":"11.0.0","fixed":"11.15.0"}],"vendor":"mermaid_project","product":"mermaid","cpe":"cpe:2.3:a:mermaid_project:mermaid:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/mermaid-js/mermaid/security/advisories/GHSA-87f9-hvmw-gh4p","tags":["third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/64769738d5b59211e1decb471ffbaca8afec51aa","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/a9d9f0d8eb790349121508688cd338253fd80d76","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/releases/tag/mermaid@11.15.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/releases/tag/v10.9.6","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41159","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"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-05-29T15:02:42.708Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-41159","url":"https://www.cve.org/CVERecord?id=CVE-2026-41159","licence":"CVE Terms of Use","modified":"2026-07-01T19:21:36.047Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-87f9-hvmw-gh4p","url":"https://github.com/advisories/GHSA-87f9-hvmw-gh4p","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:04.895Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-41159","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41159","licence":"Public domain","modified":"2026-07-21T12:10:00.090Z"}],"updatedAt":"2026-11-25T22:59:23.325Z","epss":{"score":0.00486,"percentile":0.43518,"date":"2026-12-01T12:00:22.000Z"}}