SiYuan stored XSS leads to code execution (CVE-2026-40322)
CVE-2026-40322
Click a malicious diagram in SiYuan notes and an attacker gains full remote code execution on your PC. Update to version 3.6.4 to patch this critical flaw.
Patch now - CVE-2026-40322 is a critical remote code execution flaw in SiYuan versions 3.6.3 and below that lets attackers execute arbitrary code on the victim’s desktop when they click a malicious diagram node. Update to version 3.6.4 or later immediately.
Overview
A critical security vulnerability in the SiYuan personal knowledge management software allows attackers to execute arbitrary code on a victim’s desktop system. The flaw, tracked as CVE-2026-40322, stems from how the application renders diagrams within user notes.
Vulnerability Details
SiYuan versions 3.6.3 and below render Mermaid diagrams with insecure default settings (securityLevel: "loose"). This allows malicious javascript: URLs embedded within a diagram’s code block to be injected directly into the webpage’s Document Object Model (DOM) via innerHTML. When a user opens a note containing a malicious diagram, the attacker’s script executes in the context of the SiYuan application.
The impact is significantly higher on the desktop application built with Electron. These builds have nodeIntegration enabled and contextIsolation disabled. This configuration flaw escalates the stored Cross-Site Scripting (XSS) vulnerability into full arbitrary code execution on the victim’s operating system when they interact with the malicious diagram element.
Impact
An attacker who can create or edit a note containing a Mermaid diagram-for example, by sharing a malicious note file or compromising a knowledge base-can embed code that executes when another user views it. On affected desktop installations, this code execution is not confined to the browser sandbox and can perform actions like installing malware, stealing files, or creating backdoors.
The vulnerability requires user interaction (a victim must open the note and click the diagram node), but the potential consequence is a complete compromise of the local machine. The CVSS v3.1 base score is 9.0 (Critical).
Remediation and Mitigation
The primary and definitive remediation is to update SiYuan to version 3.6.4 or later. This version fixes the insecure Mermaid rendering configuration.
Action Required:
- Update Immediately: All users of SiYuan, especially the desktop version, must upgrade to version 3.6.4 without delay.
- Verify Version: Check your current SiYuan version in the application’s settings or about dialog.
- Exercise Caution: Until updated, be cautious when opening shared note files or data packs from untrusted sources.
There is no effective workaround for this vulnerability; patching is essential.
Security Insight
This vulnerability highlights the compounded risk when web application vulnerabilities are inherited by Electron-based desktop clients without appropriate sandboxing. The chain of a simple stored XSS leading to full local code execution is a recurring pattern, similar to past incidents in other Electron apps where disabled contextIsolation turned script injection into a critical system threat. It underscores the necessity for developers to rigorously apply Electron security best practices, especially contextIsolation: true, by default.
Further Reading
Never miss a critical vulnerability
Get real-time security alerts delivered to your preferred platform.
Related Advisories
SiYuan is a personal knowledge management system. Prior to version 3.6.2, a vulnerability allows crafted block attribute values to bypass server-side attribute escaping when an HTML entity is mixed wi...
SiYuan is a personal knowledge management system. Prior to version 3.6.2, an attacker who can place a malicious URL in an Attribute View mAsse field can trigger stored XSS when a victim opens the Gall...
SiYuan is a personal knowledge management system. In versions 3.6.0 and below, SanitizeSVG has an incomplete blocklist — it blocks data:text/html and data:image/svg+xml in href attributes but misses d...
SiYuan is a personal knowledge management system. Prior to version 3.5.9, an unauthenticated reflected XSS vulnerability exists in the dynamic icon API endpoint "GET /api/icon/getDynamicIcon" when typ...
Other B3log Siyuan Vulnerabilities
SiYuan is a personal knowledge management system. Prior to version 3.6.2, an attacker who can place a malicious URL in an Attribute View mAsse field can trigger stored XSS when a victim opens the Gall...
SiYuan is a personal knowledge management system. Prior to version 3.6.2, a malicious website can achieve Remote Code Execution (RCE) on any desktop running SiYuan by exploiting the permissive CORS po...
SiYuan is a personal knowledge management system. Prior to version 3.6.2, a vulnerability allows crafted block attribute values to bypass server-side attribute escaping when an HTML entity is mixed wi...
SiYuan is a personal knowledge management system. In versions 3.6.0 and below, the /api/lute/html2BlockDOM on the desktop copies local files pointed to by file:// links in pasted HTML into the workspa...