Summary
SiYuan through version 3.7.3 contains a cross-site scripting vulnerability in the block-reference autocomplete popup. Unsanitized block metadata can execute script when a victim searches for a crafted block, and SiYuan's Electron configuration may allow that script to invoke operating-system commands.
Affected context
The vulnerability occurs in SiYuan's Electron-based editor when block-reference autocomplete results are generated. It requires a block whose name, alias, or memo contains attacker-controlled markup and a victim who opens the autocomplete popup by entering a block-reference search. The risk is greater when Electron security controls such as context isolation and content security policy are disabled.
Exploit preconditions
- Attack surface: The block-reference autocomplete hint popup in the SiYuan editor
- Required access: Ability to create or modify a block's name, alias, or memo metadata
- Trigger point: Rendering autocomplete results after a victim enters a block-reference search
- Why exploitation is possible: Metadata is concatenated into HTML without context-appropriate escaping, allowing browser script execution; permissive Electron settings may expose privileged Node.js capabilities
Why this happens
The issue results from inserting attacker-influenced block metadata directly into an HTML string without output encoding or safe DOM construction. This is a reflected or stored-style cross-site scripting pattern, depending on how the crafted metadata is persisted and displayed, and maps to CWE-79: Improper Neutralization of Input During Web Page Generation. The impact is amplified because the affected Electron renderer may run with Node.js integration enabled, context isolation disabled, and no effective content security policy.
Potential impact
- Arbitrary script execution in a victim's SiYuan renderer
- Access to sensitive application or local user data
- Execution of operating-system commands through exposed Node.js capabilities
- Compromise of the user's workstation account
- Modification, deletion, or exfiltration of accessible files
General mitigation guidance
Mitigation generally focuses on treating block metadata as untrusted content and maintaining strong Electron renderer boundaries.
Common defensive patterns include:
- Escaping metadata for the exact HTML context, or constructing DOM nodes through safe text APIs
- Separating data from markup and avoiding string-based HTML generation for autocomplete results
- Disabling Node.js integration in renderer windows and enabling context isolation
- Applying a restrictive content security policy where compatible with application functionality
- Validating and constraining metadata at input boundaries without relying on validation as a substitute for output encoding
- Limiting renderer privileges and exposing only narrowly scoped, protected APIs through a preload layer
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for unsanitized string concatenation passed to HTML-rendering APIs
- Code review checks covering innerHTML, template construction, and dynamic markup generation
- Electron configuration reviews for Node.js integration, context isolation, preload exposure, and CSP settings
- Dynamic testing with harmless encoded markers in block metadata to verify correct text rendering
- Policy enforcement that requires contextual output encoding and secure renderer defaults
Automated security review tools may help flag dangerous DOM sinks and permissive Electron settings, but findings should be validated against the application's rendering flow.

