# CVE-2025-54881: Mermaid XSS in sequence diagram labels

Source: https://junglewise.ai/threats/cve-2025-54881-mermaid-xss-in-sequence-diagram-labels  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-08-19. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2025-54881 · Severity: medium · CVSS 4 · Published 2025-08-19

Mermaid is a popular JavaScript library used to create diagrams from text descriptions. A flaw in how it processes sequence diagram labels allows attackers to inject malicious code that executes in the browser of anyone viewing the diagram. Sites that accept and display user-provided diagrams are at risk of account compromise or malware distribution.

Technologies: [mermaid (npm)](https://junglewise.ai/threats/technologies/mermaid). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2025-54881 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-54881 being exploited in the wild.

**How severe is CVE-2025-54881?** Medium severity, with a CVSS score of 4, published 19 August 2025.

**Which products and versions are affected?** mermaid (npm) SEMVER:introduced=11.0.0-alpha.1,fixed=11.10.0.

**Is there a fix for CVE-2025-54881?** Yes. mermaid (npm): upgrade to 11.10.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-54881 attacked?** It is attacked over the network.

**Am I affected by CVE-2025-54881?** Check whether you run mermaid (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- mermaid (npm): upgrade to 11.10.0 or later

  ```sh
  npm install mermaid@11.10.0
  ```


## Technical details

The vulnerability is a Cross-Site Scripting (XSS) flaw in the calculateMathMLDimensions function, which processes sequence diagram labels with KaTeX mathematical notation. The function calls renderKatex() on user-supplied text, then directly assigns the output to element.innerHTML without sanitization, allowing arbitrary HTML and JavaScript injection. The attack vector is network-based: an attacker crafts a malicious diagram (e.g., with an img tag containing an onerror handler) and tricks a user into viewing it on a site running vulnerable Mermaid. No authentication is required, but user interaction (viewing the diagram) is necessary. Successful exploitation allows arbitrary JavaScript execution in the victim's browser context. Patches are available in Mermaid 10.9.4 and 11.10.0.

## Affected products

- Mermaid Mermaid 11.0.0-alpha.1 to 11.9.x (fixed in 11.10.0); 10.9.0-rc.1 to 10.9.3 (fixed in 10.9.4)

## Identifiers

- CVE-2025-54881
- GHSA-7rqq-prvp-x9jh

## Timeline

- 2025-08-19: disclosed: GHSA-7rqq-prvp-x9jh published

## References

- [https://github.com/mermaid-js/mermaid/security/advisories/GHSA-7rqq-prvp-x9jh](https://github.com/mermaid-js/mermaid/security/advisories/GHSA-7rqq-prvp-x9jh)

## Related threats

- [Mermaid radar diagrams denial of service via unchecked ticks input](https://junglewise.ai/threats/cve-2026-71439-mermaid-radar-diagrams-denial-of-service-via-unchecked-ticks)
- [Mermaid prototype pollution in configuration APIs](https://junglewise.ai/threats/cve-2026-71438-mermaid-prototype-pollution-in-configuration-apis)
- [Mermaid prototype pollution in architecture-beta diagrams](https://junglewise.ai/threats/cve-2026-71437-mermaid-prototype-pollution-in-architecture-beta-diagrams)
- [Mermaid infinite loop in XY Charts axis processing](https://junglewise.ai/threats/cve-2026-71436-mermaid-infinite-loop-in-xy-charts-axis-processing)
- [Mermaid CSS injection via sibling combinators](https://junglewise.ai/threats/cve-2026-50159-mermaid-css-injection-via-sibling-combinators)
