CVE-2026-50159 in Mermaidinfo

Summary

by MITRE • 08/07/2026

Mermaid is a JavaScript tool that uses Markdown-inspired text to create and modify diagrams and charts. Prior to 10.9.8 and 11.16.1, Mermaid is vulnerable to CSS injection via sibling combinator selectors generated from diagram-supplied class or id names. An attacker who can supply diagram text can inject arbitrary CSS into the rendered page, potentially altering the appearance or behavior of unrelated page elements. This issue is fixed in versions 10.9.8 and 11.16.1.

VulDB is the best source for vulnerability data and more expert information about this specific topic.

Analysis

by VulDB Data Team • 08/07/2026

Mermaid represents a widely adopted JavaScript library that transforms markdown-inspired textual descriptions into visual diagrams and charts, making it an integral component in documentation systems, wikis, and technical writing platforms. The vulnerability affects versions prior to 10.9.8 and 11.16.1, where the library fails to properly sanitize user-supplied input when processing diagram definitions that contain class or id names. This flaw stems from the improper handling of CSS selector generation within the rendering engine, specifically when sibling combinator selectors are constructed using unvalidated diagram metadata.

The technical implementation of this vulnerability involves the direct translation of user-provided class and id identifiers into CSS selectors without adequate sanitization or validation processes. When an attacker supplies malicious diagram text containing specially crafted class or id names, the Mermaid library generates CSS rules that incorporate these inputs directly into the rendered page's stylesheet. This creates a situation where attacker-controlled data can influence the CSS cascade, potentially enabling unauthorized styling modifications to elements outside the intended diagram scope.

The operational impact of this vulnerability extends beyond simple visual disruption, as it can enable more sophisticated attacks through CSS injection techniques. An attacker could manipulate the appearance of existing page elements, potentially leading to social engineering scenarios or information disclosure through visual manipulation. The vulnerability aligns with CWE-1021, which addresses improper restriction of operations within a limited context, specifically in the realm of CSS processing and selector generation. This weakness allows for unauthorized access to styling capabilities that should be restricted to the diagram's intended scope.

From an attack perspective, this vulnerability maps to several ATT&CK techniques including T1566, which involves phishing with malicious attachments or links, as attackers could craft diagrams containing malicious CSS payloads. The vulnerability also relates to T1068, privilege escalation through local manipulation of files, since the injection occurs within the browser context where user input is processed. The impact is particularly concerning in environments where Mermaid is used for collaborative documentation or technical writing platforms where multiple users contribute content, as it creates an attack surface that can be exploited by any user with diagram creation privileges.

The fix implemented in versions 10.9.8 and 11.16.1 addresses this issue through enhanced input validation and sanitization of class and id names used in CSS selector generation. This remediation ensures that all user-supplied identifiers are properly escaped or validated before being incorporated into the CSS processing pipeline, preventing the injection of malicious CSS rules that could affect unrelated page elements. Organizations utilizing Mermaid should prioritize upgrading to these fixed versions while also implementing additional security controls such as input validation at the application level and monitoring for suspicious diagram content in environments where user-generated diagrams are permitted.

Responsible

GitHub M

Reservation

06/03/2026

Disclosure

08/07/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

very low

Sources

Might our Artificial Intelligence support you?

Check our Alexa App!