Summary
SiYuan can persist a table caption into its IAL properties without sanitizing it, allowing attacker-controlled content to become stored cross-site scripting when imported or synchronized. If the caption is rendered in the Electron client with Node integration enabled, script execution may escalate to remote code execution in the client context.
Affected context
The issue affects SiYuan deployments before 3.8.10 when table captions are persisted into IAL properties without adequate HTML sanitization. Risk arises when crafted content is imported or synchronized and then rendered by the Electron client; the described impact depends in part on the client's Node integration context.
Exploit preconditions
- Attack surface: Imported or synchronized document content containing a table caption
- Required access: Ability to provide or influence content that reaches a victim's SiYuan client
- Trigger point: Import or sync followed by rendering the affected caption
- Why exploitation is possible: The caption is persisted without HTML sanitization, and its event-handler content may execute in the Electron client context
Why this happens
The application persists attacker-influenced caption data into IAL properties without applying context-appropriate HTML sanitization or encoding. When that data is later rendered as active markup, it can trigger stored cross-site scripting, corresponding to CWE-94. In an Electron environment with Node integration enabled, script execution may have access to capabilities beyond those available to ordinary browser content.
Potential impact
- Script execution in the SiYuan client when affected content is rendered
- Remote code execution with the privileges available to the Electron process
- Exposure or modification of data accessible to the client
- Further compromise of the user's environment, depending on client permissions and configuration
General mitigation guidance
Defensive patterns focus on treating imported and synchronized content as untrusted:
- Sanitize or contextually encode caption data before persistence and rendering
- Prefer safe text-rendering APIs over interpreting user-controlled values as HTML
- Disable Electron Node integration for rendered content where possible, and use context isolation and sandboxing
- Apply restrictive Content Security Policy and minimize renderer privileges
- Validate content against a strict schema while recognizing that validation alone does not replace output encoding
How teams detect issues like this
- Use static analysis to identify unsanitized data flows from imported or synchronized captions into HTML-rendering sinks
- Review code that writes IAL properties and code that renders those properties in the Electron client
- Enforce policies that restrict unsafe HTML APIs and unnecessary Node integration in renderer processes
- Add security tests for encoded or otherwise unusual caption content across import, sync, persistence, and rendering paths
- Automated code review tools may help identify risky data flows and renderer configurations

