/

CVE-2026-40189

Severity:

CRITICAL RISK

(9.8)

Missing Authorization in goshs HTTP Server

CVE-2026-40189

Analyzed

Vulnerability type

Category:

Missing Authorization

CWE:

CWE-862

Impact:

Authorization Bypass with Full Read/Write/Delete Capabilities

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 .goshs ACL/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, multipart POST /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 PUT requests to upload files into a .goshs-protected directory
  • Multipart POST /upload to place files in protected paths
  • Query operations using ?mkdir to create directories
  • Query operations using ?delete to remove files, including the .goshs ACL 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 .goshs ACL file itself.
  • Once the .goshs file 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 .goshs policy) rather than the HTTP method alone.
  • Treat the .goshs control 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.

Sources

SourceLink
github.comgithub.com/patrickhener/goshs/commit/f212c4f4a126556bab008f79758e21a839ef2c0f
github.comgithub.com/patrickhener/goshs/releases/tag/v2.0.0-beta.4
github.comgithub.com/patrickhener/goshs/security/advisories/GHSA-wvhv-qcqf-f3cx

Frequently asked

questions

Yes. If a goshs instance is accessible over the network and exposes the affected endpoints, a remote attacker can exploit the issue without valid credentials to modify or delete content in .goshs-protected directories.

The attacker only needs network-level access to the vulnerable goshs server. No prior authentication or special privileges are required to reach the state-changing routes.

The robust fix is to centralize authorization and apply it consistently to every operation—read and write—on protected resources. All handlers that manipulate files or directories, especially in paths governed by .goshs or similar policies, should invoke the same authorization logic before performing actions.

Preventative practices include designing an explicit access control layer (middleware or shared helpers), forbidding ad hoc permission checks inside individual handlers, enforcing architectural rules via code review and automated checks, and performing security testing focused on verifying that every exposed operation on sensitive resources requires proper authorization.

Find out what's already
exploitable in your codebase.