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

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). 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
    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

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.