Summary
Cockpit CMS's bucket file storage API improperly sanitizes bucket names, allowing directory traversal via .. and ../ sequences that are normalized but not blocked.
An authenticated low-privileged user can abuse this flaw to list, upload, and delete files across all buckets, including those owned by other users or roles, whenever the Bucket API is exposed.
Affected context
The vulnerability arises in Cockpit CMS deployments that use the Bucket file storage API under /system/buckets/api.
It manifests when:
- Bucket names are accepted from user-controlled input
- The application relies on simple character whitelisting and path normalization
- The underlying filesystem abstraction (Flysystem) treats
buckets/..as a valid path and resolves it to the uploads storage root
In such configurations, bucket operations can unintentionally target directories outside the intended bucket scope.
Exploit preconditions
- Attack surface: HTTP requests targeting the Bucket file storage API (
/system/buckets/api) - Required access: Authenticated user with minimal permissions to interact with buckets
- Trigger point: Supplying a crafted bucket name containing
..or../sequences to theapi()method - Why exploitation is possible: The sanitization regex removes disallowed characters but still permits
..segments, and Flysystem's path normalizer resolvesbuckets/..to the storage root without flagging traversal, allowing the attacker's bucket operations to escape their authorized bucket directory.
Why this happens
This issue stems from insufficient path validation and reliance on naive input sanitization for filesystem paths.
The api() controller uses a regex-based whitelist that strips certain characters but does not reject or normalize out directory traversal segments such as .. and ../.
When these sanitized values are interpolated into filesystem paths managed by Flysystem, the path normalizer legally resolves buckets/.. to the higher-level storage root.
Conceptually, this matches CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled path components are allowed to influence directory resolution beyond their intended scope.
Potential impact
- An authenticated low-privileged user may list files stored in other users' buckets
- Attackers could upload arbitrary files into other buckets, potentially influencing application behavior or content
- Existing files across buckets can be deleted or overwritten, leading to data loss or corruption
- Sensitive assets stored in buckets, such as media or configuration-related artifacts, could be exposed or tampered with
General mitigation guidance
Effective mitigation centers on enforcing strict directory boundaries and rejecting unsafe path constructs.
Common defensive patterns include:
- Validating bucket identifiers against a constrained, canonical format (e.g., fixed slugs or IDs) rather than raw path segments
- Explicitly detecting and rejecting path traversal markers such as
..,../, and redundant separators before constructing filesystem paths - Mapping logical bucket names to internal, non-user-controllable directory names so that user input cannot directly shape filesystem paths
- Applying authorization checks at the logical bucket level for read, write, and delete operations, ensuring that operations are tied to the owning user or role
- Configuring storage layers so that application-level buckets are confined to dedicated subdirectories with no ability to escape via relative path resolution
How teams detect issues like this
Organizations can detect similar path traversal issues by:
- Using static analysis rules to flag any interpolation of user input into filesystem paths, particularly when combined with relative segments
- Reviewing controller and storage-layer code for regex-based sanitization that does not explicitly handle
..and other traversal constructs - Implementing security-focused unit and integration tests that attempt bucket names with
../, extra slashes, and ambiguous whitespace to verify enforcement - Applying runtime monitoring or logging that records bucket names and path resolutions, alerting on suspicious patterns involving traversal markers
- Employing automated code review tools or SAST solutions configured with checks for CWE-22 patterns in file handling and storage APIs

