Summary
SiYuan versions before 3.7.4 do not sufficiently validate the packageName parameter used by Bazaar installation and uninstallation endpoints. An authenticated administrator could exploit directory traversal sequences to write files to unintended locations or recursively delete directories.
Affected context
The vulnerability occurs in SiYuan Bazaar install and uninstall functionality when the packageName parameter is used to construct filesystem paths without adequate canonicalization and boundary checks. Risk is higher where authenticated administrators can invoke these endpoints and the application process has write or delete permissions beyond its intended package directory.
Exploit preconditions
- Attack surface: Bazaar package installation and uninstallation endpoints
- Required access: Authenticated administrator privileges
- Trigger point: Processing a crafted
packageNamevalue containing directory traversal sequences - Why exploitation is possible: The supplied parameter can influence filesystem locations without sufficient restriction to the intended Bazaar directory
Why this happens
The underlying bug is improper limitation of a user-controlled path component. When an application combines packageName with a trusted base directory without canonicalizing the result and verifying that it remains within the permitted directory, traversal sequences can escape the intended path.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal. The same unchecked path resolution can affect both file-writing and recursive deletion operations.
Potential impact
- An attacker may write arbitrary files to locations accessible to the SiYuan process.
- An attacker could overwrite application, configuration, or operational files.
- An attacker may recursively delete directories within the process's filesystem permissions.
- The application could become unavailable or behave unpredictably.
- Additional compromise could be possible if written files are later executed or loaded by privileged components.
General mitigation guidance
Mitigation generally focuses on treating package identifiers as constrained names rather than filesystem paths.
Common defensive patterns include:
- Resolve candidate paths against a fixed, dedicated package directory and verify the canonical result remains within that directory.
- Reject path separators, traversal components, absolute paths, encoded equivalents, and unexpected characters before filesystem operations.
- Use allowlisted package identifiers and secure-by-default path-joining abstractions.
- Separate installation and deletion permissions from broader administrative capabilities where practical.
- Run the application with the least filesystem privilege required and isolate package storage from sensitive directories.
- Apply distinct safeguards to write, rename, extraction, and recursive deletion operations.
How teams detect issues like this
Organizations can look for path-construction code that combines request parameters with filesystem paths, especially where canonicalization and containment checks are absent.
Useful approaches include:
- Static analysis for user-controlled values passed to file creation, move, extraction, deletion, or recursive directory APIs.
- Code review checks for direct string concatenation or unsafe path-joining with request parameters.
- Tests using traversal, encoded traversal, absolute-path, and platform-specific separator variants to verify containment enforcement.
- Runtime logging and policy monitoring for unusual Bazaar requests, filesystem writes, and recursive deletion activity.
- Automated security review tools can help identify untrusted path data reaching filesystem operations.

