CVE-2026-41159: CWE-94: Improper Control of Generation of Code ('Code Injection') in mermaid-js mermaid
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.
AI Analysis
Technical Summary
Mermaid-js mermaid versions before 10.9.6 and 11.15.0 have a vulnerability where the default configuration permits injection of CSS that escapes the intended Mermaid diagram scope. This is due to stylis's handling of the '&' scope reference, specifically the use of ':not(&)', which bypasses the automatic scoping of styles to the Mermaid container. Additionally, global CSS at-rules like @font-face, @keyframes, and @counter-style can be injected because stylis hoists them to the top level. Exploitation can result in page defacement and exfiltration of DOM attributes via CSS :has() selectors. The issue is classified as CWE-94 (Improper Control of Generation of Code).
Potential Impact
The vulnerability allows an attacker to inject CSS that affects the entire webpage, not just the Mermaid diagram, potentially leading to visual defacement and unauthorized exfiltration of DOM attributes. This can undermine the integrity and confidentiality of the affected web pages. The CVSS 4.0 score is 5.3 (medium), reflecting network attack vector, low complexity, no privileges required, user interaction needed, and limited impact on confidentiality and integrity.
Mitigation Recommendations
This vulnerability is fixed in mermaid versions 10.9.6 and 11.15.0. Users should upgrade to at least version 10.9.6 or later to remediate this issue. No other mitigation or temporary workaround is indicated in the available data.
CVE-2026-41159: CWE-94: Improper Control of Generation of Code ('Code Injection') in mermaid-js mermaid
Description
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.
CVSS v4.0
Score 5.3medium
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Mermaid-js mermaid versions before 10.9.6 and 11.15.0 have a vulnerability where the default configuration permits injection of CSS that escapes the intended Mermaid diagram scope. This is due to stylis's handling of the '&' scope reference, specifically the use of ':not(&)', which bypasses the automatic scoping of styles to the Mermaid container. Additionally, global CSS at-rules like @font-face, @keyframes, and @counter-style can be injected because stylis hoists them to the top level. Exploitation can result in page defacement and exfiltration of DOM attributes via CSS :has() selectors. The issue is classified as CWE-94 (Improper Control of Generation of Code).
Potential Impact
The vulnerability allows an attacker to inject CSS that affects the entire webpage, not just the Mermaid diagram, potentially leading to visual defacement and unauthorized exfiltration of DOM attributes. This can undermine the integrity and confidentiality of the affected web pages. The CVSS 4.0 score is 5.3 (medium), reflecting network attack vector, low complexity, no privileges required, user interaction needed, and limited impact on confidentiality and integrity.
Mitigation Recommendations
This vulnerability is fixed in mermaid versions 10.9.6 and 11.15.0. Users should upgrade to at least version 10.9.6 or later to remediate this issue. No other mitigation or temporary workaround is indicated in the available data.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-04-17T16:34:45.524Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a19a74de29bf47b50f00d47
Added to database: 05/29/2026, 14:48:45 UTC
Last enriched: 07/01/2026, 21:22:00 UTC
Last updated: 07/31/2026, 19:22:58 UTC
Views: 87
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.