Summary
SiYuan Desktop before v3.7.2 contains a cross-site scripting vulnerability in its siyuan:// protocol handler that injects unescaped icon parameters into a tab header via innerHTML.
On systems where the renderer runs with nodeIntegration enabled, this client-side XSS can be escalated to arbitrary operating-system command execution through access to Node APIs.
Affected context
This vulnerability occurs in SiYuan Desktop when handling siyuan://plugins/<name> links that reference a plugin name not currently installed.
In these cases, the application creates a custom tab and uses the link's icon parameter as HTML for the tab header without escaping or sanitization.
On Electron-based deployments where nodeIntegration is set to true in the renderer, any JavaScript executed in this context can reach Node's require function and spawn local processes.
Exploit preconditions
- Attack surface: SiYuan Desktop application via siyuan:// URL handling and plugin links.
- Required access: Ability to cause the victim application to open a crafted siyuan://plugins/<name> link (e.g., through a hyperlink, document, or URL handler invocation).
- Trigger point: Opening a plugins/<name> link pointing to a non-installed plugin, with a malicious icon parameter that is inserted into the tab header via innerHTML.
- Why exploitation is possible: The icon parameter is treated as trusted HTML and written directly into the DOM without escaping or sanitization. In an Electron renderer with nodeIntegration:true, injected script can access Node APIs such as require('child_process'), turning a browser-context XSS into native command execution.
Why this happens
The underlying bug is unsafe handling of user-controlled HTML in the application's UI, mapping directly to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The siyuan:// protocol handler passes the icon parameter from a plugins/<name> link into a tab header using innerHTML, assuming the value is benign markup.
Because there is no escaping, filtering, or content policy enforcement, attackers can supply elements with JavaScript event handlers (e.g., <img onerror=...>), causing script execution in the renderer.
In the specific Electron configuration with nodeIntegration:true, this script runs with elevated capabilities, enabling access to Node's module system and local OS command execution, extending a client-side scripting bug into a host-level code execution issue.
Potential impact
- Malicious JavaScript may execute within the SiYuan Desktop renderer context.
- Attackers could access Node's require API and execute arbitrary operating-system commands.
- The local user account's data and files could be read, modified, or exfiltrated.
- The integrity of documents and notes managed by SiYuan can be altered or corrupted.
- The compromised host may be used as a foothold for further lateral movement in the user's environment.
General mitigation guidance
Effective mitigations focus on removing direct injection of untrusted HTML and reducing renderer privileges.
Common defensive patterns include:
- Treating protocol handler parameters as untrusted input and applying robust HTML escaping or sanitization before inserting into the DOM.
- Avoiding innerHTML for UI composition; prefer safe DOM APIs that do not interpret raw markup from external input.
- Applying a security-conscious Electron configuration: disabling nodeIntegration in renderer processes by default and separating browser UI from privileged Node functionality.
- Introducing clear trust boundaries so that data originating from links, URLs, or external documents cannot directly influence privileged UI components.
- Leveraging content security policies and strict type validation for protocol parameters (e.g., icon should be constrained to URLs or known-safe tokens).
How teams detect issues like this
Detection can rely on a combination of code-level and configuration-level checks:
- Static analysis rules that flag use of innerHTML, outerHTML, or similar sinks when they receive data derived from URLs, protocol handlers, or other untrusted sources.
- Code review practices that scrutinize Electron-specific configurations, especially nodeIntegration and access to require in renderer processes.
- Security-oriented linters or automated review tools that highlight XSS-prone patterns and unsafe DOM construction in TypeScript/JavaScript code.
- Policy enforcement that requires sanitization or encoding of all data passed from custom protocol handlers into UI components.
- Runtime instrumentation or logging that can surface unexpected protocol parameter values and anomalous script execution behaviors in the renderer.

