CVE-2021-35513: Cross-site Scripting in Mermaid
Summary
CVE-2021-35513: Cross-site Scripting in Mermaid. Affects mermaid versions < 8.11.0. Fixed in 8.11.0. How to fix ↓
Also tracked for
- node-mermaid · Debian:11
The same CVE-2021-35513 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Mermaid is an npm package that allows users to generate diagrams and flowcharts from text. It is widely used for visualizing complex data and processes. However, versions before 8.11.0 are vulnerable to a cross-site scripting (XSS) attack when the antiscript feature is used.
Vulnerability Detail
The vulnerability in Mermaid allows an attacker to inject malicious scripts into the generated diagrams or flowcharts. This can lead to the execution of arbitrary code in the context of the user's browser, potentially compromising sensitive information or performing unauthorized actions. The antiscript feature, which is designed to prevent script execution, is ineffective in preventing this type of attack.
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 version below is the minimum fixed release for this vulnerability.
If you need the minimum change
8.11.0
This is the first release that contains the fix.
npm install mermaid@8.11.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating to the latest version is not immediately feasible, a temporary workaround is to disable the antiscript feature in Mermaid. This can be done by modifying the configuration or code that utilizes Mermaid to generate diagrams. By disabling the antiscript feature, the risk of XSS attacks is mitigated, but it is still important to update to the fixed version as soon as possible.
Conclusion
In conclusion, the vulnerability in Mermaid allows for cross-site scripting attacks when the antiscript feature is used. It is crucial to update to version 8.11.0 or later to mitigate this vulnerability. If immediate updating is not possible, disabling the antiscript feature can provide temporary protection. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for mermaid →
FAQ
The vulnerability allows an attacker to execute arbitrary code in the user's browser, potentially leading to data theft, session hijacking, or unauthorized actions.
At the time of this advisory, there are no known public exploits targeting this vulnerability. However, it is recommended to update to the fixed version to prevent any potential attacks.
No, only versions before 8.11.0 are vulnerable to this XSS issue. It is important to update to the fixed version to ensure the security of your application.
Yes, this vulnerability can be exploited remotely by an attacker who can trick a user into visiting a specially crafted website or clicking on a malicious link.
Yes, a temporary workaround is to disable the antiscript feature in Mermaid. However, it is strongly recommended to update to the fixed version as soon as possible to fully address the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for mermaid.