CVE-2021-35513 Cross-site Scripting in Mermaid
Attackers can execute arbitrary scripts via XSS in Mermaid when the antiscript feature is enabled, affecting applications using this library.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2021-35513?
CVE-2021-35513 is a medium-severity cross-site scripting vulnerability in n/a, published on 27 Jun 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Official description
Mermaid before 8.11.0 allows XSS when the antiscript feature is used.
Weakness: CWE-79
Which versions are affected by CVE-2021-35513?
2 open source packages ship an affected version, including mermaid. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
mermaid npm | All versions | 8.11.0 |
mermaid npm | All versions | 8.11.0 |
Products include Mermaid Project Mermaid.
How do I fix CVE-2021-35513?
Upgrade mermaid to 8.11.0 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
Is CVE-2021-35513 being exploited?
There is no known exploitation of CVE-2021-35513 in the wild and no public exploit code.
Other vulnerabilities in n/a
- CVE-2021-43861 Incorrect sanitisation function leads to `XSS`
- CVE-2026-41150 Mermaid Gantt Charts are vulnerable to an Infinite Loop DoS
- CVE-2026-41159 Mermaid: Improper sanitization of configuration leads to CSS injection
- CVE-2025-54880 Mermaid does not properly sanitize architecture diagram iconText leading to XSS
- CVE-2022-31108 Arbitrary `CSS` injection into the generated graph affecting the container HTML in mermaid.js
Sources
Also known as DEBIAN-CVE-2021-35513, GHSA-4f6x-49g2-99fm, UBUNTU-CVE-2021-35513.