Summary
SiYuan contains a stored cross-site scripting vulnerability in table column width handling. An attacker who can submit or modify column-width data through the affected API may inject content into style attributes, causing script execution whenever affected table cells are rendered.
In Electron deployments with Node integration enabled, successful exploitation could extend beyond the renderer and enable arbitrary code execution with the application's available privileges.
Affected context
The issue occurs in SiYuan table rendering when column-width values supplied through the setAttrViewColWidth API are incorporated into style attributes without adequate validation or escaping. It is particularly risky when attacker-controlled or insufficiently trusted users can create or modify table metadata and when the resulting content is opened in an Electron renderer with Node integration enabled.
Exploit preconditions
- Attack surface: SiYuan table metadata and the
setAttrViewColWidthAPI - Required access: The ability to create, modify, synchronize, or otherwise influence table column-width values
- Trigger point: Rendering table cells whose styles contain the stored value
- Why exploitation is possible: Width data is accepted without sufficiently restrictive validation or context-aware escaping, allowing stored content to escape the intended style attribute and introduce executable markup or event-handler behavior
Why this happens
The vulnerability is caused by treating a table column-width value as trusted presentation data without enforcing its expected format or applying output encoding appropriate for a style attribute.
When attacker-controlled values are inserted into HTML or DOM-related style contexts, insufficient validation can allow the value to alter surrounding markup and create an executable cross-site scripting condition. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting. Electron-specific security settings, such as Node integration, can increase the consequences of renderer-side script execution.
Potential impact
- Stored script execution in users' rendered table views
- Theft or manipulation of application-visible data
- Actions performed in the victim's application context
- Compromise of the Electron renderer process
- Arbitrary local code execution when renderer privileges and Node integration permit it
- Possible access to files, credentials, or connected services available to the application
General mitigation guidance
Mitigation generally focuses on treating column dimensions as strictly typed presentation values rather than free-form strings.
Common defensive patterns include:
- Accepting only a narrowly defined numeric width format with safe bounds
- Rejecting unexpected characters and malformed values at the API boundary
- Applying context-aware output encoding when values are placed into style attributes or DOM properties
- Prefering safe DOM style APIs over string-based HTML or attribute construction
- Avoiding Node integration for untrusted renderer content
- Using context isolation, restrictive content security policies, and minimal preload exposure
- Separating user-authored content from privileged application capabilities
- Applying least privilege to the Electron process and its accessible local resources
How teams detect issues like this
High-level detection can combine:
- Static analysis for string concatenation or template interpolation into HTML, attributes, and style contexts
- Code review checks for API fields that are expected to be numeric but are handled as unrestricted strings
- Tests using malformed, boundary, and context-breaking input to verify rejection and safe rendering
- Repository-wide searches for direct HTML construction and unsafe DOM insertion
- Electron configuration reviews covering Node integration, context isolation, preload exposure, and content security policy
- Runtime monitoring for unexpected renderer navigation, script execution, or privileged API access
Automated security review tools can help identify likely injection sinks, but findings should be confirmed against the actual rendering and trust boundaries.

