Read the docs
TI-2022-13152 Aliases CVE-2022-31108GHSA-x3vm-38hw-55wf

Arbitrary `CSS` injection into the generated graph affecting the container HTML in mermaid.js

Priority MEDIUM 60CWE-74Published · Updated

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

Exploitation Proof of concept CISA SSVC · not in CISA KEV
EPSS 0.00914 60th percentileScored 2026-11-07
Public exploit Yes 1 exploit referenceTagged by NVD
Fix Fixed mermaid (mermaid-js): 9.1.3mermaid (npm): 9.1.2

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

VendorProductAffected versionsFixed inStatusSource
mermaid-jsmermaid8.0.0 to before 9.1.39.1.3Patch availableCNA
—mermaid (npm)8.0.0 to before 9.1.29.1.2Patch availableGHSA-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

CPEVersionsRoleVendor
cpe:2.3:a:mermaid_project:mermaid:*:*:*:*:*:node.js:*:*8.0.0 to before 9.1.3Vulnerablemermaid-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

  1. 2026-10-02 Threatist record created from CVE-2022-31108
  2. 2026-10-03 Alias added: GHSA-x3vm-38hw-55wf

References

  • 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