Stored XSS to RCE in SiYuan Mermaid rendering
CVE-2026-40322 affects SiYuan, an open-source personal knowledge management system. In SiYuan 3.6.3 and earlier, Mermaid diagrams are rendered with Mermaid configured with securityLevel set to "loose", and the generated SVG is inserted into the DOM via innerHTML. As a result, attacker-controlled javascript: URLs embedded in Mermaid code blocks can persist into the rendered output, creating a stored cross-site scripting condition. In Electron-based desktop builds, this becomes more severe because application windows are created with nodeIntegration enabled and contextIsolation disabled. Under those conditions, when a victim opens a note containing a malicious Mermaid block and clicks the rendered diagram node, the stored XSS can be escalated to arbitrary code execution on the local system. The issue was fixed in SiYuan 3.6.4.
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
What an attacker gets, and what they’ve been doing with it.
Successful exploitation allows an attacker to store a malicious Mermaid payload in a note and trigger script execution in the victim's SiYuan client when the note is viewed and the rendered diagram node is clicked. In the desktop Electron application, the insecure Electron configuration can elevate this from stored XSS to arbitrary code execution, potentially resulting in full compromise of the victim's local SiYuan context and the confidentiality, integrity, and availability impacts associated with code execution.
If you can’t patch tonight, do this now.
If immediate upgrade is not possible, avoid opening untrusted notes containing Mermaid content, and do not click rendered Mermaid diagram nodes from untrusted sources. In desktop deployments, reducing Electron attack surface by disabling nodeIntegration and enabling contextIsolation would limit XSS-to-RCE escalation, though the provided content only confirms that the issue is fixed in 3.6.4.
Patch, then assume compromise.
Upgrade SiYuan to version 3.6.4 or later, which fixes the vulnerability. The vulnerable behavior exists in versions 3.6.3 and below.
No public exploits tracked yet. Mallory keeps watching.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
5 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.