Summary
SiYuan's /api/file/getFile endpoint previously relied on case-sensitive string comparison to block access to sensitive files.
On case-insensitive file systems like Windows, attackers could craft mixed-case paths to bypass these checks and read protected configuration files.
Affected context
This issue affects SiYuan instances running on case-insensitive file systems, primarily Windows, where filesystem path matching does not distinguish between upper and lower case.
The vulnerable behavior occurs in the /api/file/getFile HTTP endpoint, which attempts to prevent access to sensitive files (such as configuration or internal application files) using case-sensitive string equality checks on the requested path.
When the underlying OS treats file names as case-insensitive, these checks can be bypassed by varying the letter casing in the request path, allowing access to files that were intended to be blocked.
Exploit preconditions
- Attack surface: Network-accessible /api/file/getFile HTTP endpoint.
- Required access: Ability to send HTTP requests to the SiYuan instance (e.g., local network or exposed web interface).
- Deployment context: SiYuan running on a case-insensitive filesystem (e.g., Windows NTFS in default mode).
- Trigger point: Submission of a crafted file path with mixed or altered casing that maps to a protected file on disk.
- Why exploitation is possible: The application enforces access control using case-sensitive string checks, while the underlying filesystem resolves paths in a case-insensitive manner, causing a mismatch between the intended access policy and actual file resolution.
Why this happens
The root cause is improper restriction of filesystem paths (CWE-22) due to trusting simple, case-sensitive string comparisons to enforce file access restrictions.
Instead of normalizing and validating paths in a way that reflects the semantics of the underlying filesystem, the endpoint checks for sensitive targets using exact-case string equality (for example, blocking "config.json" but not "Config.json").
On case-insensitive filesystems, both variations resolve to the same file, so the application's logical filters diverge from the OS's path resolution behavior.
This design flaw illustrates a broader bug class where application-layer path checks do not account for platform-specific filename and path normalization rules, resulting in unauthorized file access.
Potential impact
- Attackers may read protected configuration files that were intended to be inaccessible.
- Sensitive information such as API keys, access tokens, or database credentials could be exposed.
- Internal application settings and environment details can be revealed, aiding further attacks.
- User-related data stored in configuration or support files could be disclosed depending on deployment.
- Reconnaissance value for attackers, enabling more targeted exploitation of the system or adjacent services.
General mitigation guidance
Mitigation generally focuses on aligning application-level path validation with filesystem behavior and minimizing direct file exposure:
- Normalize and canonicalize requested paths before authorization checks, including resolving case, dot-segments (../, ./), and symbolic links where applicable.
- Implement allowlist-based file serving (e.g., mapping logical IDs or aliases to specific, pre-approved files) instead of accepting arbitrary user-supplied paths.
- Use OS-appropriate APIs or libraries that enforce canonical paths and provide secure abstractions over direct filesystem access.
- Centralize path validation logic to avoid ad-hoc string checks scattered across the codebase.
- Restrict the file-serving component to a dedicated, non-sensitive directory and ensure that configuration and secrets are stored outside of any web-accessible tree.
- Apply least-privilege filesystem permissions so that the application process can only read files strictly required for serving user content.
How teams detect issues like this
Effective detection combines code-level analysis with behavioral testing:
- Static analysis and code review:
- Search for direct use of user-controlled paths in file access APIs (e.g., open/read operations) within request handlers such as /api/file/getFile.
- Flag string-based path filters or blacklist/denylist checks that rely on exact-case comparison or simple substring matching.
- Review for absence of path normalization routines (e.g., canonicalization) before authorization checks.
- Dynamic and behavioral testing:
- Fuzz file-serving endpoints with mixed-case paths and variants of known sensitive filenames to identify case-based bypasses.
- Attempt to access configuration or internal files outside the intended document root using casing variations.
- Policy and tooling:
- Enforce secure coding guidelines that require canonical path validation for all filesystem access.
- Integrate security-focused linters or SAST tools configured with rules for CWE-22 and path traversal patterns into CI pipelines.
- Use application security tests that explicitly consider platform differences (Windows vs. Unix-like systems) in path handling.

