Summary
Directus versions prior to 11.17.0 contain an access control flaw in the PATCH /files/{id} endpoint that allows attackers to control the filename_disk value for stored files.
By pointing this value at the storage path of another user's file, an attacker may overwrite that file's contents and manipulate metadata like uploaded_by, potentially hiding evidence of tampering.
Affected context
This vulnerability arises in Directus deployments where the file management API is exposed and users can call PATCH /files/{id} on file records they can edit.
The issue is most relevant when:
- Multiple users or tenants share the same file storage backend
- Filenames and storage paths are not fully isolated per user or tenant
- Application logic trusts client-controlled
filename_diskvalues to determine on-disk file locations
Under these circumstances, a malicious user can influence where a file is stored on disk and target paths used by other users' files.
Exploit preconditions
- Attack surface: HTTP API, specifically the
PATCH /files/{id}endpoint in Directus. - Required access: Ability to authenticate or otherwise gain permission to update at least one file record (or any context in which
PATCH /files/{id}is allowed). - Trigger point: Sending a crafted PATCH request where
filename_diskis set to the storage path used by another user's file, along with optional metadata changes (e.g.,uploaded_by). - Why exploitation is possible: The server-side implementation does not sufficiently validate or constrain
filename_diskrelative to the authenticated user or the original file, allowing users to redirect writes to arbitrary file paths within the storage scope and overwrite existing content they do not own.
Why this happens
The core issue is insufficient authorization on a critical file attribute that maps directly to storage paths.
Rather than deriving the storage location on the server from trusted state, the implementation allows a user-controlled parameter (filename_disk) to influence where the file is stored or updated.
This maps to CWE-284: Improper Access Control, as the system fails to enforce ownership or authorization checks when modifying storage paths, and to CWE-639: Authorization Bypass Through User-Controlled Key, because a client-controlled key-like attribute determines access to another user's resource.
Abstractly, the insecure pattern is: exposing an identifier or path that selects a resource in shared storage and letting untrusted clients modify it directly, without re-checking whether the caller is allowed to affect the underlying resource or its metadata.
Potential impact
- Overwriting another user's file content, potentially destroying important data.
- Tampering with shared assets such as images, documents, or configuration-like files stored in Directus.
- Manipulating metadata (e.g.,
uploaded_by) to obscure who performed the change and hinder forensic analysis. - Undermining data integrity guarantees across tenants or user groups sharing the same storage.
- Facilitating more complex attacks that rely on replacing trusted content (e.g., malicious documents or swapped media assets).
General mitigation guidance
Effective mitigation focuses on tightening authorization around file attributes and removing trust from client-controlled storage identifiers.
Recommended design patterns include:
- Deriving physical storage paths exclusively on the server side, based on immutable properties (such as file IDs or server-generated random names), rather than accepting
filename_diskor similar fields from clients. - Treating any identifier that maps to shared storage as sensitive, and validating that changes cannot cause cross-user or cross-tenant collisions.
- Enforcing strict ownership and permission checks whenever a file's location or underlying content is updated, not just when metadata is changed.
- Separating user-facing metadata (e.g., display filenames) from internal storage identifiers, and ensuring only metadata fields are user-modifiable.
- Applying least-privilege principles so that users can only modify files they own or are explicitly granted access to, and ensuring that privileged operations are not exposed to regular users.
These patterns reduce the chance that a single misvalidated field can redirect writes to another user's file.
How teams detect issues like this
Detecting this type of issue typically involves reviewing both code paths and runtime behavior around file handling:
- Static analysis and code review:
- Search for API endpoints that allow clients to set or modify storage-related fields such as
filename_disk,path, or similar identifiers. - Flag patterns where client input is concatenated or directly mapped to file system or object-storage keys without server-side derivation.
- Examine access control logic around file update handlers to ensure authorization is enforced at the resource level, not just at the request level.
- Policy and architectural review:
- Establish design guidelines that internal storage identifiers must be immutable and server-controlled.
- Introduce security review checklists for file upload, update, and delete endpoints to verify ownership checks and path isolation.
- Runtime monitoring and logging:
- Log file updates with both logical file IDs and underlying storage paths, and monitor for unexpected cross-user or cross-tenant changes.
- Use anomaly detection or simple heuristics to identify frequent over-writes of the same path from different users.
Automated review tools and linters configured with custom rules for file access patterns can help surface similar issues early in development.

