Summary
SiYuan contains a stored cross-site scripting vulnerability in confirmDialog() because package and notebook names are inserted into innerHTML without escaping. An attacker who can submit a malicious bazaar package or influence a notebook name may cause script content to execute in another user's browser when the affected dialog is displayed.
Affected context
The vulnerability occurs in SiYuan workflows that display package or notebook names through confirmation dialogs. It becomes risky when attacker-controlled names are stored and later rendered as HTML without context-appropriate output encoding, such as during package removal or encrypted-notebook unlocking.
Exploit preconditions
- Attack surface: Web-based SiYuan user interface and confirmation dialogs
- Required access: Ability to submit or cause storage of a package name or notebook name containing markup
- Trigger point: A victim views the affected confirmation dialog, such as during package uninstallation or notebook unlocking
- Why exploitation is possible: User-controlled values are interpolated into
innerHTMLwithout sufficient escaping or sanitization
Why this happens
The underlying bug is improper neutralization of user-controlled input in an HTML context. The application treats package and notebook names as trusted markup and inserts them directly into DOM content through innerHTML. This behavior maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.
Potential impact
- Malicious script content may execute in a victim's browser context
- An attacker could perform actions available to the victim within SiYuan
- Sensitive information visible to the application may be exposed
- User settings or notebook content could be modified
- The vulnerability could support phishing or unauthorized account activity
General mitigation guidance
Mitigation generally focuses on treating package and notebook names as untrusted data throughout their lifecycle.
Common defensive patterns include:
- Prefer text-content DOM APIs or framework-safe rendering over direct
innerHTMLinterpolation - Apply context-appropriate output encoding at every HTML rendering boundary
- Use narrowly scoped sanitization only where formatted markup is an intentional requirement
- Validate names against an explicit, restrictive format when business rules permit
- Enforce content security controls that limit script execution as a defense in depth
- Apply least privilege to browser sessions and separate administrative workflows where practical
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for
innerHTML, unsafe template interpolation, and equivalent DOM sinks - Code review checks tracing package, notebook, and other persisted names into HTML rendering
- Tests that render markup-bearing input in every dialog and notification path
- Dynamic security testing for stored payload execution across user workflows
- Policy enforcement requiring safe DOM APIs or approved output-encoding utilities
- Automated code review tools that flag untrusted data flowing into browser script or HTML contexts

