Summary
File Browser's access control logic previously matched protected paths using a simple string prefix check, causing rules defined for one directory (such as /uploads) to also apply to similarly named directories (like /uploads_backup/).
Under these conditions, an attacker could gain unauthorized access to unintended directories or be incorrectly denied access, depending on how the rules were configured.
Affected context
This vulnerability arises in File Browser deployments that rely on path-based access rules to restrict or grant access to directories.
The Matches() function in rules/rules.go used strings.HasPrefix() without verifying a trailing path separator, so any directory whose path merely started with the rule's path could be affected.
Environments with multiple similarly named directories (e.g., /uploads and /uploads_backup/) are particularly exposed, because rule definitions may unintentionally apply to both.
Exploit preconditions
- Attack surface: File Browser HTTP interface (web UI or API endpoints handling file operations).
- Required access: Ability to authenticate or otherwise reach a File Browser instance where access rules are configured for specific directories.
- Trigger point: Submitting file operations (upload, read, delete, rename, edit, or list) targeting paths that partially match an existing rule's directory prefix (e.g.,
/uploads_backup/when there is a rule for/uploads). - Why exploitation is possible: The access rule evaluation relies on
strings.HasPrefix()without enforcing a directory boundary, so any path that begins with the rule path string is treated as covered by that rule, even if it refers to a different directory.
Why this happens
The root cause is a logic flaw in path validation and authorization: directory-based access rules are evaluated using a plain string prefix match rather than a path-aware comparison.
By using strings.HasPrefix() without requiring a trailing directory separator or canonicalization of paths, the implementation conflates similarly named directories.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because the system fails to strictly confine access rules to the intended directory boundaries.
Potential impact
- Unauthorized read access to files in directories that only partially match a rule path.
- Unauthorized write, upload, or deletion of files in unintended directories.
- Accidental over-restriction, where legitimate users lose access to directories due to misapplied rules.
- Potential exposure or corruption of application data stored in misprotected directories.
General mitigation guidance
Mitigation centers on enforcing path-aware, boundary-safe matching for authorization decisions, rather than naive string comparisons.
Recommended defensive patterns include:
- Normalize and canonicalize all paths before evaluation (resolving
.and.., symbolic links where feasible, and consistent separators). - Compare full path segments, requiring a trailing directory separator or exact match for directory rules.
- Prefer filesystem-path libraries or helper functions that operate on path components instead of raw string APIs.
- Keep access control rules simple and explicit, avoiding overlapping directory names where possible.
- Apply least-privilege principles to directory permissions, granting only the minimal needed scope per role or user group.
How teams detect issues like this
Effective detection focuses on finding and auditing path-based authorization logic:
- Static analysis: Flag uses of generic string prefix/substring operations (
HasPrefix,Contains) in code paths that implement authorization or directory checks. - Code review: Examine access control modules (
rules/rules.goand similar) for path comparison logic; verify they use normalized paths and segment-aware comparison. - Security testing: Create test cases where two directories share a common prefix (e.g.,
/dataand/data_backup) and verify that rules for one do not affect the other. - Automated policy checks: Integrate secure coding guidelines into CI, enforcing that path authorization uses helper functions or utilities designed for safe path handling.

