Description
Mermaid does not fully restrict CSS to the rendered SVG subtree. Although selectors are prefixed with #mermaid-X, sibling (~ and +) combinators can still escape the Mermaid container and inject styles to DOM elements adjacent to the diagram <svg>.
Recommendation
Update the mermaid package to the latest compatible version. Followings are version details:
Affected version(s): **< 10.9.8 >= 11.0.0-alpha.1, < 11.16.1** Patched version(s): **10.9.8 11.16.1**
References
Could your website be exposed too?
SmartScanner can check your website for Mermaid allows CSS injection applying to sibling elements of the diagram and gives you actionable findings to investigate.
Start a free scanRelated Issues
- Mermaid: Improper sanitization of `classDefs` in diagrams leads to CSS injection - CVE-2026-41148
- Mermaid: Improper sanitization of configuration leads to CSS injection - CVE-2026-41159
- CryptPad has a Sanitizer Bypass in Diffmarked.js that Allows Arbitrary HTML Injection and Potential XSS - CVE-2026-26028
- tarteaucitron.js allows UI manipulation via unrestricted CSS injection - CVE-2025-31138


