Quick answers
- Is CVE-2022-31108 exploited in the wild?
- No. Junglewise Threat Intelligence has no report of CVE-2022-31108 being exploited in the wild.
- How severe is CVE-2022-31108?
- Low severity, with a CVSS score of 3.1, published 5 July 2022.
- Which products and versions are affected?
- mermaid (npm) SEMVER:introduced=8.0.0,fixed=9.1.2.
- Is there a fix for CVE-2022-31108?
- Yes. mermaid (npm): upgrade to 9.1.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
- How is CVE-2022-31108 attacked?
- It is attacked over the network.
- Am I affected by CVE-2022-31108?
- Check whether you run mermaid (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.
How to fix
- mermaid (npm): upgrade to 9.1.2 or later
npm install mermaid@9.1.2
Technical details
The vulnerability is a CSS injection flaw in Mermaid.js versions 8.0.0 through 9.1.1 affecting the theme configuration handling. The root cause is insufficient sanitization of user-supplied theme variables (such as textColor, fontFamily, and fontSize) before embedding them directly into CSS blocks generated by the getStyles() function and mermaidAPI.js. An attacker with the ability to control diagram initialization parameters (via theme variables in graph definitions) can break out of the intended CSS scope and inject arbitrary selectors and rules. The attack vector is network-based with no authentication required, but user interaction (viewing a page containing the malicious diagram) is necessary. Exploitation enables information disclosure via CSS attribute selectors paired with URL-based side channels, DOM manipulation, and clickjacking attacks. The vulnerability was fixed in version 9.1.2 by properly escaping user input before CSS insertion.
Affected products
- Mermaid.js Mermaid 8.0.0 through 9.1.1
Identifiers
- CVE-2022-31108
- GHSA-x3vm-38hw-55wf
Timeline
- 2022-06-28: disclosed
- 2022-07-05: advisory
- 2022-07-05: patched: Version 9.1.2 released