/

CVE-2026-40883

Severity:

HIGH RISK

(8.1)

CSRF in goshs State-Changing GET Endpoints

CVE-2026-40883

Analyzed

Vulnerability type

Category:

Cross-Site Request Forgery (CSRF)

CWE:

CWE-352

Impact:

Unauthorized State-Changing Actions via Victim's Browser

Severity:

HIGH RISK

(8.1)

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 versions 2.0.0-beta.4 through 2.0.0-beta.5 expose state-changing HTTP GET routes (such as ?delete and ?mkdir) without CSRF protection.

An external site can trick a user's already authenticated browser into sending these requests, allowing destructive file operations without the user's intent.

Affected context

This vulnerability appears in goshs deployments that:

  • Use HTTP basic authentication in the browser for access control
  • Expose file-management actions (e.g., create directory, delete) via HTTP GET query parameters like ?delete and ?mkdir
  • Are reachable from users who browse other, potentially malicious websites while still authenticated to goshs

The issue manifests when the application trusts any authenticated GET request as intentional, without validating its origin or the user's explicit interaction.

Exploit preconditions

  • Attack surface: Web interface of goshs, specifically state-changing GET endpoints.
  • Required access:
  • Attacker must be able to serve or inject HTML/JavaScript that the victim's browser can load.
  • Victim must be authenticated to goshs via HTTP Basic Auth and have an active session or cached credentials.
  • Trigger point: Victim visits a malicious or compromised site that silently issues GET requests (e.g., via <img>, <link>, or automatic navigation) to goshs endpoints such as ?delete or ?mkdir.
  • Why exploitation is possible: goshs:
  • Relies solely on HTTP basic authentication, which the browser automatically reuses.
  • Does not implement CSRF tokens or same-site checks.
  • Does not enforce Origin or Referer validation on sensitive routes.

Why this happens

The root cause is the absence of anti-CSRF controls on state-changing endpoints combined with the use of HTTP GET for destructive actions.

Browsers automatically include stored basic-auth credentials in cross-origin requests, so any site can induce a user's browser to send authenticated requests if the target server does not verify the request's origin or user intent.

This maps to CWE-352: Cross-Site Request Forgery (CSRF), where an application accepts authenticated requests from a user's browser without ensuring that those requests were deliberately initiated by that user within the trusted origin.

Potential impact

  • Unauthorized deletion of files or directories accessible through goshs
  • Unauthorized creation of directories or other file system modifications
  • Disruption or loss of hosted content served by goshs
  • Facilitation of further attacks if file operations can modify configuration or upload malicious content
  • Damage to data integrity and availability within the served directory tree

General mitigation guidance

Effective mitigation focuses on treating state-changing operations as sensitive and verifying user intent and request origin:

  • Prefer non-idempotent HTTP methods (POST/PUT/DELETE) for state-changing actions instead of GET, and treat them as protected endpoints.
  • Introduce CSRF tokens for all operations that mutate state; validate tokens server-side for each such request.
  • Enforce strict Origin and/or Referer header checks for sensitive routes, rejecting requests that do not originate from allowed origins.
  • Apply the principle of least privilege at the file-system level so that the goshs process only has access to the minimal required directory tree.
  • Consider time-bounded or per-action authentication prompts for highly destructive operations (e.g., bulk delete) rather than relying only on long-lived basic auth.
  • Encourage deployment behind an authenticated reverse proxy or gateway that can enforce CSRF-aware policies if application-level changes are limited.

How teams detect issues like this

Organizations and maintainers can detect similar CSRF issues using:

  • Static analysis and code review:
  • Flag state-changing logic reachable via HTTP GET or without CSRF token verification.
  • Identify sensitive endpoints that do not check Origin/Referer headers.
  • Look for reliance solely on HTTP basic authentication without additional request-context validation.
  • Security testing:
  • Perform manual penetration tests or automated web scans that attempt cross-origin requests to sensitive endpoints.
  • Use browser-based testing tools to simulate cross-site requests from untrusted domains.
  • Process and policy checks:
  • Enforce secure coding guidelines mandating CSRF protections on all state-changing endpoints.
  • Integrate automated checks in CI to detect routes lacking CSRF defenses or misusing HTTP methods for state changes.

Sources

SourceLink
github.comgithub.com/patrickhener/goshs/security/advisories/GHSA-jrq5-hg6x-j6g3

Frequently asked

questions

Yes. If goshs is reachable from the victim's browser and the victim is authenticated, an attacker can host malicious content on any external site and cause the victim's browser to send unintended authenticated requests.

The attacker does not need direct access to credentials. Exploitation relies on the victim already being authenticated with goshs (or having cached basic-auth credentials) so that the browser automatically includes them with cross-site requests.

The robust fix is to enforce CSRF protections on all state-changing endpoints, avoid using GET for destructive actions, and verify the Origin/Referer headers for sensitive operations. Combining these measures significantly reduces unintended cross-site requests.

Adopt a design rule that any endpoint changing state must: use appropriate HTTP methods, require a validated CSRF token, and validate request origin. Back this with secure coding standards, code review checklists, and automated tests to ensure new endpoints comply by default.

Find out what's already
exploitable in your codebase.