CVE-2026-26226
SVG Attribute Injection XSS in beautiful-mermaid Before
Publication date: 2026-02-13
Last updated on: 2026-02-13
Assigner: VulnCheck
Description
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| Vendor | Product | Version / Range |
|---|---|---|
| lukilabs | beautiful-mermaid | to 0.1.3 (exc) |
Helpful Resources
Exploitability
| CWE ID | Description |
|---|---|
| CWE-79 | The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. |
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?
CVE-2026-26226 is an SVG attribute injection vulnerability in versions of the beautiful-mermaid library prior to 0.1.3. The issue occurs because user-controlled input from Mermaid diagram directives such as style and classDef is directly inserted into SVG attribute values without proper escaping. This allows an attacker to craft malicious Mermaid diagrams that break out of the intended attribute context and inject arbitrary SVG elements or attributes.
When the generated SVG is embedded in a web page, this injection can lead to cross-site scripting (XSS), enabling script execution in the context of the embedding origin. The vulnerability arises mainly from unescaped inline style properties like fill, stroke, stroke-width, and color, which can be manipulated to inject malicious payloads such as event handlers (e.g., onload) that execute JavaScript.
How can this vulnerability impact me? :
This vulnerability can impact you by allowing attackers to execute arbitrary scripts in the context of your web application if you embed Mermaid-generated SVG diagrams that contain maliciously crafted style or classDef directives.
Such script execution can lead to a range of security issues including theft of user credentials, session hijacking, unauthorized actions on behalf of users, and exposure of sensitive information.
Because the vulnerability involves injection into SVG attributes, attackers can bypass typical text escaping protections and inject event handlers or other malicious SVG elements that trigger code execution when the SVG is rendered.
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:
I don't know
How can this vulnerability be detected on my network or system? Can you suggest some commands?
[{'type': 'paragraph', 'content': 'To detect this vulnerability, you can deploy the vulnerable beautiful-mermaid application with XSS test payloads targeting the style directive injection and observe if the SVG output allows script execution. The vulnerability manifests when user-controlled style or classDef directives inject malicious SVG attributes that execute scripts.'}, {'type': 'paragraph', 'content': 'A practical approach is to test Mermaid diagrams containing crafted style directives such as: style="fill:#f00" onload="alert(1)" and check if the rendered SVG includes unescaped attributes that trigger script execution.'}, {'type': 'paragraph', 'content': 'The security report recommends deploying the vulnerable app to a platform like Vercel and using a Browser Agent to inject XSS payloads and validate exploitability live.'}, {'type': 'paragraph', 'content': 'While no specific network commands are provided, you can scan your web application logs or monitor rendered SVG outputs for suspicious attributes like onload or script event handlers embedded in SVG elements.'}] [1]
What immediate steps should I take to mitigate this vulnerability?
The primary mitigation is to upgrade the beautiful-mermaid library to version 0.1.3 or later, where the vulnerability is fixed by properly escaping inline style values to prevent SVG attribute injection.
The fix involves applying an escapeXml() function to all inline style properties such as fill, stroke, stroke-width, and color before inserting them into SVG output, preventing attribute breakout and script injection.
Additional recommended mitigations include implementing Content Security Policy (CSP) headers to restrict script execution and using input validation or sanitization libraries like DOMPurify to clean user-controlled inputs before rendering.