/

CVE-2026-33670

Severity:

CRITICAL RISK

(9.8)

Directory Traversal in SiYuan Notebook File Enumeration API

CVE-2026-33670

Analyzed

Vulnerability type

Category:

Directory Traversal

CWE:

CWE-22

Impact:

Unauthorized File System Enumeration / Information Disclosure

Severity:

CRITICAL RISK

(9.8)

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 directory traversal flaw in SiYuan's /api/file/readDir endpoint allows an attacker to enumerate document file names across a notebook by abusing path handling logic.

When exposed to untrusted clients, this can reveal the structure and names of private knowledge documents, significantly weakening data confidentiality and aiding further attacks.

Affected context

The vulnerability appears in SiYuan deployments that expose the /api/file/readDir interface to a browser or network client, such as desktop instances with an HTTP API, local web deployments, or remote/self-hosted servers.

It becomes relevant when:

  • The API accepts user-controlled or loosely validated paths or notebook identifiers, and
  • The service has access to sensitive notebooks or document directories that users assume are private.

In such setups, an attacker who can issue requests to the SiYuan API may be able to list document names beyond the intended scope of a single directory or user context.

Exploit preconditions

  • Attack surface: HTTP API endpoint /api/file/readDir.
  • Required access: Ability to send requests to the SiYuan API (e.g., local browser access, same-network access, or authenticated access depending on deployment).
  • Trigger point: Supplying crafted parameters that influence the directory path or notebook selection when invoking the readDir interface.
  • Why exploitation is possible: The endpoint traverses directories and returns file names without robust normalization, canonicalization, and authorization checks, allowing user input to influence which directories are listed.

Why this happens

This issue stems from improper restriction of a path used for file system operations, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

The /api/file/readDir handler relies on user-influenced input to determine which directory to read and then enumerates file names under that path.

Without enforcing strict base directories, normalizing paths to a canonical form, and verifying that the resulting path stays within an allowed notebook scope, the API can be abused to traverse beyond intended boundaries and disclose file names of documents that should not be visible.

Potential impact

  • Exposure of notebook and document filenames that the requesting user should not see
  • Disclosure of the structure and organization of private knowledge bases
  • Leakage of sensitive information embedded in file or directory names (e.g., project names, client names, credentials hints)
  • Intelligence gathering that can facilitate targeted phishing, social engineering, or subsequent technical attacks
  • Potential enumeration of files that reveal the presence of other users' data in multi-user setups

General mitigation guidance

Effective mitigation focuses on constraining file system access and enforcing clear trust boundaries around pathhandling:

  • Restrict all file operations to well-defined root directories per user or notebook, and reject any request that attempts to escape them.
  • Normalize and canonicalize paths (e.g., resolving .., symlinks, and redundant separators) before use, then verify that the resolved path is still within the allowed base directory.
  • Treat all client-supplied path components and notebook identifiers as untrusted, and apply strict allowlists (e.g., matching only known IDs or pre-registered notebook names rather than raw paths).
  • Add authorization checks so that listing files for a notebook is only permitted when the caller has explicit rights to that notebook.
  • Limit metadata exposure by returning only minimal information necessary for the UI (e.g., IDs instead of raw file system paths, avoiding sensitive naming patterns).

How teams detect issues like this

Organizations can detect and monitor for directory traversal-style weaknesses and abuse in several ways:

  • Static analysis and code scanning: Flag code paths where user input is concatenated with file system paths, especially around APIs like readDir, open, or stat, and verify canonicalization and base-path enforcement.
  • Code review practices: Require reviewers to explicitly check that any path-based API validates notebook identifiers, uses path normalization, and enforces per-user or per-notebook root directories.
  • Runtime logging and monitoring: Log directory listing requests including normalized paths and notebook IDs, and alert on attempts to use traversal sequences (../, unusual absolute paths, or access outside expected notebook directories).
  • Security tests: Incorporate automated tests or DAST scans that attempt common traversal patterns against the API surface to ensure that such requests are rejected.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-xmw9-6r43-x9ww

Frequently asked

questions

It can be, depending on how SiYuan is deployed. If the /api/file/readDir endpoint is accessible over the network without strong access controls, a remote attacker could exploit it to enumerate document names. In local-only deployments, the risk is primarily from local or same-machine processes and users.

An attacker generally needs the ability to issue HTTP requests to the SiYuan API. In some configurations, this might mean local browser access; in others, authenticated or same-network access may be required. The key factor is whether the attacker can reach /api/file/readDir and control its parameters.

The safest pattern is to strictly bind all file operations to controlled root directories, canonicalize and validate paths against those roots, and ensure that only authorized users can list directories for specific notebooks. Avoid exposing raw file system paths or allowing arbitrary path input from clients.

Adopt a secure-by-default file handling model: treat all path inputs as untrusted, enforce canonicalization and base-path checks, require explicit authorization for directory listings, and include path traversal checks in code review, automated testing, and static analysis rules across the codebase.

Find out what's already
exploitable in your codebase.