CVE-2026-50159: Mermaid CSS Injection Vulnerability Affecting Sibling Elements

mermaid Updated 06 Aug 2026

Summary

06/08/2026
Yes i
Moderate
5.3

CVE-2026-50159: Mermaid allows CSS injection applying to sibling elements of the diagram. Affects mermaid across 2 version ranges.

< 10.9.8 >= 11.0.0-alpha.1, < 11.16.1

Fixed in 10.9.8 or 11.16.1, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Mermaid is an open-source JavaScript library that enables the generation of diagrams and flowcharts from text descriptions. It is widely used for visualizing complex information in a simple and intuitive manner. The library allows users to create diagrams in various formats, making it a popular choice for documentation and presentations. However, a recent vulnerability has been identified that allows CSS injection, potentially affecting the styling of sibling elements adjacent to the rendered diagrams.

Vulnerability Detail

The vulnerability arises from Mermaid's CSS scoping mechanism, which is intended to restrict styles to the rendered SVG subtree. However, due to the use of sibling combinators in CSS, attackers can exploit this weakness to inject styles into DOM elements that are siblings to the diagram's SVG. This can lead to UI redressing, content hiding, and phishing-style visual manipulation. Although most users may not be affected, those who manually insert SVG elements into the DOM are at risk. Importantly, this vulnerability does not allow for JavaScript execution.

How To Fix

Latest published version: 12.2.0 as of 22 Oct 2026

npm install mermaid@12.2.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 10.9.8 10.9.8
    npm install mermaid@10.9.8
  • >= 11.0.0-alpha.1, < 11.16.1 11.16.1
    npm install mermaid@11.16.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If you are manually inserting the SVG into the DOM, you can wrap it in a container element to prevent CSS leakage. For example, use the following code: <div><svg>...</svg></div>. Alternatively, you can utilize Mermaid's built-in functions like mermaid.run() or mermaid.initialize() to handle the SVG insertion correctly. Additionally, setting the configuration option 'securityLevel' to 'sandbox' will prevent this vulnerability.

Conclusion

The CVE-2026-50159 vulnerability in the Mermaid library poses a risk of CSS injection that can affect sibling elements of rendered diagrams. Users are encouraged to update to the latest patched versions and implement recommended workarounds to secure their applications.

See every vulnerability recorded for mermaid →

Share this vulnerability

FAQ

CVE-2026-50159 is a vulnerability in the Mermaid library that allows CSS injection affecting sibling elements of the rendered diagram.

Most users are not affected unless they manually insert SVG elements into the DOM. Those who do are at risk of CSS injection.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Check your application using the Vulert playground without any signup.

The vulnerability can lead to UI redressing, content hiding, and phishing-style visual manipulation, but does not allow for JavaScript execution.

Update Mermaid to the patched versions (v11.16.1 or v10.9.8) and consider implementing the provided workarounds to mitigate risks.

Related vulnerabilities

Recent vulnerabilities recorded for mermaid.

How To Fix

Latest published version: 12.2.0 as of 22 Oct 2026

npm install mermaid@12.2.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 10.9.8 10.9.8
    npm install mermaid@10.9.8
  • >= 11.0.0-alpha.1, < 11.16.1 11.16.1
    npm install mermaid@11.16.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback