Summary
SiYuan versions before 3.7.4 do not properly validate or escape the color field used by attribute-view select options. An attacker who can store a crafted value may trigger arbitrary JavaScript when users view a database containing the malicious select field.
Affected context
The vulnerability occurs in SiYuan attribute-view databases when select-option color values are rendered without consistent output encoding. It affects deployments where an attacker can create or modify database content that is later viewed by other users, and where one or more of the affected render paths processes the stored value in an HTML context.
Exploit preconditions
- Attack surface: SiYuan attribute-view database rendering
- Required access: Permission to create or modify content containing a select field, or another trusted workflow that stores attacker-controlled values
- Trigger point: A user views a database containing the affected select option
- Why exploitation is possible: The color value is not consistently validated or escaped at multiple render sites, allowing browser-interpreted markup to be stored and executed in the viewer's session
Why this happens
The underlying bug is insufficient output encoding and input validation for a stored value that is inserted into HTML-rendered attribute-view content. Quotation marks in the color field can alter attribute boundaries, allowing attacker-controlled event-handler attributes to reach the browser. 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 context of a viewing user's SiYuan session
- Session-related information or accessible application data could be exposed
- Database content may be modified or actions may be performed on behalf of a victim
- Malicious scripts could be used for phishing, defacement, or further compromise of accessible resources
General mitigation guidance
Mitigation generally focuses on treating attribute-view values as untrusted data throughout their lifecycle.
Common defensive patterns include:
- Applying context-appropriate HTML attribute encoding at every render site
- Validating color values against a strict allowlist of supported formats
- Using safe DOM APIs and framework auto-escaping rather than assembling HTML strings
- Avoiding interpretation of stored values as markup or executable content
- Applying least privilege to user sessions and restricting sensitive actions that can be initiated from rendered content
- Centralizing rendering and validation logic to reduce inconsistent handling across multiple sites
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis for string concatenation or templating that inserts database values into HTML attributes
- Code review checks for missing context-sensitive output encoding
- Tests that store and render metacharacters in every supported field and view
- Dynamic application testing across all attribute-view render paths
- Content security policy monitoring for unexpected script execution and violation reports
- Automated security review tools that flag unescaped user-controlled values in web output

