CVE-2026-41159: CWE-94: Improper Control of Generation of Code ('Code Injection') in mermaid-js mermaid
CVE-2026-41159 is a medium severity vulnerability in the mermaid-js mermaid JavaScript tool that allows CSS injection outside of Mermaid diagrams via certain configuration options. This occurs due to improper handling of CSS scoping in stylis, enabling attackers to apply styles globally on the page, potentially causing page defacement and DOM attribute exfiltration. The issue affects versions prior to 10. 9. 6 and versions from 11. 0. 0-alpha. 1 up to but not including 11. 15. 0.
AI Analysis
Technical Summary
Mermaid-js mermaid versions before 10.9.6 and between 11.0.0-alpha.1 and 11.15.0 have a vulnerability where the default configuration allows injection of CSS that escapes the intended scoping of Mermaid diagrams. This is due to stylis's handling of the '&' scope reference, specifically the use of ':not(&)', which bypasses the automatic scoping (#mermaid-xxx) and applies styles globally. Additionally, global at-rules like @font-face, @keyframes, and @counter-style can be injected because stylis hoists them to the top level. This vulnerability can lead to page defacement and exfiltration of DOM attributes via CSS :has() selectors. The vulnerability is identified as CWE-94 (Improper Control of Generation of Code).
Potential Impact
An attacker can inject CSS that affects the entire page outside the Mermaid diagram, potentially defacing the page or exfiltrating DOM attributes. This could impact the integrity and confidentiality of the web page content where Mermaid is used. The CVSS 4.0 score is 5.3 (medium severity), indicating a moderate risk with network attack vector, low complexity, no privileges required, and requiring user interaction.
Mitigation Recommendations
This vulnerability is fixed in mermaid versions 10.9.6 and 11.15.0. Users should upgrade to these or later versions to remediate the issue. Patch status is not explicitly stated in the vendor advisory content provided, but the description confirms the fix is included in these versions. No additional mitigation steps are indicated.
CVE-2026-41159: CWE-94: Improper Control of Generation of Code ('Code Injection') in mermaid-js mermaid
Description
CVE-2026-41159 is a medium severity vulnerability in the mermaid-js mermaid JavaScript tool that allows CSS injection outside of Mermaid diagrams via certain configuration options. This occurs due to improper handling of CSS scoping in stylis, enabling attackers to apply styles globally on the page, potentially causing page defacement and DOM attribute exfiltration. The issue affects versions prior to 10. 9. 6 and versions from 11. 0. 0-alpha. 1 up to but not including 11. 15. 0.
CVSS v4.0
Score 5.3medium
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Mermaid-js mermaid versions before 10.9.6 and between 11.0.0-alpha.1 and 11.15.0 have a vulnerability where the default configuration allows injection of CSS that escapes the intended scoping of Mermaid diagrams. This is due to stylis's handling of the '&' scope reference, specifically the use of ':not(&)', which bypasses the automatic scoping (#mermaid-xxx) and applies styles globally. Additionally, global at-rules like @font-face, @keyframes, and @counter-style can be injected because stylis hoists them to the top level. This vulnerability can lead to page defacement and exfiltration of DOM attributes via CSS :has() selectors. The vulnerability is identified as CWE-94 (Improper Control of Generation of Code).
Potential Impact
An attacker can inject CSS that affects the entire page outside the Mermaid diagram, potentially defacing the page or exfiltrating DOM attributes. This could impact the integrity and confidentiality of the web page content where Mermaid is used. The CVSS 4.0 score is 5.3 (medium severity), indicating a moderate risk with network attack vector, low complexity, no privileges required, and requiring user interaction.
Mitigation Recommendations
This vulnerability is fixed in mermaid versions 10.9.6 and 11.15.0. Users should upgrade to these or later versions to remediate the issue. Patch status is not explicitly stated in the vendor advisory content provided, but the description confirms the fix is included in these versions. No additional mitigation steps are indicated.
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: 5/29/2026, 2:48:45 PM
Last enriched: 5/29/2026, 3:03:58 PM
Last updated: 5/29/2026, 3:53:41 PM
Views: 4
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.