Summary
A path traversal flaw in SiYuan's /assets/*path HTTP route allows attackers to bypass directory restrictions by using double URL encoding of .. segments.
In publish mode, an unauthenticated remote attacker can read sensitive files within the workspace directory, including configuration, database, and log files.
Affected context
This vulnerability occurs in SiYuan instances running in publish mode, which exposes an anonymous read-only HTTP endpoint (default port 6808).
It affects the /assets/*path route when path components are insufficiently validated, allowing traversal outside the intended asset subdirectory using double-encoded .. segments.
The issue is limited to files located under the configured WorkspaceDir, but this directory commonly contains configuration secrets, local databases, and detailed logs.
Exploit preconditions
- Attack surface: Public HTTP endpoint for publish mode (typically
http://host:6808/). - Required access: No authentication; any remote client that can reach the publish endpoint.
- Trigger point: HTTP requests to the
/assets/*pathroute containing double URL-encoded directory traversal sequences (e.g., encoded..path segments). - Why exploitation is possible: The path normalization and sanitization logic does not correctly decode and validate multiple layers of URL encoding, allowing attacker-controlled paths to resolve to files outside the intended assets directory inside
WorkspaceDir.
Why this happens
The root cause is incomplete path validation and canonicalization when resolving user-supplied paths in the /assets/*path route.
The code attempts to restrict access to a specific directory but fails to correctly handle double-encoded special segments like .., so the effective filesystem path can traverse to arbitrary locations under WorkspaceDir.
This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, and is related to CWE-23: Relative Path Traversal and CWE-1188: Insecure Default Initialization of Resource, because the publish endpoint exposes a broad attack surface with insufficiently constrained resource access.
Potential impact
- An attacker may read
conf/conf.json, exposing hashed access codes, API tokens, and sync keys. - An attacker could access
temp/siyuan.dbandtemp/blocktree.db, potentially extracting user content, metadata, and structural information. - An attacker can read
siyuan.log, which may reveal internal paths, debug data, and other sensitive operational details. - An attacker could enumerate other files in
WorkspaceDirthat may contain proprietary notes, documents, or configuration data. - Disclosure of secrets may enable follow-on attacks, such as API misuse or unauthorized synchronization actions.
General mitigation guidance
Effective mitigation focuses on robust path handling and reducing the exposure of sensitive files through public endpoints.
Recommended patterns include:
- Performing strict canonicalization of requested paths after fully decoding URL components, then enforcing that the resolved path stays within a defined asset directory.
- Rejecting any request containing
..or other traversal indicators after decoding, rather than attempting partial sanitization. - Separating workspace storage for public assets from internal configuration, database, and logs, minimizing the blast radius if an asset route is misconfigured.
- Limiting the data stored in publicly reachable workspaces and avoiding co-location of secrets with user content.
- Applying defense-in-depth controls such as access control layers, environment-based configuration, and least-privilege filesystem permissions to reduce the risk of sensitive file exposure.
How teams detect issues like this
Detection can rely on both preventative and retrospective techniques:
- Static analysis rules that flag any use of user-controlled path segments in filesystem operations (
open,readFile, etc.) without canonicalization and explicit directory bounds checks. - Code review checklists that require verification of URL decoding order, rejection of traversal sequences, and confinement to a dedicated assets directory for any HTTP file-serving routes.
- Runtime monitoring and logging to detect suspicious requests with URL-encoded
..segments or anomalies in asset requests that resolve to non-asset files. - Security tests and CI/CD checks that include automated path traversal test cases against file-serving endpoints.
- Periodic configuration audits to ensure publish mode is only enabled in intended environments and that workspace directories do not contain unnecessary sensitive artifacts.

