/

CVE-2026-32751

Severity:

CRITICAL RISK

(9.0)

XSS in SiYuan Mobile File Tree Enables Remote Code Execution

CVE-2026-32751

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Remote Code Execution via Stored XSS in Electron Environment

Severity:

CRITICAL RISK

(9.0)

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 versions 3.6.0 and below contain a stored cross-site scripting vulnerability in the mobile file tree, where notebook names are rendered as HTML without escaping when processed from WebSocket rename events.

An authenticated user who can rename notebooks can inject arbitrary HTML/JavaScript that executes on mobile and narrow-window Electron clients, and due to permissive Electron settings this can escalate to full remote code execution via Node.js APIs.

Affected context

The vulnerability occurs in the mobile file tree rendering logic (MobileFiles.ts) of SiYuan when notebook names are updated over WebSocket (renamenotebook events).

Instead of safely escaping user-controlled notebook names, the mobile client inserts them directly using innerHTML.

While the traditional desktop file tree (Files.ts) applies escapeHtml(), the mobile layout (also used in desktop when the window is narrow) does not, creating a divergence where the same logical data path is handled securely in one view and insecurely in another.

Exploit preconditions

  • Attack surface: Mobile UI and desktop Electron app when using the mobile layout (narrow window view of the file tree).
  • Required access: Authenticated access to a SiYuan workspace with permission to rename notebooks.
  • Trigger point: A victim user opens the file tree in the vulnerable mobile layout or in the Electron desktop app in a narrow window, causing the malicious notebook name to be rendered via innerHTML.
  • Why exploitation is possible: The mobile file tree renderer uses innerHTML directly on notebook names received from WebSocket events without HTML escaping, allowing notebook names to embed script or HTML payloads. In the Electron context configured with nodeIntegration: true and contextIsolation: false, any executed JavaScript gains full Node.js privileges.

Why this happens

This vulnerability stems from inconsistent output encoding between different UI components handling the same data.

The desktop file tree correctly applies escapeHtml() before rendering notebook names, but the mobile file tree uses innerHTML with unescaped input coming from WebSocket renamenotebook events.

Conceptually, this maps to CWE-79: Improper Neutralization of Input During Web Page Generation, where user-controllable data is incorporated into an HTML context without appropriate escaping.

In a browser-only environment this would "only" be stored XSS, but because SiYuan's Electron configuration exposes Node.js APIs to renderer JavaScript, the XSS is effectively an RCE primitive.

Potential impact

  • Execution of arbitrary JavaScript in the context of affected mobile and Electron clients.
  • Full remote code execution on desktops via Node.js APIs (file system access, command execution, process manipulation).
  • Theft or modification of notes, notebooks, and other user data stored by SiYuan.
  • Credential/session token theft or impersonation within the application.
  • Lateral movement if compromised hosts have access to other sensitive resources.

General mitigation guidance

Effective mitigation focuses on consistent output encoding and hardening the runtime environment:

  • Apply strict HTML escaping or context-appropriate encoding to all user-controllable data (such as notebook names) before inserting into the DOM, regardless of view (mobile, desktop, narrow layout).
  • Avoid using innerHTML for dynamic content where possible; prefer text-oriented APIs (e.g., textContent) or templating systems that escape output by default.
  • Enforce a single, shared rendering utility that always escapes notebook names so that both mobile and desktop paths use the same safe behavior.
  • In Electron environments, reduce the impact of any UI injection by disabling nodeIntegration, enabling contextIsolation, and exposing only minimal, audited functionality via preload scripts or IPC bridges.
  • Adopt a least-privilege design for renderer processes so that even if a script executes unexpectedly, direct access to Node.js and the underlying OS is constrained.

How teams detect issues like this

To detect and prevent similar issues, teams can:

  • Use static analysis rules to flag direct assignments to innerHTML and similar DOM sinks when the source is user-controllable or originates from WebSocket/event data.
  • Include code review checklists that explicitly require context-appropriate escaping for all rendered user data, and that scrutinize differences between mobile and desktop view implementations.
  • Implement linting or custom ESLint rules that disallow unescaped DOM injection and require use of safe rendering helpers.
  • Conduct security testing (including XSS-focused tests) on Electron views, particularly where web technologies interact with Node.js, to identify paths where unsafe rendering can escalate to RCE.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/f6d35103f774b65e52f03e018649ff0e57924fb0
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.6.1
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-qr46-rcv3-4hq3

Frequently asked

questions

Exploitation requires network-accessible interaction with a SiYuan instance where the attacker can authenticate and rename notebooks.

Once a malicious notebook name is stored, any user who views the file tree in the vulnerable layout (mobile or narrow Electron window) can be impacted remotely.

The attacker must have valid credentials and sufficient permissions to rename notebooks in a shared or multi-user environment.

Anonymous or unauthenticated users cannot exploit this specific flaw if the application requires authentication for notebook operations.

The most robust fix is to centralize and enforce HTML escaping for all user-derived fields before DOM insertion and to eliminate direct innerHTML usage for user data.

Complement this by locking down Electron's configuration (disabling nodeIntegration and enabling contextIsolation) so that any residual XSS cannot escalate to arbitrary code execution.

Standardize on safe rendering utilities, enforce secure coding guidelines around DOM manipulation, and add automated checks for XSS sinks in the CI pipeline.

For Electron or similar hybrid frameworks, treat renderer JavaScript as potentially hostile and design with strict process isolation and minimal Node.js exposure from the start.

Find out what's already
exploitable in your codebase.