Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…
EPSS 0.3%top 74%

CVE-2026-41148: CWE-94: Improper Control of Generation of Code ('Code Injection') in mermaid-js mermaid

0
Medium
VulnerabilityCVE-2026-41148cvecve-2026-41148cwe-94
Published: 05/22/2026 (05/22/2026, 22:03:50 UTC)
Source: CVE Database V5
Vendor/Project: mermaid-js
Product: mermaid

Description

Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Versions 10.9.5 and prior, in addition to 11.0.0-alpha.1 through 11.12.0 are vulnerable to CSS injection through improper sanitization. The state diagram (and any other diagram type that routes user-controlled style strings through the createCssStyles parser) captures classDef values using an unrestricted regex that matches everything up to a newline. That value then flows unsanitized through addStyleClass() into createCssStyles() and is assigned to style.innerHTML, so a closing brace (}) in the value terminates the generated CSS selector and turns everything after it into a new CSS rule on the page. This enables page defacement, user tracking via url() callbacks, and DOM attribute exfiltration. This issue has been fixed in versions 10.9.6 and 11.15.0. If developers are unable to immediately upgrade, they can work around this issue by setting "securityLevel": "sandbox", which prevents the issue by rendering the mermaid diagram in a sandboxed <iframe>.

CVSS v4.0

Score 5.3medium

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
Passive
Vuln. Confidentiality
None
Vuln. Integrity
Low
Vuln. Availability
None
Subsq. Confidentiality
Low
Subsq. Integrity
Low
Subsq. Availability
Low
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

Affected software

mermaid-js/mermaid
pkg:npm/mermaid-js/mermaid
Affected versions
<10.9.6>=11.0.0 <=11.12.0

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 05/30/2026, 20:20:36 UTC

Technical Analysis

Mermaid-js mermaid versions <=10.9.5 and 11.0.0-alpha.1 through 11.12.0 suffer from a CSS injection vulnerability due to improper sanitization of classDef values routed through the createCssStyles parser. The vulnerability arises because the regex capturing classDef values is unrestricted and allows injection of closing braces, which terminate CSS selectors and inject new CSS rules. This can be exploited to perform page defacement, user tracking via CSS url() callbacks, and exfiltration of DOM attributes. The vulnerability is identified as CWE-94 (Improper Control of Generation of Code). It is fixed in versions 10.9.6 and 11.15.0. Developers unable to upgrade immediately can mitigate by enabling the "securityLevel": "sandbox" setting, which uses a sandboxed iframe for rendering.

Potential Impact

Exploitation of this vulnerability allows an attacker to inject arbitrary CSS into pages rendering mermaid diagrams, which can lead to visual defacement of the page, tracking users through CSS url() callbacks, and exfiltration of DOM attributes. The CVSS 4.0 base score is 5.3 (medium severity), reflecting network attack vector, low complexity, no privileges required, user interaction needed, and limited impact on confidentiality, integrity, and availability.

Mitigation Recommendations

A fix is available in mermaid versions 10.9.6 and 11.15.0. Users and developers should upgrade to these versions to remediate the vulnerability. If immediate upgrade is not feasible, setting the configuration option "securityLevel" to "sandbox" provides a temporary workaround by rendering diagrams inside a sandboxed iframe, preventing CSS injection exploitation.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2026-04-17T12:59:15.739Z
Cvss Version
4.0
State
PUBLISHED
Remediation Level
null

Threat ID: 6a10d8e4e1370fbb485de040

Added to database: 05/22/2026, 22:29:56 UTC

Last enriched: 05/30/2026, 20:20:36 UTC

Last updated: 07/31/2026, 19:22:58 UTC

Views: 115

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

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

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses