Summary
goshs, a SimpleHTTPServer written in Go, enforces per-folder .goshs ACL/basic-auth for directory listings and file reads but fails to apply the same authorization checks to state-changing endpoints.
An unauthenticated attacker can upload, create, and delete content—including the .goshs file itself—inside a protected directory, effectively stripping its access control and exposing previously protected data.
Affected context
This vulnerability affects goshs deployments that:
- Rely on the per-folder
.goshsACL/basic-auth mechanism for access control - Expose goshs directly or indirectly to untrusted networks (e.g., internet, shared internal segments)
- Allow HTTP methods and query parameters such as
PUT, multipartPOST /upload,?mkdir, and?delete
Under these conditions, operations that modify files and directories in a .goshs-protected folder are not subject to the same authorization checks as read operations.
Exploit preconditions
- Attack surface: HTTP interface of goshs, reachable over the network.
- Required access: Network access to the goshs instance; no valid credentials are required for the vulnerable routes.
- Trigger points:
- HTTP
PUTrequests to upload files into a.goshs-protected directory - Multipart
POST /uploadto place files in protected paths - Query operations using
?mkdirto create directories - Query operations using
?deleteto remove files, including the.goshsACL file - Why exploitation is possible: The authorization layer is only enforced for directory listings and file reads but not consistently applied to state-changing routes. As a result, write and delete operations bypass the intended ACL/basic-auth checks.
Why this happens
The underlying issue is a broken authorization model where access control is applied selectively rather than uniformly across all sensitive operations.
While the .goshs per-folder mechanism guards directory listing and file read endpoints, the implementation omits equivalent checks for state-changing routes (file upload, directory creation, and file deletion).
This maps to CWE-862: Missing Authorization, where the software fails to perform required authorization checks for specific actions, allowing unauthorized users to perform operations that should be restricted.
Conceptually, the bug stems from treating "read" paths as protected while implicitly considering modification endpoints as trusted or internal, instead of deriving authorization from the resource and user context for every request.
Potential impact
- An attacker can upload arbitrary files into a previously protected directory.
- An attacker can create arbitrary directories within protected paths.
- An attacker can delete data, including important files and the
.goshsACL file itself. - Once the
.goshsfile is deleted, the folder's auth policy is removed and protected content can be accessed without credentials. - Confidential information stored in protected directories may be disclosed.
- Application or service behavior relying on the integrity of files in the served directory may be altered or disrupted.
- Availability can be impacted via bulk deletion of content or replacement with attacker-controlled files.
General mitigation guidance
Effective mitigation focuses on consistent, centralized authorization and reducing blind trust in per-route behavior:
- Ensure that all state-changing operations (upload, create, delete, modify) go through the same authorization checks as read operations for the same resource.
- Apply authorization based on the target resource (directory/file and its
.goshspolicy) rather than the HTTP method alone. - Treat the
.goshscontrol file and similar policy artifacts as sensitive resources; prevent unauthorized modification or deletion, or store access policies outside the served filesystem. - Follow a secure-by-default configuration where write-capable endpoints are disabled unless explicitly needed and are protected by authentication and authorization.
- Use least-privilege principles at the service level: run goshs with permissions scoped to only the intended directories and avoid reusing it as a general-purpose file management interface on sensitive hosts.
- Consider defense-in-depth with upstream controls (e.g., reverse proxies, WAFs, or API gateways) enforcing authentication and path/method allowlists for goshs endpoints.
How teams detect issues like this
Organizations can detect and monitor for this class of issue using a combination of review and runtime visibility:
- Code review and design analysis:
- Look for endpoints that perform file or directory mutations (upload, delete, mkdir) and verify they invoke the same authorization logic as listing and read operations.
- Identify scattered authorization checks; centralize access control decisions in middleware or a common handler to avoid omissions.
- Review handling of control/ACL files (like
.goshs) to ensure their modification requires at least as much privilege as accessing the protected content. - Static analysis and policy checks:
- Use static analysis or linters to flag HTTP handlers that touch the filesystem but do not call shared auth helpers or middleware.
- Enforce architectural policies (e.g., "every handler must pass through auth middleware unless explicitly exempted and documented").
- Runtime detection and logging:
- Enable detailed access logging for write-capable routes (
PUT,POST /upload,?mkdir,?delete) and monitor for unauthenticated usage. - Configure anomaly detection or alerting for state-changing requests originating from unexpected IP ranges or without credentials.

