GHSA-qr46-rcv3-4hq3 SiYuan Vulnerable to Remote Code Execution via Stored XSS in Notebook Name - Mobile Interface
Remote Code Execution via Stored XSS in Notebook Name - Mobile InterfaceSummarySiYuan'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.9Vulnerable CodeMobile — no escaping (MobileFiles.ts:77)Desktop — properly escaped (Files.ts:104)Backend — sends unescaped name (notebook.go:104-116)`model.RenameBox()` only validates length (512 chars max) and emptiness — no HTML sanitization.Electron — Node.js in renderer (main.js:422-426)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)On Linux/macOS:**Confirmed:** API accepts the name without escaping. The `renamenotebook` WebSocket event broadcasts the raw HTML to all connected clients.2. Mobile client renders and executesWhen 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 contentThe HTML/JS payload is preserved verbatim in the WebSocket event.4. Data exfiltration variant5. Reverse shell variantAttack ScenarioIn a multi-user SiYuan deployment, an attacker with editor role renames a notebook with an RCE payloadThe `renamenotebook` event broadcasts the payload to ALL connected clientsAny user viewing the file tree on the mobile interface (or desktop in narrow/mobile layout) triggers the payload`nodeIntegration: true` gives the injected JavaScript full OS accessAttacker 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 restartsPropagates via cloud sync to all synced devicesAffects all mobile interface users and desktop users in mobile/narrow layoutInconsistent escaping — desktop is safe, mobile is not (indicates oversight)Can steal files, credentials, SSH keys, install backdoors, open reverse shellsSuggested Fix1. Apply the same escaping used in the desktop version2. Sanitize notebook names on the backend3. Long-term: Harden Electron configuration
CVSS v4.0 score: 5.1