Vulnerability · Published Jun 28, 2022 · Assigned by GitHub_M

CVE-2022-31108Arbitrary `CSS` injection into the generated graph affecting the container HTML in mermaid.js

Medium 4.1

In plain English

A medium-severity injection in mermaid from mermaid-js. Proof-of-concept exploit code is public. The chance it is exploited in the next 30 days is estimated at 0.9% (higher than 60% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)4.1Medium
Exploit odds (30 days)0.9%top 39.7% of all CVEs
Exploited in the wildNo reportsCISA SSVC: poc
Attack toolingNoneno public tooling known

Official description

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.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:14node-mermaid9.2.2+~2.0.0-1DEBIAN-CVE-2022-31108
Ubuntu:22.04:LTSnode-mermaidno fix listedUBUNTU-CVE-2022-31108
Ubuntu:26.10node-mermaidno fix listedUBUNTU-CVE-2022-31108
npmmermaid9.1.2GHSA-x3vm-38hw-55wf

Affected products (as reported)

VendorProductVersions
mermaid-js mermaid >= 8.0.0, < 9.1.3

Weakness: CWE-74 · Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:N/A:N

References