/

CVE-2026-66396

Severity:

HIGH RISK

(8.4)

Stored XSS (CWE-79) in SiYuan Gallery and Kanban Covers

CVE-2026-66396

Deferred

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Arbitrary Code Execution via Stored XSS

Severity:

HIGH RISK

(8.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SiYuan before v3.7.2 contains a stored cross-site scripting vulnerability in the rendering of Gallery and Kanban cover images, where a title-img attribute value is interpolated into a style attribute without proper escaping.

Editors can inject malicious handlers that execute arbitrary code in the Electron renderer with full Node.js access when other users open the affected documents, turning a client-side XSS into a high-impact desktop compromise.

SiYuan before v3.7.2 contains a stored cross-site scripting vulnerability in the rendering of Gallery and Kanban cover images, where a title-img attribute value is interpolated into a style attribute without proper escaping.

Editors can inject malicious handlers that execute arbitrary code in the Electron renderer with full Node.js access when other users open the affected documents, turning a client-side XSS into a high-impact desktop compromise.

Affected context

The issue arises in SiYuan's desktop environment when rendering documents that use Gallery or Kanban blocks with cover images.

The vulnerability is present where the title-img Individual Attribute List value is used to build inline style attributes without robust HTML and JavaScript escaping.

It becomes relevant in contexts where multiple users share or sync documents and at least one user has editor-level permissions to modify block attributes.

The issue arises in SiYuan's desktop environment when rendering documents that use Gallery or Kanban blocks with cover images.

The vulnerability is present where the title-img Individual Attribute List value is used to build inline style attributes without robust HTML and JavaScript escaping.

It becomes relevant in contexts where multiple users share or sync documents and at least one user has editor-level permissions to modify block attributes.

Exploit preconditions

  • Attack surface: Document rendering in the SiYuan Electron-based desktop application
  • Required access: Editor permissions on a document or template that supports Gallery and Kanban cover images
  • Trigger point: Victim opens or previews an affected document, causing the unescaped attribute interpolation to render in the UI
  • Why exploitation is possible: The title-img attribute is injected into a style attribute without proper sanitization, enabling injection of script-like constructs (such as onload handlers) that execute in a privileged renderer with Node.js access
  • Attack surface: Document rendering in the SiYuan Electron-based desktop application
  • Required access: Editor permissions on a document or template that supports Gallery and Kanban cover images
  • Trigger point: Victim opens or previews an affected document, causing the unescaped attribute interpolation to render in the UI
  • Why exploitation is possible: The title-img attribute is injected into a style attribute without proper sanitization, enabling injection of script-like constructs (such as onload handlers) that execute in a privileged renderer with Node.js access

Why this happens

The root cause is improper neutralization of user-controlled data before it is injected into HTML attributes, mapping directly to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

SiYuan's rendering path for Gallery and Kanban cover images trusts the title-img Individual Attribute List value and interpolates it directly into a style attribute.

Without a dedicated escaping and validation layer for attribute values, an attacker can craft input that transforms intended presentation data into executable script, which in Electron-based environments can escalate to arbitrary system-level code execution.

The root cause is improper neutralization of user-controlled data before it is injected into HTML attributes, mapping directly to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

SiYuan's rendering path for Gallery and Kanban cover images trusts the title-img Individual Attribute List value and interpolates it directly into a style attribute.

Without a dedicated escaping and validation layer for attribute values, an attacker can craft input that transforms intended presentation data into executable script, which in Electron-based environments can escalate to arbitrary system-level code execution.

Potential impact

  • Execution of arbitrary JavaScript in the Electron renderer
  • Arbitrary Node.js code execution with the privileges of the SiYuan desktop user
  • Theft or corruption of local notes and configuration data
  • Access to local filesystem resources via Node.js APIs
  • Potential installation of malware or backdoors on the victim's machine
  • Execution of arbitrary JavaScript in the Electron renderer
  • Arbitrary Node.js code execution with the privileges of the SiYuan desktop user
  • Theft or corruption of local notes and configuration data
  • Access to local filesystem resources via Node.js APIs
  • Potential installation of malware or backdoors on the victim's machine

General mitigation guidance

Effective mitigation focuses on treating all document attributes as untrusted input and enforcing strict output encoding before injecting them into HTML or CSS contexts.

Common defensive patterns include:

  • Applying context-aware escaping for style and HTML attributes, ensuring that special characters, URL fragments, and script-like payloads are neutralized
  • Introducing a validation layer that restricts title-img values to safe formats (e.g., constrained URLs or predefined tokens instead of raw strings)
  • Designing rendering components to avoid mixing executable contexts with user-controlled data, especially in Electron where JavaScript often has extended privileges
  • Running the renderer with reduced capabilities where feasible (for example, limiting direct Node.js access) to reduce impact if a script is injected

Effective mitigation focuses on treating all document attributes as untrusted input and enforcing strict output encoding before injecting them into HTML or CSS contexts.

Common defensive patterns include:

  • Applying context-aware escaping for style and HTML attributes, ensuring that special characters, URL fragments, and script-like payloads are neutralized
  • Introducing a validation layer that restricts title-img values to safe formats (e.g., constrained URLs or predefined tokens instead of raw strings)
  • Designing rendering components to avoid mixing executable contexts with user-controlled data, especially in Electron where JavaScript often has extended privileges
  • Running the renderer with reduced capabilities where feasible (for example, limiting direct Node.js access) to reduce impact if a script is injected

How teams detect issues like this

Detection usually combines static analysis, targeted code review, and runtime validation.

Common approaches include:

  • Static analysis rules that flag direct concatenation or interpolation of user-controlled data into HTML, CSS, or JavaScript contexts without escaping
  • Code review practices that treat attribute rendering paths and markdown-to-HTML conversions as high-risk areas requiring explicit sanitization checks
  • Automated linting or policy enforcement that mandates use of safe templating helpers for any style, src, or event-handler-related attributes
  • Optional use of security-oriented scanning tools that crawl rendered documents and look for suspicious inline attributes or script-like patterns

Detection usually combines static analysis, targeted code review, and runtime validation.

Common approaches include:

  • Static analysis rules that flag direct concatenation or interpolation of user-controlled data into HTML, CSS, or JavaScript contexts without escaping
  • Code review practices that treat attribute rendering paths and markdown-to-HTML conversions as high-risk areas requiring explicit sanitization checks
  • Automated linting or policy enforcement that mandates use of safe templating helpers for any style, src, or event-handler-related attributes
  • Optional use of security-oriented scanning tools that crawl rendered documents and look for suspicious inline attributes or script-like patterns

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-5rxg-wh59-mg34
vulncheck.comvulncheck.com/advisories/siyuan-before-stored-xss-to-rce-via-title-img-ial

Frequently asked

questions

Exploitation primarily targets environments where multiple users share or sync documents and at least one user has editor permissions. The attack is stored in the document, then executed whenever other users open or render the affected content.

The attacker must have the ability to edit documents or templates that include Gallery or Kanban cover images. Viewer-only access is not sufficient to plant the payload, but viewers are exposed once the malicious document is opened.

The most robust fix is to enforce strict, context-aware output encoding for all user-controlled attributes and to validate title-img values against a limited, non-executable format. Rendering components should rely on hardened templating helpers rather than manual string concatenation.

Adopt a consistent encoding strategy for all rendering paths, treat all document content and attributes as untrusted, and integrate security reviews for any new UI components that interpolate user data. For Electron applications, minimizing direct Node.js exposure in the renderer further reduces the impact of any residual XSS bugs.

Exploitation primarily targets environments where multiple users share or sync documents and at least one user has editor permissions. The attack is stored in the document, then executed whenever other users open or render the affected content.

The attacker must have the ability to edit documents or templates that include Gallery or Kanban cover images. Viewer-only access is not sufficient to plant the payload, but viewers are exposed once the malicious document is opened.

The most robust fix is to enforce strict, context-aware output encoding for all user-controlled attributes and to validate title-img values against a limited, non-executable format. Rendering components should rely on hardened templating helpers rather than manual string concatenation.

Adopt a consistent encoding strategy for all rendering paths, treat all document content and attributes as untrusted, and integrate security reviews for any new UI components that interpolate user data. For Electron applications, minimizing direct Node.js exposure in the renderer further reduces the impact of any residual XSS bugs.

Find out what's already
exploitable in your codebase.