Oct 5, 2026·6 min read·14 visits
Weak relative path checks in SiYuan allowed standard users to access sensitive configuration files and publishing tokens by requesting them via unprotected history and git diff endpoints.
A weak path access control vulnerability in SiYuan note-taking application allowed authenticated users to bypass restricted file paths by requesting historical backups and git diffs of sensitive configurations, including plain-text authentication tokens.
SiYuan is a personal knowledge management system utilizing local-first note-taking structures. To protect user data and operational integrity, the application restricts access to highly sensitive system files. These include publishAccess.json, which contains plain-text synchronization and publishing credentials, custom formatting templates, and specific user snippet configurations.
The application implements a defensive path filter, IsForbiddenAbsPath, which blocks direct read operations on these system files. This absolute path validation mechanism effectively secures standard file retrieval endpoints like /api/file/getFile. However, the system's attack surface includes auxiliary endpoints designed to handle version management and synchronization history.
Two critical endpoints, /history/*path and /repo/diff/*path, allow users to access previous states of their notes and view differential updates. Prior to version 3.8.1, these endpoints were not subject to the same strict path-filtering rules applied to live filesystem operations. This omission created a direct logical bypass where restricted files could be queried from the historical backup and git directories.
The root cause of this vulnerability lies in the inconsistent application of path authorization logic across different subsystem handlers. While live file transactions are subjected to complete sanitization and verified against absolute blocklists, the historical backup system uses a distinct storage directory (HistoryDir). This directory contains complete snapshots of the workspace, retaining identical subdirectory layouts and file naming conventions.
Because the security validation utility IsForbiddenAbsPath was designed to evaluate absolute paths relative to the live data root (DataDir), queries made to the history controller bypassed these checks. The controller processed requests to retrieve snapshots directly by appending the user-supplied string to the history directory prefix. This allowed the path resolution to occur outside the scope of the established security interceptor.
Similarly, the git-based repository differential system, exposed via /repo/diff/*path, allowed users to request file differences directly. Since the diff processor only queried the repository history rather than active physical paths, the absolute path check was not triggered. Consequently, any credentials or configuration parameters modified over time could be reconstructed from the repository metadata history.
In the vulnerable version of kernel/server/serve.go, the route handler for the history endpoint accepted the path parameter directly from the Gin context without sanitization. The application performed a simple join operation using filepath.Join to determine the target file on the disk, completely bypassing the path validation logic designed for active files.
Below is the vulnerable handling logic inside /history/*path compared against the patched implementation:
// Pre-v3.8.1 Vulnerable Code Path
ginServer.GET("/history/*path", model.CheckAuth, model.CheckAdminRole, func(context *gin.Context) {
p := filepath.Join(util.HistoryDir, context.Param("path"))
// Direct file read and transmission occurs here without path validation checks
})In the patched version (v3.8.1), the developer added manual directory traversal checks and introduced a new helper function IsForbiddenDataRelPath to systematically inspect files residing in the snapshot directory structures:
// Patched Code Path in v3.8.1
ginServer.GET("/history/*path", model.CheckAuth, model.CheckAdminRole, func(context *gin.Context) {
requestPath := context.Param("path")
// Reject directory traversal attempts
if strings.Contains(requestPath, "..") {
context.Status(http.StatusUnauthorized)
return
}
p := filepath.Join(util.HistoryDir, requestPath)
// Normalize path by stripping the snapshot folder prefix
rel := strings.TrimPrefix(requestPath, "/")
if idx := strings.Index(rel, "/"); 0 <= idx {
rel = rel[idx+1:]
} else {
rel = ""
}
// Evaluate path using the relative path blacklist
if util.IsForbiddenDataRelPath(rel) {
context.Status(http.StatusForbidden)
return
}
// Safe to resolve file
})The introduction of IsForbiddenDataRelPath in kernel/util/path_guard.go addresses the path separation issue by standardizing relative pathways to forward slashes, forcing lowercase evaluation on case-insensitive filesystems, and evaluating against restricted prefixes. This centralized approach guarantees uniform protection across both the active filesystem and snapshot configurations.
Exploitation of this vulnerability requires an authenticated session or direct network access to the local API on a system configured to accept external requests. The target files of interest include .siyuan/publishAccess.json which stores plain-text access tokens and templates containing confidential records.
The attack sequence is structured as follows:
An attacker initiates the attack by identifying a valid historical snapshot prefix, typically formatted chronologically based on synchronization intervals. Once the snapshot directory identifier is determined, the attacker issues a GET request targeting the history route. By querying /history/<timestamp>-sync/.siyuan/publishAccess.json, the path check is avoided, allowing the application to serialize and return the raw configuration file. Alternatively, requesting /repo/diff/.siyuan/publishAccess.json yields the modifications history of the same credentials, extracting key assets from git logs without authorization checks.
An analysis of the patch implementation reveals a critical OS-specific bypass mechanism affecting Windows environments. The relative path isolation logic within /history/*path relies on string split operations that assume forward-slash separators are consistently utilized.
Specifically, the application performs the prefix trimming operation using the following instruction block:
rel := strings.TrimPrefix(requestPath, "/")
if idx := strings.Index(rel, "/"); 0 <= idx {
rel = rel[idx+1:]
} else {
rel = ""
}On Windows operating systems, filesystem requests can be formulated using backslash separators (\). If an attacker constructs a query targeting a historical snapshot utilizing backslashes (e.g., 2026-08-15-120000-sync\.siyuan\publishAccess.json), strings.Index(rel, "/") yields a value of -1. This shifts program execution to the else block, assigning an empty string to rel. Because an empty string does not match any of the forbidden rules in IsForbiddenDataRelPath, the validation check succeeds, and the request is permitted. The downstream function then combines the paths using filepath.Join, which automatically normalizes backslashes and accesses the restricted backup file on the host filesystem.
To remediate this structural gap, the incoming requestPath must be normalized utilizing filepath.ToSlash prior to executing any string matching or prefix slicing routines.
The primary mitigation action for this vulnerability is upgrading the application to version v3.8.1 or higher. This release integrates relative path filtering and directory traversal prevention into the affected API controllers.
For environments unable to perform an immediate upgrade, several operational workarounds can be deployed:
Network Binding Restraints: Restrict the listening socket of the SiYuan web interface exclusively to the local loopback interface (127.0.0.1). This isolates the interface from remote access vectors.
Web Application Firewall (WAF) Implementation: Deploy an inspection layer or reverse proxy (such as Nginx) in front of the server. Configure rule-sets to analyze incoming requests and block matches containing /history/ or /repo/diff/ combined with sensitive configuration directory structures or backslash sequences.
| Product | Affected Versions | Fixed Version |
|---|---|---|
SiYuan siyuan-note | < 3.8.1 | v3.8.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-862 (Missing Authorization) / CWE-22 (Path Traversal) |
| Attack Vector | Network (Authenticated Standard User or Local API Access) |
| CVSS v3.1 | 7.5 (Medium-High) |
| Exploit Status | Proof-of-Concept (PoC) Analyzed |
| Impact | Information Disclosure (Retrieval of plain-text publishing tokens and templates) |
| Remediation | Upgrade to v3.8.1 or higher |
File Browser versions prior to 2.63.17 contain an authorization and state-management flaw in the BoltDB storage backend. When an authenticated user deletes a shared directory via an HTTP request with a trailing slash (e.g., DELETE /api/resources/a/), the share cleanup routine queries the database index using the unnormalized path before stripping the trailing slash. Because canonical share paths are stored without trailing slashes (e.g., /a), the database prefix query fails to match the parent directory share record. If a directory with the same name is later recreated, the dormant public share hash automatically reactivates and exposes the new directory contents to unauthenticated users.
An uncontrolled memory allocation vulnerability exists in ag-psd versions prior to 31.0.0. When parsing Adobe Photoshop Document (PSD) files, the readPsd() function reads image dimensions and color depth directly from the file header and allocates off-heap typed arrays without validating whether the requested memory size is proportional to the input stream or bounded by operational thresholds. An unauthenticated attacker can supply a crafted 52-byte PSD payload that triggers an immediate 3.35 GB memory allocation, resulting in process termination via the operating system Out-Of-Memory (OOM) killer.
CVE-2026-126297 (GHSA-v8f3-6phw-6mh9) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Natural Language Toolkit (NLTK) prior to version 3.10.4. Located in the Semantic Role Labeling (SRL) parser within `nltk/corpus/reader/conll.py`, the flaw allows an attacker to trigger quadratic O(N^2) CPU processing overhead by providing crafted CoNLL-formatted corpus inputs containing decoy span columns or nested full-width verb spans. Applications parsing untrusted linguistic corpora can experience prolonged CPU exhaustion and application-level Denial of Service (DoS).
CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.