Junglewise Threat Intelligence

CVE-2026-50159: Mermaid CSS injection via sibling combinators

CVE-2026-50159 · Severity: medium · CVSS 5.3 · Published 2026-08-06

Executive brief

Mermaid, a popular tool for generating charts and diagrams from text, contains a vulnerability that allows malicious diagrams to affect other parts of a web page. If an attacker can provide diagram code to be rendered on a site, they can inject styles that change the appearance of surrounding content, potentially leading to phishing attacks or hiding important information. This primarily affects developers who manually insert Mermaid diagrams into their web pages alongside other content.

Technical details

A CSS injection vulnerability exists in Mermaid's style namespacing middleware. While the library attempts to scope CSS rules to the diagram's SVG subtree by prefixing selectors with a unique ID, it fails to account for sibling combinators ('~' and '+'). An attacker providing a malicious diagram source can use these combinators to target and restyle DOM elements adjacent to the Mermaid SVG. This can lead to UI redressing or visual phishing, though JavaScript execution is not possible. The issue is patched in versions 11.16.1 and 10.9.8.

Affected products

  • mermaid-js mermaid >= 11.0.0-alpha.1, < 11.16.1
  • mermaid-js mermaid < 10.9.8

Timeline

  • 2026-08-04: disclosed
  • 2026-08-06: advisory
  • 2026-08-06: patched

References