Summary
SiYuan desktop before v3.7.2 contains a reflected cross-site scripting vulnerability in the bazaar plugin readme handler triggered via crafted siyuan:// deep links.
By injecting HTML through the plugin name parameter, an attacker can execute arbitrary code in an insecure Electron renderer, gaining full Node.js-level access to the desktop environment.
SiYuan desktop before v3.7.2 contains a reflected cross-site scripting vulnerability in the bazaar plugin readme handler triggered via crafted siyuan:// deep links.
By injecting HTML through the plugin name parameter, an attacker can execute arbitrary code in an insecure Electron renderer, gaining full Node.js-level access to the desktop environment.
Affected context
This vulnerability appears in SiYuan desktop when the bazaar plugin readme handler:
- Accepts plugin name input from
siyuan://deep links - Reflects that value into the DOM without output encoding or sanitization
- Renders content using
insertAdjacentHTMLinside an Electron renderer with Node.js integration or related powerful APIs enabled
It becomes relevant when users can be convinced to open crafted deep links or when other components can programmatically trigger such URLs within the application context.
This vulnerability appears in SiYuan desktop when the bazaar plugin readme handler:
- Accepts plugin name input from
siyuan://deep links - Reflects that value into the DOM without output encoding or sanitization
- Renders content using
insertAdjacentHTMLinside an Electron renderer with Node.js integration or related powerful APIs enabled
It becomes relevant when users can be convinced to open crafted deep links or when other components can programmatically trigger such URLs within the application context.
Exploit preconditions
- Attack surface: SiYuan desktop application handling
siyuan://deep links - Required access: Ability to supply a malicious deep link to a user or process that opens it in SiYuan (e.g., via email, chat, browser redirect, local HTML file, or inter-app communication)
- Trigger point: Invocation of the bazaar plugin readme handler with an attacker-controlled plugin name parameter that is rendered via
insertAdjacentHTML - Why exploitation is possible: The Electron renderer trusts unsanitized plugin name input, inserts it directly into the DOM as HTML, and runs with powerful Node.js capabilities, allowing DOM-level script execution to escalate to arbitrary code execution on the host system.
- Attack surface: SiYuan desktop application handling
siyuan://deep links - Required access: Ability to supply a malicious deep link to a user or process that opens it in SiYuan (e.g., via email, chat, browser redirect, local HTML file, or inter-app communication)
- Trigger point: Invocation of the bazaar plugin readme handler with an attacker-controlled plugin name parameter that is rendered via
insertAdjacentHTML - Why exploitation is possible: The Electron renderer trusts unsanitized plugin name input, inserts it directly into the DOM as HTML, and runs with powerful Node.js capabilities, allowing DOM-level script execution to escalate to arbitrary code execution on the host system.
Why this happens
The underlying issue is unvalidated, unsanitized user-controlled data being embedded directly into HTML content in a privileged renderer.
The bazaar plugin readme handler uses insertAdjacentHTML with plugin name data taken from a deep link parameter without escaping or context-aware output encoding, enabling reflected XSS.
In an Electron environment where the renderer process has Node.js access or is configured insecurely (e.g., nodeIntegration enabled, weak preload isolation), this XSS moves beyond typical browser constraints and maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), turning a markup injection into a full arbitrary code execution primitive.
The underlying issue is unvalidated, unsanitized user-controlled data being embedded directly into HTML content in a privileged renderer.
The bazaar plugin readme handler uses insertAdjacentHTML with plugin name data taken from a deep link parameter without escaping or context-aware output encoding, enabling reflected XSS.
In an Electron environment where the renderer process has Node.js access or is configured insecurely (e.g., nodeIntegration enabled, weak preload isolation), this XSS moves beyond typical browser constraints and maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), turning a markup injection into a full arbitrary code execution primitive.
Potential impact
- Attacker-controlled JavaScript execution within the Electron renderer
- Arbitrary Node.js code execution on the victim's machine
- Access to local files, application data, and OS-level capabilities through Node.js APIs
- Theft or tampering of SiYuan notes, plugins, and configuration data
- Installation of persistent malware or backdoors via filesystem and process APIs
- Lateral movement using credentials, tokens, or other secrets read from the desktop environment
- Attacker-controlled JavaScript execution within the Electron renderer
- Arbitrary Node.js code execution on the victim's machine
- Access to local files, application data, and OS-level capabilities through Node.js APIs
- Theft or tampering of SiYuan notes, plugins, and configuration data
- Installation of persistent malware or backdoors via filesystem and process APIs
- Lateral movement using credentials, tokens, or other secrets read from the desktop environment
General mitigation guidance
Effective mitigation focuses on eliminating unsafe rendering patterns and reducing renderer privileges:
- Apply strict output encoding or contextual escaping to all user-controlled values before inserting them into the DOM, avoiding raw
insertAdjacentHTMLfor untrusted data. - Use dedicated templating or UI frameworks that handle encoding automatically rather than constructing HTML strings manually.
- Enforce robust input validation for deep link parameters, rejecting or constraining unexpected HTML or script-like content.
- Harden Electron configuration by disabling
nodeIntegration, using context isolation, and limiting access to sensitive APIs through controlled preload bridges with narrow, audited interfaces. - Adopt least-privilege principles for renderer processes, ensuring that even if script execution occurs, access to filesystem and OS-level capabilities is minimized.
Effective mitigation focuses on eliminating unsafe rendering patterns and reducing renderer privileges:
- Apply strict output encoding or contextual escaping to all user-controlled values before inserting them into the DOM, avoiding raw
insertAdjacentHTMLfor untrusted data. - Use dedicated templating or UI frameworks that handle encoding automatically rather than constructing HTML strings manually.
- Enforce robust input validation for deep link parameters, rejecting or constraining unexpected HTML or script-like content.
- Harden Electron configuration by disabling
nodeIntegration, using context isolation, and limiting access to sensitive APIs through controlled preload bridges with narrow, audited interfaces. - Adopt least-privilege principles for renderer processes, ensuring that even if script execution occurs, access to filesystem and OS-level capabilities is minimized.
How teams detect issues like this
Organizations can detect similar XSS and Electron misuse issues through a combination of review and tooling:
- Static analysis rules targeting direct usages of
insertAdjacentHTML,innerHTML, or similar sinks with data originating from URL parameters, deep links, or other external inputs. - Code review checklists that flag insecure Electron configurations (e.g.,
nodeIntegration: true, missingcontextIsolation, broad preload bridges) combined with dynamic HTML insertion. - Automated scanning for cross-site scripting patterns, focusing on renderer code paths that handle protocol handlers, custom deep links, or plugin metadata.
- Security policies that prohibit unescaped HTML rendering of external inputs and require threat modeling of Electron privilege boundaries.
Organizations can detect similar XSS and Electron misuse issues through a combination of review and tooling:
- Static analysis rules targeting direct usages of
insertAdjacentHTML,innerHTML, or similar sinks with data originating from URL parameters, deep links, or other external inputs. - Code review checklists that flag insecure Electron configurations (e.g.,
nodeIntegration: true, missingcontextIsolation, broad preload bridges) combined with dynamic HTML insertion. - Automated scanning for cross-site scripting patterns, focusing on renderer code paths that handle protocol handlers, custom deep links, or plugin metadata.
- Security policies that prohibit unescaped HTML rendering of external inputs and require threat modeling of Electron privilege boundaries.

