Summary
SiYuan contains a stored cross-site scripting vulnerability because block names, aliases, and memo fields are not properly escaped when rendered in hints, backlinks, and breadcrumbs. An attacker who can set a block field containing script-capable markup may cause code to execute in another user's browser when that user views a document referencing or displaying the block.
Affected context
The issue affects SiYuan deployments where user-controlled block names, aliases, or memo fields are displayed through hint, backlink, or breadcrumb rendering paths without context-appropriate output encoding. It is most relevant when content created or modified by one user is later viewed by other users in the same application context, particularly where those users have higher privileges or access to sensitive documents.
Exploit preconditions
- Attack surface: SiYuan document and block-rendering interfaces
- Required access: Permission to create or modify a block name, alias, or memo
- Trigger point: Another user views a document, hint, backlink, or breadcrumb that renders the affected field
- Why exploitation is possible: User-controlled content reaches an HTML-rendering context without sufficient output encoding or sanitization
Why this happens
The vulnerability results from treating block metadata as trusted display content rather than as untrusted input. Rendering functions for hints, backlinks, and breadcrumbs fail to apply context-appropriate escaping to block names, aliases, and memo fields, allowing markup intended as data to be interpreted by the browser. This behavior maps to CWE-79, Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.
Potential impact
- An attacker may execute script in another user's browser session.
- Session-associated information or page data could be exposed.
- Malicious script could perform actions available to the viewing user.
- Content could be altered, misleading links could be presented, or users could be redirected.
- Higher-privileged users may be targeted for broader unauthorized changes.
General mitigation guidance
Mitigation generally focuses on treating all block metadata as untrusted and
applying output encoding at every rendering sink.
Common defensive patterns include:
- Applying context-appropriate HTML escaping to names, aliases, and memo fields.
- Using safe rendering APIs that distinguish text from markup by default.
- Allowing rich text only through a narrowly defined, sanitized allowlist.
- Validating and normalizing metadata at input boundaries without relying on validation alone.
- Enforcing Content Security Policy and related browser protections as defense in depth.
- Limiting user privileges and isolating administrative interfaces from untrusted content.
How teams detect issues like this
Organizations commonly detect this class of issue through:
- Static analysis for unsafe interpolation into HTML, template, or DOM sinks.
- Code review checks tracing block metadata from storage and user input to rendering functions.
- Tests that verify special characters and script-capable markup remain inert in every display context.
- Policy enforcement requiring framework-native auto-escaping and approved sanitization libraries.
- Dynamic application testing that examines stored content across hints, backlinks, breadcrumbs, and related views.
- Automated code review tools that flag unescaped user-controlled values in web templates or client-side rendering code.

