/

CVE-2026-59832

Severity:

HIGH RISK

(7.7)

Path Traversal (CWE-22) in SiYuan Snippet Handler

CVE-2026-59832

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-23

Impact:

Sensitive Data Exposure

Severity:

HIGH RISK

(7.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in SiYuan's snippet-serving endpoint allows authenticated users to escape the intended snippets directory and access sensitive files.

By abusing double-encoded directory traversal sequences in snippet paths, an attacker can read workspace secrets and the underlying document database when the application handles the request.

Affected context

This vulnerability occurs in SiYuan deployments that expose the /snippets/*filepath HTTP route and rely on it to serve user snippets from a dedicated directory.

The issue manifests when request paths are decoded and then joined with the snippets directory without verifying that the resulting path remains inside the allowed subtree.

It is most relevant in environments where authenticated users have access to the snippets API and the application stores configuration, secrets, and document data in predictable subdirectories.

Exploit preconditions

  • Attack surface: HTTP endpoint /snippets/*filepath on the SiYuan server.
  • Required access: Valid authenticated user account capable of sending snippet requests.
  • Trigger point: Supplying a crafted, encoded path (e.g., /%2e%2e/%2e%2e/conf/conf.json) that is decoded and joined with the snippets directory.
  • Why exploitation is possible: The server decodes the path once and performs a simple filesystem join without enforcing subpath containment or checking for traversal sequences, allowing access outside the intended snippets directory.

Why this happens

The underlying bug is a classic path traversal issue where user-supplied filesystem paths are trusted without proper normalization and containment checks.

In serveSnippets within kernel/server/serve.go, the application joins a single-decoded request path directly with the snippets directory and then serves the resulting file.

This pattern maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-23: Relative Path Traversal, because user-controlled relative paths can escape the target directory and reach sensitive configuration and database files.

Potential impact

  • An attacker may read configuration files containing workspace secrets or authentication tokens.
  • An attacker could access the document database and extract private notes or knowledge base content.
  • Sensitive system or application metadata can be disclosed, aiding further attacks.
  • Compromised data may enable account takeover or unauthorized integration access, depending on stored secrets.

General mitigation guidance

Effective mitigation focuses on strictly constraining file access to the intended snippets directory and treating all request paths as untrusted.

Secure patterns include:

  • Normalizing and canonicalizing requested paths, then verifying that the resolved path is a subpath of the snippets root before serving any file.
  • Rejecting any path containing traversal segments such as .. after normalization, regardless of encoding.
  • Using higher-level file-serving utilities that enforce directory whitelisting and subpath containment by default.
  • Separating storage locations for configuration, secrets, and databases from any web-accessible directories and ensuring snippet serving logic cannot traverse to those locations.
  • Applying least-privilege file permissions so that web components cannot read unnecessary sensitive files even if traversal is attempted.

How teams detect issues like this

Organizations can detect similar path traversal weaknesses by:

  • Applying static analysis rules that flag direct concatenation or joining of user-supplied paths with filesystem locations without containment checks.
  • Reviewing route handlers for file-serving logic that lacks path normalization and directory whitelisting.
  • Implementing security tests or fuzzing against file-serving endpoints using encoded .. segments and unexpected path patterns to confirm containment.
  • Enforcing application security policies that require canonical path checks and explicit directory scopes for any file access based on HTTP parameters.
  • Using automated code review tools or SAST platforms configured with rules for CWE-22 and CWE-23 to catch risky filesystem access patterns during development.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/68cc0f537dfa4502496dfa794e71835421c25c09
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.7.1
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-275h-v5h9-vr82

Frequently asked

questions

Yes, it is exploitable via the HTTP interface, but only by authenticated users who can access the /snippets/*filepath route on a reachable SiYuan instance.

The attacker needs a valid authenticated account or equivalent session able to send requests to the snippets endpoint; no special filesystem access is required beyond what the application process already has.

The safest approach is to normalize incoming paths, verify that the resolved path remains within a predefined allowed directory, and reject any request that attempts traversal or references files outside that scope.

Consistently treat all path parameters as untrusted, use canonicalization plus subpath containment checks, keep sensitive assets out of web-served directories, and enforce coding standards backed by automated checks targeting CWE-22 and CWE-23 patterns.

Find out what's already
exploitable in your codebase.