Home / mermaid-js / mermaid / CVE-2022-31108
CVE-2022-31108: is it exploited, and which versions of mermaid-js mermaid are affected and fixed?
CVE-2022-31108 is an injection vulnerability in mermaid-js mermaid. It is not known to be exploited: it is not in CISA's Known Exploited Vulnerabilities catalog (catalog 2026.11.30, read December 3, 2026, 15:39 UTC). Affected: mermaid from 8.0.0 before 9.1.2 (GitHub advisory GHSA-x3vm-38hw-55wf). Fixed in 9.1.2 (GitHub advisory GHSA-x3vm-38hw-55wf). Severity: Medium (4.1, CVSS 3.1, from GitHub_M).
Data checked December 3, 2026: last read CISA KEV December 3, 2026, 15:39 UTC, CVE record November 19, 2026, 07:14 UTC and NVD November 19, 2026, 07:47 UTC.
What is CVE-2022-31108?
Arbitrary `CSS` injection into the generated graph affecting the container HTML in mermaid.js
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.
From the CVE record by GitHub_M, last updated April 22, 2025, 17:52 UTC.
Which versions are affected, and which fix it?
| Vendor | Product | Affected | Fixed or not affected from |
|---|---|---|---|
| mermaid-js | mermaid | >= 8.0.0, < 9.1.3 |
As the CVE record by GitHub_M states it, last updated April 22, 2025. Version ranges are the CNA's; a version the record calls not affected is usually the fix.
Which packages are affected, and in which version is each fixed?
| Ecosystem | Package | Affected | Fixed in | Advisory |
|---|---|---|---|---|
| npm | mermaid | >= 8.0.0, < 9.1.2 | 9.1.2 | GHSA-x3vm-38hw-55wf |
GitHub Advisory Database, reviewed advisories (CC BY 4.0); advisory updated July 5, 2022. Summary: Possible inject arbitrary `CSS` into the generated graph affecting the container HTML.
Which products and versions does the NVD list as affected?
| Vendor | Product | Versions | Type |
|---|---|---|---|
| mermaid project | mermaid | from 8.0.0 before 9.1.3 | application |
NVD analysis (status Modified), last modified June 17, 2026, 04:44 UTC.
How severe is CVE-2022-31108?
| Score | Version | Vector | Source |
|---|---|---|---|
| Medium 4.1 | CVSS 3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:N/A:N | GitHub_M |
| Medium 6.1 | CVSS 3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N | NVD |
| Medium 5.8 | CVSS 2.0 | AV:N/AC:M/Au:N/C:P/I:P/A:N | NVD |
Each score is shown as its source gave it: the CNA that wrote the record, CISA's ADP (vulnrichment) and the NVD. They can differ.
What the ratings mean: in CVSS 3 and 4, scores run from 0 to 10, with Low 0.1 to 3.9, Medium 4.0 to 6.9, High 7.0 to 8.9 and Critical 9.0 to 10.0. CVSS 2 has no Critical band: its High runs from 7.0 to 10.0. The vector lists how the flaw is reached (network, local), what an attacker needs (privileges, a user's click) and what it can harm.
Is CVE-2022-31108 exploited in the wild?
- CISA KEV
- Not listed (catalog 2026.11.30)
- CISA SSVC
- Exploitation: poc; automatable: no; technical impact: partial (CISA ADP, April 22, 2025)
- EPSS
- 0.93% probability of exploitation activity in the next 30 days, percentile 61.7 (FIRST EPSS, scores of December 3, 2026)
What kind of flaw is it?
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component
- CWE-79 Improper Neutralization of Input During Web Page Generation
Where are the vendor advisories and references?
- https://github.com/mermaid-js/mermaid/security/advisories/GHSA-x3vm-38hw-55wf x_refsource_CONFIRM
- https://github.com/mermaid-js/mermaid/commit/0ae1bdb61adff1cd485caff8c62ec6b8ac57b225 x_refsource_MISC
When was it published, and where is the official record?
- Reserved
- May 18, 2022
- Published
- June 28, 2022, 18:35 UTC
- CVE record updated
- April 22, 2025, 17:52 UTC by GitHub_M
- NVD
- Modified, last modified June 17, 2026, 04:44 UTC
- Last checked
- CVE list November 19, 2026, 07:14 UTC; NVD November 19, 2026, 07:47 UTC; KEV December 3, 2026, 15:39 UTC; EPSS December 3, 2026
- Official record
- cve.org · NVD
What other CVEs affect mermaid?
- Aug 6, 2026CVE-2026-71439 mermaid-js mermaid: unchecked Input for Loop Condition
- Aug 6, 2026CVE-2026-71438 mermaid-js mermaid: prototype pollution
- Aug 6, 2026CVE-2026-50159 mermaid-js mermaid: code injection (remote code execution)
- Aug 6, 2026CVE-2026-71437 mermaid-js mermaid: prototype pollution
- Aug 6, 2026CVE-2026-71436 mermaid-js mermaid: infinite loop (denial of service)
- May 29, 2026CVE-2026-41150 mermaid-js mermaid: infinite loop (denial of service)
- May 29, 2026CVE-2026-41159 mermaid-js mermaid: code injection (remote code execution)
- May 22, 2026CVE-2026-41149 mermaid-js mermaid: code injection (remote code execution)
Questions about CVE-2022-31108
Is CVE-2022-31108 exploited in the wild?
Not as far as CISA knows: it is not in the Known Exploited Vulnerabilities catalog, read December 3, 2026, 15:39 UTC. FIRST's EPSS gives it a 0.93% chance of exploitation activity in the next 30 days (scores of December 3, 2026).
Which versions of mermaid-js mermaid are affected by CVE-2022-31108?
mermaid from 8.0.0 before 9.1.2, per the GitHub advisory GHSA-x3vm-38hw-55wf. The tables above give every range the sources list.
Which version fixes CVE-2022-31108?
9.1.2, per the GitHub advisory GHSA-x3vm-38hw-55wf. Check the vendor's advisory before you rely on it.
How severe is CVE-2022-31108?
Medium (4.1, CVSS 3.1, from GitHub_M). The severity table above shows each score with its source.
Where is the official record of CVE-2022-31108?
The CVE Program's record is at cve.org and the NVD's at nvd.nist.gov. For a fix, the vendor's own advisory is the one to follow.