CVE-2026-41148

CVE-2026-41148 is a medium-severity code injection vulnerability in mermaid (npm), affecting versions >= 11.0.0-alpha.1, <= 11.14.0. It is fixed in 11.15.0, 10.9.6.

Summary

Details

The state diagram and any other diagram type that routes user-controlled style strings through createCssStyles parser for Mermaid v11.14.0 and earlier captures classDef values with an unrestricted regex:

// packages/mermaid/src/diagrams/state/parser/stateDiagram.jison:83
<CLASSDEFID>[^\n]*   { this.popState(); return 'CLASSDEF_STYLEOPTS' }

The value passes unsanitized through addStyleClass() -> createCssStyles() -> style.innerHTML (mermaidAPI.ts:418). A } in the value closes the generated CSS selector, and everything after becomes a new CSS rule on the page.

PoC

stateDiagram-v2 
      classDef x }*{ background-image: url("http://media.giphy.com/media/SggILpMXO7Xt6/giphy.gif")}

Live demo:
https://mermaid.live/edit#pako:eNpFjzFvgzAQhf-KdVNbEcBgMHhtlkqtOnSJKi8ONsYKBmRMlRTx3-skanvTfbp7996t0IxSAYPZC6_2Rmgn7O4rQ00v5nmvWnRG29OKjqI5aTcug9wZK7RiaHH9A4fO-4kliVXSiFibqbvEzWjvnHxo_fI6vR3e6cGXyX2qTcvhcYMItDMSmHeLisAqZ8UVYeUDQhx8p6ziwEIrhTtx4MNVM4nhcxztrywE0h2wVvRzoGWS_z_8rahBKvcckntgmN5OAFvhDIzUNCZZQXCR5nVaZkUEF2BVFpOcEkoxxhUuyRbB980yjStapKHqoKFlhvPtB7BFZEU

Workarounds

Setting "securityLevel": "sandbox" will prevent this, by rendering the mermaid diagram in a sandboxed <iframe>.

Impact

Enables page defacement, user tracking via url() callbacks, and DOM attribute exfiltration via CSS :has() selectors.

Untrusted input is evaluated as executable code within the application's runtime environment. Typical impact: arbitrary code execution within the application's privilege context.

Affected versions

mermaid (>= 11.0.0-alpha.1, <= 11.14.0) mermaid (<= 10.9.5)

Security releases

mermaid → 11.15.0 (npm) mermaid → 10.9.6 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

This has been patched in:

Frequently Asked Questions

  1. What is CVE-2026-41148? CVE-2026-41148 is a medium-severity code injection vulnerability in mermaid (npm), affecting versions >= 11.0.0-alpha.1, <= 11.14.0. It is fixed in 11.15.0, 10.9.6. Untrusted input is evaluated as executable code within the application's runtime environment.
  2. Which versions of mermaid are affected by CVE-2026-41148? mermaid (npm) versions >= 11.0.0-alpha.1, <= 11.14.0 is affected.
  3. Is there a fix for CVE-2026-41148? Yes. CVE-2026-41148 is fixed in 11.15.0, 10.9.6. Upgrade to this version or later.
  4. Is CVE-2026-41148 exploitable, and should I be worried? Whether CVE-2026-41148 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  5. What actually determines whether CVE-2026-41148 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  6. How do I fix CVE-2026-41148?
    • Upgrade mermaid to 11.15.0 or later
    • Upgrade mermaid to 10.9.6 or later

Other vulnerabilities in mermaid

CVE-2026-41159CVE-2026-41149CVE-2026-41148CVE-2025-54881CVE-2025-54880

Stop the waste.
Protect your environment with Kodem.