Summary
SiYuan before 3.8.4 renders document titles as HTML in the backlink dock tree without escaping markup characters. An attacker who can influence a title through the rename API or a crafted notebook may execute script in the Electron renderer, potentially reaching privileged command-execution capabilities.
Affected context
The issue occurs in SiYuan's Electron desktop interface when document titles are displayed in the backlink dock tree as HTML rather than as escaped text. It becomes risky when an attacker can create or modify notebook content, invoke a title-changing API, or otherwise cause a malicious title to be rendered in a user's Electron session.
Exploit preconditions
- Attack surface: Document-title rendering in the Electron backlink dock tree
- Required access: Ability to influence a document title through the rename API, a crafted notebook, or another supported content-import path
- Trigger point: Opening or viewing the affected backlink tree so the title is rendered
- Why exploitation is possible: Markup is inserted into the renderer without adequate output encoding, allowing attacker-controlled content to be interpreted as script
- Additional security factor: The impact depends on the renderer's exposed privileges, including whether access to Node.js or
child_processis available
Why this happens
The underlying bug is a failure to contextually encode untrusted document-title content before inserting it into an HTML-rendering user-interface component. Markup characters are therefore treated as executable content instead of display text. This is a stored or persistent cross-site scripting pattern mapped to CWE-79, with the Electron renderer's privilege boundary potentially increasing the consequences beyond ordinary browser-side script execution.
Potential impact
- An attacker-controlled script may execute in the Electron renderer
- User data or application state could be read or modified
- Sessions or locally accessible secrets may be exposed
- Renderer privileges could enable command execution where unsafe integrations are available
- The application may be used as a stepping stone for local compromise or data tampering
General mitigation guidance
Mitigation generally focuses on treating document titles as untrusted text throughout
the rendering pipeline.
Common defensive patterns include:
- Apply context-appropriate output encoding when inserting titles into the DOM
- Prefer text-based DOM APIs over HTML interpretation for document names
- Sanitize only where rich text is explicitly required, using a narrowly configured allowlist
- Maintain a strict Electron isolation boundary and avoid exposing Node.js or command-execution APIs to renderer content
- Enforce least privilege for application processes and limit filesystem and process access
- Validate and constrain title input at API and storage boundaries without relying on validation as a substitute for output encoding
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying untrusted title or notebook data passed to HTML sinks such as
innerHTML - Code review checks for direct DOM HTML assignment, template interpolation, or disabled Electron isolation controls
- Dynamic tests that render markup-like title values and verify that they remain inert text
- Repository-wide searches for renderer bridges exposing filesystem, shell, or process functionality
- CI policies requiring contextual output encoding and security tests for content-rendering components
- Automated code-review tools that flag unsafe HTML sinks and untrusted-to-renderer data flows

