Impact
An older Mermaid version allows injection of arbitrary CSS via the classDef directive. The bug stems from a regex that accepts any characters up to a newline, causing unsanitized CSS to be injected into the page’s DOM. This can deface the user interface, embed tracking callbacks, and exfiltrate DOM attributes. The vulnerability is a form of code injection described by CWE‑94, leading to potential compromise of the page’s integrity and confidentiality.
Affected Systems
The issue affects mermaid‑js:mermaid in versions 10.9.5 and earlier, as well as releases 11.0.0‑alpha.1 through 11.12.0. This includes all applications that embed Mermaid diagrams from untrusted input unless they upgrade to the fixed releases 10.9.6 or 11.15.0.
Risk and Exploitability
The CVSS score of 5.3 indicates moderate severity; no EPSS score is available, and it is not currently listed in the CISA KEV catalog. Attackers can exploit the flaw by supplying crafted Mermaid syntax that contains a closing brace and additional CSS, which can be delivered through any interface accepting diagram text, such as an editor or API. The vulnerability is mitigated by upgrading to a patched version or configuring the diagram engine with securityLevel set to sandbox, which renders the diagram in an isolated iframe and blocks the injection.
OpenCVE Enrichment
Github GHSA