GHSA-87f9-hvmw-gh4p

Suggest an improvement
Source
https://github.com/advisories/GHSA-87f9-hvmw-gh4p
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-87f9-hvmw-gh4p/GHSA-87f9-hvmw-gh4p.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-87f9-hvmw-gh4p
Aliases
  • CVE-2026-41159
Published
2026-05-11T19:37:00Z
Modified
2026-05-11T19:49:39.861570Z
Severity
  • 5.3 (Medium) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:L CVSS Calculator
Summary
Mermaid: Improper sanitization of configuration leads to CSS injection
Details

Impact

Mermaid's default configuration allows injecting CSS that applies outside of the Mermaid diagram via the fontFamily, themeCSS, and altFontFamily configuration options.

Live demo: mermaid.live

Example code:

%%{init: {"fontFamily": "x;a{b} :not(&){background:green !important} c{d}"}}%%
flowchart LR
    A --> B

The injected CSS exploits stylis's & (scope reference) handling. :not(&) escapes the #mermaid-xxx automatic scoping, applying styles to all page elements. Global at-rules (@font-face, @keyframes, @counter-style) are also injectable as stylis hoists them to top level.

This allows page defacement and DOM attribute exfiltration via CSS :has() selectors.

Patches

Workarounds

If you can't upgrade mermaid, you can set the secure config value in the mermaid config to avoid allowing diagrams to modify fontFamily, themeCSS, altFontFamily, and themeVariables.

Setting "securityLevel": "sandbox" will also prevent this.

Credits

Reported by @zsxsoft on behalf of @KeenSecurityLab

Database specific
{
    "github_reviewed": true,
    "github_reviewed_at": "2026-05-11T19:37:00Z",
    "cwe_ids": [
        "CWE-94"
    ],
    "severity": "MODERATE",
    "nvd_published_at": null
}
References

Affected packages

npm / mermaid

Package

Affected ranges

Type
SEMVER
Events
Introduced
11.0.0-alpha.1
Fixed
11.15.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-87f9-hvmw-gh4p/GHSA-87f9-hvmw-gh4p.json"
last_known_affected_version_range
"<= 11.14.0"

npm / mermaid

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
10.9.6

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-87f9-hvmw-gh4p/GHSA-87f9-hvmw-gh4p.json"
last_known_affected_version_range
"<= 10.9.5"