CVE-2022-31108
JavaScript vulnerability analysis and mitigation

Overview

CVE-2022-31108 is a CSS injection vulnerability discovered in mermaid.js versions 8+ that was disclosed on June 28, 2022. The vulnerability allows attackers to inject arbitrary CSS into generated graphs, potentially affecting elements outside the intended scope. The issue was identified in mermaid.js version 9.1.1 and was patched in version 9.1.2 (GitHub Advisory).

Technical details

The vulnerability stems from insufficient sanitization of theme variables in the getStyles function within src/styles.js. By manipulating the textColor theme variable, attackers can inject malicious CSS rules into the document. For example, setting textColor to 'green;} #target { background-color: crimson }' allows styling of arbitrary elements outside the SVG scope. The issue affects multiple functions that handle style modifications (GitHub Advisory).

Impact

The vulnerability enables information disclosure through CSS selectors and functions capable of generating HTTP requests. Attackers can exploit this to exfiltrate sensitive information by bruteforcing input field values using specially crafted CSS selectors. Additionally, the vulnerability allows attackers to modify document styling in ways that could lead users to perform unintended actions (GitHub Advisory, Security Lab).

Mitigation and workarounds

The vulnerability was patched in mermaid.js version 9.1.2. The fix involves proper sanitization of user input before embedding it in CSS blocks. Users should upgrade to version 9.1.2 or later to mitigate this vulnerability (GitHub Advisory).

Additional resources


SourceThis report was generated using AI

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-65959HIGH8.7
  • JavaScriptJavaScript
  • open-webui
NoYesDec 04, 2025
CVE-2025-66032HIGH8.7
  • JavaScriptJavaScript
  • @anthropic-ai/claude-code
NoYesDec 03, 2025
CVE-2025-65945HIGH7.5
  • JavaScriptJavaScript
  • jws
NoYesDec 04, 2025
CVE-2025-66404MEDIUM6.4
  • JavaScriptJavaScript
  • mcp-server-kubernetes
NoYesDec 03, 2025
CVE-2025-66479LOW1.8
  • JavaScriptJavaScript
  • @anthropic-ai/sandbox-runtime
NoYesDec 04, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management