Summary
SiYuan desktop up to version 3.6.0 exposes a critical file exfiltration issue where HTML paste handling copies local files referenced by file:// URLs into the workspace assets directory without proper path validation.
When combined with an authenticated /assets/*path endpoint, a publish-service visitor can cause the desktop kernel to copy and then download arbitrary readable files from the host system, potentially leaking highly sensitive data.
Affected context
This vulnerability arises in SiYuan desktop deployments that:
- Use the publish service to expose content to visitors
- Run a desktop kernel that processes pasted HTML via
/api/lute/html2BlockDOM - Allow the kernel process to access local files on the host file system
In these conditions, file:// links in pasted HTML can reference arbitrary files readable by the kernel's OS user account, which are then mirrored into the workspace assets directory and exposed over HTTP.
Exploit preconditions
- Attack surface: Network-accessible publish service and the local desktop kernel.
- Required access: Ability to act as an authenticated visitor to the publish service (or equivalent level of authenticated access to
/assets/*path), and to submit or influence HTML content processed by/api/lute/html2BlockDOM. - Trigger point: Submission of HTML containing
file://links that the desktop kernel processes; the kernel copies the referenced local files into the workspace assets directory. - Why exploitation is possible: The paste-processing endpoint copies local files pointed to by
file://URLs into a web-accessible assets directory without validating paths against a sensitive-path list or enforcing robust path restrictions, while the/assets/*pathendpoint serves those files to any authenticated visitor.
Why this happens
The issue stems from treating file paths derived from externally influenced HTML content as trusted, and automatically copying the referenced local files into a directory served over HTTP.
This behavior maps to:
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because the application fails to constrain which local files may be accessed through
file://references. - CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, since arbitrary host files become available to remote visitors.
- CWE-284: Improper Access Control, as access checks on
/assets/*pathdo not distinguish between benign workspace assets and sensitive host files mirrored into that directory.
Conceptually, this is an insecure coupling between a local file access feature and a web-exposed file-serving endpoint without a strong trust boundary or sensitive-path protection.
Potential impact
- Exfiltration of sensitive operating system files (e.g., configuration files, logs) readable by the SiYuan desktop process.
- Exposure of user-specific secrets stored on disk, such as SSH keys, API tokens, or application configuration files, depending on file permissions.
- Leakage of proprietary documents, notes, or other private content on the host machine.
- Expansion of an attacker's foothold through harvested credentials or configuration secrets used to access other systems.
General mitigation guidance
Effective mitigation focuses on decoupling local file access from web exposure and enforcing strict path controls:
- Introduce a strict allowlist of directories and file types that the paste-processing logic may access and copy; treat any other paths as untrusted and reject them.
- Implement a sensitive-path denylist for well-known locations such as user home secrets, SSH directories, system configuration paths, and application credential stores.
- Normalize and canonicalize file paths before use, then enforce that they remain within a designated safe root (e.g., a dedicated media/import directory) rather than arbitrary host paths.
- Ensure that the assets-serving endpoint is restricted to files that were explicitly created as workspace assets and not arbitrary files copied from the host filesystem.
- Apply the principle of least privilege to the desktop kernel process so that it has minimal file-system permissions and cannot read highly sensitive directories by default.
How teams detect issues like this
Detection can leverage both code-level and behavioral analysis:
- Static analysis: Search for code paths that:
- Accept or derive paths from HTML or other remote inputs.
- Use
file://URLs or user-controlled path segments to access the local file system. - Copy or move those files into directories served by HTTP endpoints.
- Code review: Flag patterns where:
- Local file reads are performed in response to web or paste events without explicit path validation.
- Assets directories double as both upload targets and generic file-serving roots.
- There is no clear separation between workspace content and host file imports.
- Runtime monitoring: Log and alert on:
- Unusual access patterns against
/assets/*path, especially requests that align with sensitive OS locations or uncommon file names. - High volume or unexpected file imports triggered by
/api/lute/html2BlockDOM. - Automated security tools can be configured to detect unvalidated file-system operations and web-exposed file-serving endpoints that rely on user-influenced paths.

