SECURITY: No validation on volume host paths allows arbitrary filesystem access #35

Closed
opened 2026-02-16 06:56:31 +01:00 by clawbot · 1 comment
Collaborator

Severity: HIGH

File: internal/handlers/app.go lines 525-545 (HandleVolumeAdd)

Description

When adding a volume mount, the host_path form value is accepted without any validation or sanitization. An authenticated user can specify any host path (e.g., /etc/shadow, /var/run/docker.sock, /) and it will be bind-mounted into the container.

While this is a single-user system and the user is already an admin, this is still a defense-in-depth concern:

  • If the session is hijacked, the attacker gets arbitrary filesystem access via container mounts
  • There's no allowlist or denylist of paths
  • No warning to the user about dangerous mounts

Suggested Fix

  1. Add a configurable allowed_volume_prefix (e.g., /data/) that restricts host paths
  2. At minimum, reject paths like /etc, /var/run/docker.sock, /proc, /sys
  3. Validate that paths are absolute and normalized (no .. traversal)
func isAllowedHostPath(path string) bool {
    cleaned := filepath.Clean(path)
    if cleaned != path {
        return false // path contains .., //, etc.
    }
    blocked := []string{"/etc", "/proc", "/sys", "/dev", "/var/run/docker.sock"}
    for _, b := range blocked {
        if strings.HasPrefix(cleaned, b) {
            return false
        }
    }
    return true
}
## Severity: HIGH ## File: `internal/handlers/app.go` lines 525-545 (HandleVolumeAdd) ## Description When adding a volume mount, the `host_path` form value is accepted without any validation or sanitization. An authenticated user can specify any host path (e.g., `/etc/shadow`, `/var/run/docker.sock`, `/`) and it will be bind-mounted into the container. While this is a single-user system and the user is already an admin, this is still a defense-in-depth concern: - If the session is hijacked, the attacker gets arbitrary filesystem access via container mounts - There's no allowlist or denylist of paths - No warning to the user about dangerous mounts ## Suggested Fix 1. Add a configurable `allowed_volume_prefix` (e.g., `/data/`) that restricts host paths 2. At minimum, reject paths like `/etc`, `/var/run/docker.sock`, `/proc`, `/sys` 3. Validate that paths are absolute and normalized (no `..` traversal) ```go func isAllowedHostPath(path string) bool { cleaned := filepath.Clean(path) if cleaned != path { return false // path contains .., //, etc. } blocked := []string{"/etc", "/proc", "/sys", "/dev", "/var/run/docker.sock"} for _, b := range blocked { if strings.HasPrefix(cleaned, b) { return false } } return true } ```
Owner

dupe #20

dupe #20
sneak closed this issue 2026-02-16 07:09:03 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#35
No description provided.