T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/deploy-agent.sh:122
- Finding
- Untrusted Docker Compose Files Can Request Host-Level Privileges<![CDATA[ ## Vulnerability Details **File Location**: `scripts/deploy-agent.sh`, lines 122–135 **Vulnerability Type**: Automatic execution of untrusted privileged container configuration **Risk Level**: Critical ### Vulnerable Code ```bash local compose_file="" for cf in docker-compose.yml docker-compose.yaml compose.yml compose.yaml; do [ -f "$dir/$cf" ] && compose_file="$dir/$cf" && break done if [ -n "$compose_file" ]; then echo "━━━ Deploy-Agent: Deploy with Docker Compose ━━━━━" info "Compose file: $compose_file" # Stop existing if running docker compose -f "$compose_file" -p "$name" down 2>/dev/null || true docker compose -f "$compose_file" -p "$name" up -d --build 2>&1 | while IFS= read -r line; do echo " $line"; done local status=${PIPESTATUS[0]} ``` ### Technical Analysis The deployment workflow automatically discovers and executes a project-controlled Docker Compose file. It does not inspect the resolved Compose configuration, enforce a security policy, or ask the user to approve requested privileges. A Compose file can request security-sensitive Docker capabilities, including: - `privileged: true` - Host PID, IPC, or network namespaces - Arbitrary Linux capabilities - Host devices - Bind mounts of `/`, `/etc`, user home directories, or other sensitive paths - A bind mount of `/var/run/docker.sock` - Changes to seccomp or AppArmor protections Because the documented workflow explicitly supports uploaded or otherwise externally supplied projects, an attacker-controlled project can place these directives in a Compose file. Docker daemon access is effectively host-administrative in many environments, so merely placing the workload inside a container does not establish an adequate security boundary. ### Attack Path 1. An attacker supplies a project containing `compose.yml` or another supported Compose filename. 2. The Compose file defines a service with a dangerous setting, such as `privileged: true`, a mount of the ho ...[truncated 967 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Resolve the configuration before deployment with `docker compose config` and parse the resulting YAML using a proper YAML parser. 2. Reject or require explicit approval for: - `privileged: true` - Host PID, IPC, or network modes - Docker socket mounts - Host device access - `security_opt` settings that disable confinement - Dangerous capabilities such as `SYS_ADMIN` - Bind mounts outside an explicitly approved project data directory 3. Present a security summary of all services, volumes, ports, capabilities, namespaces, and devices before execution. 4. Run untrusted projects in a dedicated virtual machine or isolated rootless Docker environment rather than against the primary host daemon. 5. Apply resource limits, read-only filesystems, `no-new-privileges`, capability dropping, and non-root users where supported. 6. Require a separate explicit option for privileged Compose deployment rather than enabling it through automatic project detection. ]]>
