Summary
SiYuan stores attribute-view field names without HTML escaping and inserts them into sort-menu option elements through innerHTML, allowing stored cross-site scripting. An attacker who can rename a database field may cause arbitrary JavaScript to run when a user opens the sort menu; in the desktop client, enabled Node integration may increase this to operating-system code execution.
Affected context
The vulnerability occurs in SiYuan attribute views when database field names are treated as trusted content while constructing the sort menu. It requires a deployment in which a field name can be changed or otherwise controlled by an attacker, followed by a victim opening the affected menu. The consequences are more severe in desktop environments where Node integration is enabled.
Exploit preconditions
- Attack surface: SiYuan's attribute-view sort menu
- Required access: Ability to rename or influence a database field name
- Trigger point: A user opens the sort menu containing the affected field
- Why exploitation is possible: Field names are interpolated into HTML
option elements without adequate output encoding, allowing browser-interpreted
markup and script content to reach the rendered interface
Why this happens
The underlying bug is context-inappropriate output handling. User-controlled field names are inserted into an HTML context using innerHTML without escaping or safe DOM construction, so data is interpreted as markup rather than displayed as text. This behavior maps to CWE-79, Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.
Potential impact
- Arbitrary JavaScript may execute in the SiYuan interface
- Session data or accessible application information could be exposed
- User actions may be performed within the application's security context
- The desktop client may permit broader code execution when Node integration is enabled
- Workspaces or stored content could be modified or corrupted
General mitigation guidance
Mitigation generally focuses on treating database field names as untrusted
display data and preserving a strict separation between content and markup.
Common defensive patterns include:
- Use text-oriented DOM APIs such as textContent when rendering field names
- Apply context-appropriate HTML encoding whenever templating is unavoidable
- Prefer safe DOM construction over string-based innerHTML interpolation
- Validate and constrain field-name content without relying on validation alone
- Reduce or disable privileged Node integration in desktop renderer contexts
- Apply least privilege and isolate renderer capabilities from operating-system APIs
- Use a restrictive content security policy as defense in depth
How teams detect issues like this
Organizations can look for:
- Static-analysis findings involving innerHTML, HTML templates, or string-built option elements
- Code-review signals where user-controlled names, labels, or metadata enter HTML contexts
- Tests that render special characters and markup-like input in every field-name display path
- Policy checks requiring contextual output encoding or text-only DOM APIs
- Runtime monitoring for unexpected script execution or renderer-to-main-process requests
Automated code-review and SAST tools may help identify unsafe HTML sinks, but
findings should be verified against the actual rendering context.

