Summary
A critical path traversal vulnerability in directory-serve through version 1.3.7 allows an unauthenticated remote attacker to delete files outside the intended served directory. The issue becomes risky when the application is started with the --delete option and accepts attacker-controlled path input without adequately restricting it to the configured directory.
Affected context
The vulnerability occurs in directory-serve deployments that enable the --delete functionality and expose the relevant request handling interface to untrusted clients. If supplied paths are not canonicalized and constrained to the intended served directory, traversal sequences may allow deletion requests to reach locations outside that directory.
Exploit preconditions
- Attack surface: Network-accessible directory-serve request handling
- Required access: No authentication, when the vulnerable interface is reachable
- Trigger point: A deletion request processed while the application runs with
--delete - Why exploitation is possible: User-controlled paths may be resolved outside the permitted directory when traversal is not safely normalized and bounded
Why this happens
The underlying bug is improper limitation of a pathname to an intended directory, which maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The insecure pattern occurs when application-controlled or attacker-controlled path components are joined or resolved without canonicalization, containment checks, and safe handling of symbolic links or equivalent filesystem features. When that path is used by a deletion operation, the traversal condition can turn a directory-scoped action into arbitrary file removal.
Potential impact
- Arbitrary files outside the served directory may be deleted
- Application availability could be disrupted through removal of required files
- Configuration, logs, credentials, or user data may be destroyed
- Data integrity and recovery operations may be impaired
- Dependent services could experience outages or unsafe behavior
General mitigation guidance
Mitigation generally focuses on making deletion directory-bound by design and reducing trust in request-supplied paths.
Common defensive patterns include:
- Resolving paths canonically and verifying that the result remains within the configured directory
- Rejecting traversal components, ambiguous encodings, and unexpected path formats before filesystem operations
- Applying the same containment checks after filesystem resolution, including relevant symlink handling
- Using an explicit allowlist of deletable files or controlled identifiers instead of accepting raw paths
- Keeping deletion disabled by default unless it is required
- Running the service with the least filesystem privileges necessary
- Separating served content from sensitive application and system directories
- Adding authorization and additional safeguards around destructive operations
How teams detect issues like this
Detection approaches can include:
- Static analysis for filesystem deletion calls receiving request-derived or concatenated path values
- Code review checks for missing canonicalization, containment validation, or symlink policy
- Runtime monitoring of deletion requests and filesystem changes outside the configured content root
- Web or service logs reviewed for traversal indicators, encoded separators, and unusual deletion targets
- Policy enforcement that blocks unauthenticated destructive operations and requires explicit scope controls
- Automated security review tools configured to identify path traversal and unsafe file-operation patterns

