# CVE-2026-41148: Mermaid CSS injection in class definitions

Source: https://junglewise.ai/threats/cve-2026-41148-mermaid-css-injection-in-class-definitions  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-22. Updated: 2026-06-09  
License: CC BY 4.0 with a link back

CVE-2026-41148 · Severity: medium · CVSS 4 · Published 2026-05-22

Mermaid is a popular JavaScript library used to generate charts and diagrams from text. A vulnerability in how it handles diagram styles allows an attacker to inject malicious CSS code into a web page. This could lead to page defacement, unauthorized tracking of users, or the theft of sensitive information displayed on the page.

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

## Quick answers

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

**How severe is CVE-2026-41148?** Medium severity, with a CVSS score of 4, published 22 May 2026.

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

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

**How is CVE-2026-41148 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-41148?** 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.15.0 or later

  ```sh
  npm install mermaid@11.15.0
  ```


## Technical details

A CSS injection vulnerability exists in Mermaid's state diagram and other diagram types that utilize the createCssStyles parser. The root cause is an unrestricted regular expression used to capture classDef values, which fails to sanitize user-controlled style strings. By including a closing brace '}' in a class definition, an attacker can break out of the intended CSS selector and inject arbitrary CSS rules. This can be exploited to perform page defacement, track users via URL callbacks, or exfiltrate DOM attributes using CSS selectors like :has(). The vulnerability is patched in versions 11.15.0 and 10.9.6.

## Affected products

- mermaid-js mermaid >= 11.0.0-alpha.1, <= 11.14.0; <= 10.9.5

## Identifiers

- CVE-2026-41148
- GHSA-xcj9-5m2h-648r

## Timeline

- 2026-05-11: disclosed
- 2026-05-11: advisory
- 2026-05-11: patched

## References

- [https://api.github.com/users/matejsmycka](https://api.github.com/users/matejsmycka)
- [https://github.com/matejsmycka](https://github.com/matejsmycka)
- [https://api.github.com/users/matejsmycka/gists%7B/gist_id%7D](https://api.github.com/users/matejsmycka/gists%7B/gist_id%7D)
- [https://api.github.com/users/matejsmycka/repos](https://api.github.com/users/matejsmycka/repos)
- [https://avatars.githubusercontent.com/u/45017046?v=4](https://avatars.githubusercontent.com/u/45017046?v=4)
- [https://api.github.com/users/matejsmycka/events%7B/privacy%7D](https://api.github.com/users/matejsmycka/events%7B/privacy%7D)

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