CVE-2026-26226: 
JavaScript vulnerability analysis and mitigation

Overview

CVE-2026-26226 is an SVG attribute injection vulnerability in the beautiful-mermaid npm package (versions prior to 0.1.3) that can lead to cross-site scripting (XSS) when rendering attacker-controlled Mermaid diagrams. User-controlled values from Mermaid style and classDef directives are interpolated into SVG attribute values without proper escaping, allowing crafted input to break out of an attribute context and inject arbitrary SVG elements or attributes. The vulnerability was disclosed and patched on February 13, 2026, with the fix merged on January 29, 2026. It carries a CVSS v4.0 base score of 5.3 (Medium) (GitHub Advisory).

Technical details

The root cause is CWE-79 (Improper Neutralization of Input During Web Page Generation — Cross-site Scripting): the library directly interpolates user-supplied values from Mermaid style and classDef directives into SVG attribute strings without applying XML/HTML escaping. An attacker can craft a Mermaid diagram where a style value contains a quote character (") followed by /> to close the current SVG attribute and element, then inject arbitrary SVG markup — including event handlers or <script> elements — into the rendered output. The fix applied escapeXml() to all four inlineStyle properties (fill, stroke, stroke-width, color) before they are written into SVG output. No privileges are required and the only precondition is that the application renders attacker-controlled Mermaid diagram input (GitHub Advisory, PR #8).

Impact

When a vulnerable application embeds the generated SVG in a web page, successful exploitation results in arbitrary script execution in the context of the embedding origin, enabling session hijacking, credential theft, malware distribution, or unauthorized actions on behalf of the victim user. Both confidentiality and integrity of the vulnerable and subsequent systems are impacted at a low level, while availability is unaffected. The scope of impact is limited to users who view pages where attacker-controlled Mermaid diagrams are rendered (GitHub Advisory).

Exploitability

There is no public proof-of-concept exploit and no evidence of in-the-wild exploitation at this time (GitHub Advisory). The EPSS score is approximately 0.071% (0.000710), indicating a low near-term exploitation probability. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. No threat actor attribution has been reported.

Exploitation steps

  1. Identify a target application: Find a web application that uses the beautiful-mermaid npm package (version < 0.1.3) and allows users to supply or influence Mermaid diagram source code that is then rendered and embedded as SVG in a web page.
  2. Craft a malicious Mermaid diagram: Construct a diagram using a style directive where the style value contains a double-quote to break out of the SVG attribute context, for example:
graph TD
  A[Harmless] --> B[Safe]
  style A fill:red"/> <script>alert(document.cookie)</script>
  1. Inject the payload: Submit the crafted diagram to the target application through any available input vector (e.g., a diagram editor, API endpoint, or collaborative document).
  2. Trigger rendering: When the application processes the diagram with beautiful-mermaid, the unescaped style value closes the SVG attribute and element, injecting the attacker-controlled SVG/HTML markup into the rendered output.
  3. Achieve XSS: When a victim user views the page containing the rendered SVG, the injected script executes in the context of the embedding origin, enabling session token theft, credential harvesting, or further malicious actions (GitHub Advisory, PR #8).

Indicators of compromise

  • Logs: Application or server logs showing Mermaid diagram input containing suspicious characters such as ", />, <script, onerror=, or onload= within style or classDef directive values.
  • Network: Outbound requests from victim browsers to attacker-controlled domains (e.g., for cookie exfiltration) originating from pages that render Mermaid diagrams.
  • File System / Application Output: Rendered SVG output files or cached responses containing injected <script> tags, event handler attributes (e.g., onload, onerror), or unexpected <image> elements with external href values within SVG content generated by beautiful-mermaid.

Mitigation and workarounds

Upgrade beautiful-mermaid to version 0.1.3 or later, which applies escapeXml() to all inline style properties before SVG output, preventing attribute injection (GitHub Release v0.1.3). If immediate patching is not possible, implement server-side input validation and sanitization to reject or escape special characters (", <, >) in Mermaid style and classDef directive values before passing them to the library. Additionally, deploy a strict Content Security Policy (CSP) on pages that render Mermaid diagrams to limit the impact of any injected scripts.

Community reactions

The fix was contributed by external researcher willdollman via a pull request merged on January 29, 2026, demonstrating community-driven security improvement for the project (PR #8). The GitHub Advisory was published and reviewed on February 13, 2026, and the release attracted positive reactions from several community members (GitHub Release v0.1.3). No significant broader media coverage or notable researcher commentary beyond the advisory and patch PR has been identified.

Additional resources


Source: This report was generated using AI

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-966w-4vpf-p7hcHIGH7.1
  • JavaScript logoJavaScript
  • @aloma.io/aloma
NoYesOct 25, 2026
GHSA-mrwp-f3q8-3g9pMEDIUM5.9
  • JavaScript logoJavaScript
  • follow-redirects
NoYesOct 25, 2026
GHSA-hfm3-x63j-7fxpHIGHN/A
  • JavaScript logoJavaScript
  • @payload-auth-link/migrate
NoYesOct 25, 2026
GHSA-6244-vvv9-76f5MEDIUMN/A
  • JavaScript logoJavaScript
  • @payload-auth-link/plugin
NoYesOct 25, 2026
GHSA-q53q-qg98-p9jfHIGHN/A
  • JavaScript logoJavaScript
  • llm-fw
NoYesOct 25, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management