Summary
SiYuan versions before 3.8.4 contain a path traversal vulnerability in the checkoutRepo endpoint. An authenticated administrator may use crafted sessionID path data to write or overwrite JSON files in pre-existing kernel-writable directories outside the intended workspace.
Affected context
The issue occurs in SiYuan deployments where the checkoutRepo endpoint processes attacker-controlled sessionID values as filesystem path components. Exploitation depends on authenticated administrative access and the presence of a suitable directory outside the workspace where the SiYuan kernel has write permission.
Exploit preconditions
- Attack surface: The authenticated
checkoutRepoapplication endpoint - Required access: A valid session with administrator-level privileges
- Trigger point: Processing a
sessionIDparameter containing directory traversal sequences - Filesystem condition: A target directory must already exist and be writable by the SiYuan kernel
- Why exploitation is possible: Path input is not sufficiently constrained to the intended workspace boundary before JSON file operations occur
Why this happens
The vulnerability results from treating user-controlled path data as a trusted filesystem location. When traversal sequences are accepted without canonicalization and boundary enforcement, a path intended to remain within the workspace can resolve to a location outside it. This behavior maps to CWE-73: External Control of File Name or Path, because an external input influences file operations without adequate restriction to an approved directory.
Potential impact
- Attackers may overwrite application or configuration JSON files
- Application data integrity could be compromised
- SiYuan behavior may be altered through malicious file content
- Availability could be affected if required files are corrupted
- Subsequent exploitation may be possible if overwritten files influence privileged processing
General mitigation guidance
Mitigation generally focuses on making workspace file operations independent of user-controlled path traversal.
Common defensive patterns include:
- Resolve and normalize paths before use, then enforce that they remain beneath an approved workspace directory
- Reject traversal sequences and absolute-path forms as an additional input validation layer
- Construct paths from server-controlled identifiers rather than raw request values
- Restrict write operations to narrowly scoped directories and file types
- Run the application with the least filesystem privilege required
- Apply atomic writes, integrity checks, and controlled file permissions for sensitive JSON files
- Treat authenticated administrative input as untrusted for filesystem operations
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying request parameters used in filesystem path construction
- Code review checks for missing canonicalization and workspace-boundary validation
- Tests using traversal markers, encoded separators, absolute paths, and mixed path formats
- Runtime monitoring for writes outside approved application directories
- File-integrity monitoring on sensitive JSON and configuration locations
- Policy enforcement that blocks application processes from writing outside designated data paths
Automated security review tools may help identify path construction flows that lack explicit boundary checks.

