Arbitrary `CSS` injection into the generated graph affecting the container HTML in mermaid.js
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- Cross-site scripting
- Confidentiality · integrity · availability
- Low · Low · None
- Fix status
- Fixed
Attack profile from CVSS 3.1 · NVD. Fix status from CNA and GitHub. Impact type from CWE-79.
Summary
Mermaid is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. An attacker is able to inject arbitrary `CSS` into the generated graph allowing them to change the styling of elements outside of the generated graph, and potentially exfiltrate sensitive information by using specially crafted `CSS` selectors. The following example shows how an attacker can exfiltrate the contents of an input field by bruteforcing the `value` attribute one character at a time. Whenever there is an actual match, an `http` request will be made by the browser in order to "load" a background image that will let an attacker know what's the value of the character. This issue may lead to `Information Disclosure` via CSS selectors and functions able to generate HTTP requests. This also allows an attacker to change the document in ways which may lead a user to perform unintended actions, such as clicking on a link, etc. This issue has been resolved in version 9.1.3. Users are advised to upgrade. Users unable to upgrade should ensure that user input is adequately escaped before embedding it in CSS blocks.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- Poc
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| mermaid-js | mermaid | 8.0.0 to before 9.1.3 | 9.1.3 | Patch available | CNA |
| — | mermaid (npm) | 8.0.0 to before 9.1.2 | 9.1.2 | Patch available | GHSA-x3vm-38hw-55wf |
- mermaid Vendormermaid-js Affected 8.0.0 to before 9.1.3 Fixed in 9.1.3 Patch available CNA
- mermaid (npm) Vendor— Affected 8.0.0 to before 9.1.2 Fixed in 9.1.2 Patch available GHSA-x3vm-38hw-55wf
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:mermaid_project:mermaid:*:*:*:*:*:node.js:*:* | 8.0.0 to before 9.1.3 | Vulnerable | mermaid-js |
- cpe:2.3:a:mermaid_project:mermaid:*:*:*:*:*:node.js:*:* Versions 8.0.0 to before 9.1.3 Vulnerable ·mermaid-js
Remediation
- Fix · CNA mermaid (mermaid-js) Fixed in 9.1.3
- Fix · GHSA-x3vm-38hw-55wf mermaid (npm) Fixed in 9.1.2 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2022-31108
- 2026-10-03 Alias added: GHSA-x3vm-38hw-55wf
References
More mermaid-js Mermaid vulnerabilities
- TI-2026-29778 Mermaid Gantt Charts are vulnerable to an Infinite Loop DoS CVSS 4.0MEDIUM 5.3
- TI-2025-34614 Mermaid does not properly sanitize architecture diagram iconText leading to XSS CVSS 4.0MEDIUM 5.1
- TI-2021-19667 Incorrect sanitisation function leads to `XSS` CVSS 3.1HIGH 7.2
- TI-2021-14247 Mermaid before 8.11.0 allows XSS when the antiscript feature is used. CVSS 3.1MEDIUM 6.1
- TI-2026-29785 Mermaid: Improper sanitization of configuration leads to CSS injection CVSS 4.0MEDIUM 5.3
Sources
- CVE-2022-31108 · CVE Program
- CVE-2022-31108 · NVD
- FIRST EPSS
- GHSA-x3vm-38hw-55wf · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences