/

CVE-2026-35392

Severity:

CRITICAL RISK

(9.8)

Path Traversal in goshs SimpleHTTPServer

CVE-2026-35392

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write via Path Traversal

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.0

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, contained a path traversal flaw in its HTTP PUT upload handler where uploaded file paths were not sanitized.

If an attacker could issue PUT requests to the server, they could write files outside the intended upload directory, potentially overwriting sensitive files or planting malicious content on the host.

Affected context

The vulnerability occurs in deployments of goshs prior to version 2.0.0-beta.3 that expose the HTTP PUT upload feature implemented in httpserver/updown.go.

It is relevant when:

  • The server allows clients to upload files via PUT, and
  • The server maps user-supplied paths directly to filesystem locations without proper normalization or restriction to a fixed base directory.

Environments where the goshs process has write access to sensitive system or application paths are at higher risk.

Exploit preconditions

  • Attack surface: Network-accessible HTTP endpoint that supports PUT on goshs.
  • Required access: Ability to send crafted HTTP PUT requests to the server (e.g., over LAN, WAN, or local port-forward).
  • Trigger point: The server processes a PUT request whose URL path includes traversal sequences (such as ../) or other crafted segments.
  • Why exploitation is possible: The upload handler performs no path sanitization or canonicalization, so user-controlled request paths can escape the intended upload directory and resolve to arbitrary filesystem locations writable by the goshs process.

Why this happens

The root cause is missing validation and normalization of user-controlled file paths before using them to construct filesystem locations.

In the vulnerable httpserver/updown.go PUT upload handler, the server trusts the raw request path and joins it directly with a base directory (or uses it directly) without:

  • Cleaning traversal sequences (e.g., ../),
  • Enforcing that the final canonical path remains within an expected root,
  • Or otherwise constraining where files may be written.

This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where external input drives file system access outside of intended boundaries.

Potential impact

  • Arbitrary file creation in directories writable by the goshs process.
  • Overwriting of existing files, which could lead to configuration tampering or denial of service.
  • Planting of malicious web content or scripts if the written locations are served or executed by other components.
  • Escalation of impact if critical files (e.g., application configs, keys, or binaries) are writable and can be modified.
  • Facilitation of further attacks by dropping backdoors, web shells, or altering logs and audit trails.

General mitigation guidance

Effective mitigation focuses on strict control of file paths derived from HTTP requests and minimizing the privileges of the server process.

General defensive patterns include:

  • Canonicalization and normalization: Resolve requested paths to their canonical form and reject any that escape a configured upload root directory.
  • Rooted file operations: Always construct file paths by joining a fixed, trusted base directory with a sanitized relative path, then verify the resulting path still resides under that base.
  • Allow-listing: Restrict acceptable path formats or file names to a constrained set of patterns, avoiding arbitrary nested directories from user input.
  • Permission hardening: Run goshs under a dedicated low-privilege account with write access only to the intended upload directory, not to system or application directories.
  • Feature gating: Disable or restrict PUT upload functionality in environments where it is not strictly required, or protect it behind authentication and access control.

How teams detect issues like this

Organizations can detect and manage this class of issue using a combination of code-level and runtime strategies:

  • Static analysis patterns: Scan for uses of HTTP request paths or user input directly passed to filesystem APIs (e.g., os.Create, os.OpenFile, ioutil.WriteFile) without intervening sanitization or canonicalization logic.
  • Code review signals: Flag handlers that implement upload or file write features and verify they:
  • Normalize paths (e.g., using path.Clean-like constructs),
  • Enforce confinement to a specific root directory,
  • And reject any attempted traversal outside that root.
  • Security testing: Use dynamic tests or fuzzers to send PUT requests with traversal segments and confirm that the application either blocks them or writes only within the intended upload directory.
  • Policy enforcement: Incorporate secure file handling guidelines into development standards and CI pipelines, optionally backed by automated linters or SAST tools tuned for path traversal patterns.

Sources

SourceLink
github.comgithub.com/patrickhener/goshs/security/advisories/GHSA-g8mv-vp7j-qp64

Frequently asked

questions

Yes. If goshs is exposed over the network and allows HTTP PUT requests, a remote attacker can exploit this issue by sending crafted requests with malicious paths.

The attacker needs the ability to reach the goshs server over the network and issue PUT requests. No local shell access is required, but any network-layer protections or authentication in front of the PUT endpoint can limit exploitability.

The safest pattern is to sanitize and canonicalize all user-supplied file paths, enforce that the final resolved path is strictly under a configured upload directory, and run the server with minimal filesystem privileges. Any request that attempts to escape the upload root should be rejected.

Establish a standard file-handling abstraction that:

  • Accepts only relative, validated paths,
  • Performs centralized normalization and root confinement checks,
  • And is reused across all upload and file-write code paths.

Combine this with regular security reviews, static analysis focused on filesystem usage, and configuration that limits write access to only the directories needed for application operation.

Find out what's already
exploitable in your codebase.