Summary
SiYuan's Bazaar marketplace fails to sanitize package metadata and README content, enabling stored cross-site scripting in the desktop client.
Malicious package authors can inject arbitrary HTML and JavaScript that, when viewed by users, executes with Electron's nodeIntegration privileges, potentially leading to remote code execution on their systems.
Affected context
This vulnerability occurs in the SiYuan application when users browse packages in the Bazaar marketplace.
It manifests specifically where untrusted package metadata (such as displayName, description, and README fields) is rendered without proper HTML or script sanitization.
The risk is heightened in environments where the Electron shell is configured with nodeIntegration enabled, allowing web content to interact directly with the underlying OS APIs.
Exploit preconditions
- Attack surface: SiYuan Bazaar marketplace views within the Electron-based desktop client
- Required access: Ability for an attacker to publish or modify a package with crafted metadata or README content
- Trigger point: Any user browsing, viewing details, or reading README content of the malicious package within the Bazaar
- Why exploitation is possible: User-supplied HTML and JavaScript from package metadata is rendered in a privileged web context without sanitization, and nodeIntegration exposes OS-level capabilities to the injected script
Why this happens
The core issue is the direct rendering of untrusted content in a privileged web view without adequate sanitization or context isolation.
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where user-controlled data is inserted into an HTML/JavaScript context and executed in the victim's browser or webview.
In this case, the use of Electron with nodeIntegration further amplifies the impact by allowing injected scripts to access Node.js APIs and execute OS-level commands, converting a typical XSS into a full remote code execution vector.
Potential impact
- Malicious JavaScript can execute whenever users view a crafted Bazaar package
- Attackers may execute arbitrary OS commands through Node.js APIs exposed by nodeIntegration
- User data within SiYuan can be accessed, modified, or exfiltrated
- Compromised systems may be used as a foothold for further lateral movement
- Persistent compromise of a user's environment through installation of additional malware or backdoors
General mitigation guidance
Effective mitigation focuses on breaking the chain between untrusted content and privileged execution.
Common defensive patterns include:
- Applying robust HTML and script sanitization to all user-supplied package metadata and README content before rendering
- Using context-aware output encoding for dynamic content inserted into the DOM
- Disabling or strictly limiting nodeIntegration and other high-privilege webview features, favoring isolated, sandboxed renderers
- Rendering untrusted marketplace content in a low-privilege, isolated process or browser context with no direct OS access
- Adopting a default-deny model for active content, enabling scripts only where strictly necessary and from trusted sources
How teams detect issues like this
Organizations can detect and reduce this class of issue through:
- Static analysis rules that flag direct insertion of untrusted data into HTML, innerHTML, or templating contexts without sanitization
- Code review checklists focusing on any rendering of marketplace or user-supplied content in Electron/webview components
- Security linters and policies that highlight use of nodeIntegration, remote module, or other high-risk Electron settings in combination with dynamic content
- Automated tests or fuzzing that inject benign script markers into package metadata to detect unexpected script execution paths

