Summary
A path traversal flaw in goshs' file deletion routine allows crafted paths to bypass directory restrictions when removing files.
Under certain configurations, an attacker who can send HTTP requests to a vulnerable goshs instance may be able to delete arbitrary files on the server's filesystem.
Affected context
This vulnerability appears when goshs is used to serve and manage files via HTTP, and the server exposes an endpoint that triggers tdeleteFile() for file removal.
The issue is relevant when goshs runs with permissions to delete files beyond the intended document root, and when user-controlled path input is accepted without a fully enforced post-validation return.
Deployments that expose goshs directly to untrusted networks, or that run it with broad filesystem privileges, are at elevated risk.
Exploit preconditions
- Attack surface: HTTP interface of the goshs server that supports file deletion operations.
- Required access: Ability to issue HTTP requests to the vulnerable endpoint (typically unauthenticated, depending on deployment configuration).
- Trigger point: Supplying a specially crafted path parameter containing traversal sequences (e.g., using
../) that reachestdeleteFile(). - Why exploitation is possible: The path traversal check is performed, but the function lacks an early
returnafter detecting an invalid path, allowing the deletion logic to continue operating on attacker-controlled input.
Why this happens
The underlying issue is a classic directory traversal (CWE-22) caused by incomplete control flow around a security check.
In tdeleteFile(), user-supplied paths are examined for traversal patterns, but when an unsafe path is identified the function does not immediately abort processing.
This mismatch between validation and enforcement means that, even after failing the traversal check, the code path that performs file deletion can still execute with the unchecked path.
Conceptually, the bug represents an authorization boundary implemented via input validation but not consistently upheld in the function's control flow.
Potential impact
- Deletion of files outside the intended web root or shared directory
- Removal of application configuration files that could disrupt service availability
- Deletion of log files that may hinder forensic investigations
- Potential escalation to broader system impact if critical system or user data is removed, depending on goshs' runtime privileges
General mitigation guidance
Effective mitigation focuses on enforcing strict path handling and hardening the runtime environment:
- Ensure that any path validation logic terminates execution immediately on failure, preventing subsequent file operations.
- Normalize and canonicalize user-supplied paths before comparison, then enforce that the resolved path remains within a predefined document root.
- Use deny-by-default patterns for file operations, explicitly whitelisting allowed directories and forbidding navigation above them.
- Run the goshs process with the least privileges necessary, restricting filesystem access via OS-level permissions and, where possible, chroot jails or containerization.
- Avoid exposing file deletion endpoints directly to the internet; place them behind authentication or administrative interfaces.
How teams detect issues like this
High-level detection can combine code-centric and operational approaches:
- Static analysis: Search for file deletion functions that operate on user-controlled paths without robust canonicalization and early-return on failed checks.
- Code review: Flag any instance where security checks (e.g., traversal detection) are followed by file operations but not guarded by clear control-flow exits on error conditions.
- Runtime monitoring: Track deletion of files outside the intended serving directory and alert on suspicious patterns such as repeated deletions using relative paths.
- Policy enforcement: Include secure file handling rules in CI/CD pipelines, using automated tools to prevent merging of code that performs filesystem operations on unvalidated or partially validated paths.

