CVE-2025-54881 Mermaid improperly sanitizes of sequence diagram labels leading to XSS
Attackers can execute arbitrary scripts via unsanitized sequence diagram labels in the Mermaid JavaScript 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-2025-54881?
CVE-2025-54881 is a medium-severity cross-site scripting vulnerability in mermaid-js mermaid, published on 19 Aug 2025. 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 is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. In the default configuration of mermaid 10.9.0-rc.1 to 11.9.0, user supplied input for sequence diagram labels is passed to innerHTML during calculation of element size, causing XSS.
Weakness: CWE-79
Which versions are affected by CVE-2025-54881?
4 open source packages ship an affected version, including mermaid.
| Package | Affected | Fixed in |
|---|---|---|
mermaid npm | From 10.9.0-rc.1 | 10.9.4 |
mermaid npm | From 10.9.0-rc.1 | 10.9.4 |
mermaid npm | From 11.0.0-alpha.1 | 11.10.0 |
mermaid npm | From 11.0.0-alpha.1 | 11.10.0 |
How do I fix CVE-2025-54881?
Upgrade mermaid to a fixed version for your release line: 10.9.4 or 11.10.0.
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-2025-54881 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-54881 exists.
Sources
Also known as GHSA-7rqq-prvp-x9jh, UBUNTU-CVE-2025-54881.