Skip to main content

SKY-D331 · Deployment and infrastructure

Host device or control path mounted into a container

High

A Docker Compose service that maps a host device, the whole /dev, /proc or /sys tree, /run/udev, or the Docker socket into the container. These paths give the container direct control over host hardware or over the host itself.

Languages
Docker Compose
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security; the detector never reports CRITICAL.
Finding type
review
Catalog name
Docker Compose host device exposure
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Whoever can talk to the Docker socket can start a privileged container with the host's disk mounted, which is root on the host. Broad /dev, /proc or /sys access lets a compromised container read other processes' memory or reconfigure hardware.

What Skylos flags

docker-compose.yml · YAMLReported on line 5
services:  fleet-agent:    image: ghcr.io/acme/fleet-agent:1.8.0    restart: always    volumes:      - /var/run/docker.sock:/var/run/docker.sock      - ./agent.toml:/etc/fleet-agent/agent.toml:ro    environment:      FLEET_API: https://fleet.example.com

What Skylos leaves alone

docker-compose.yml · YAML
services:  fleet-agent:    image: ghcr.io/acme/fleet-agent:1.8.0    restart: always    volumes:      - /var/run/postgresql:/var/run/postgresql      - agent-state:/var/lib/fleet-agent      - ./agent.toml:/etc/fleet-agent/agent.toml:ro    environment:      FLEET_API: https://fleet.example.comvolumes:  agent-state:

Why Skylos leaves it alone

The service still mounts a host socket folder, but it is PostgreSQL's, not Docker's, and it is not a device or kernel interface. Named volumes and files from the project folder are not host control paths either.

How Skylos decides

  1. Runs with --danger. Reads the same Compose files as SKY-D330 (compose.y*ml, docker-compose.y*ml and names starting with compose. or docker-compose.), skipping symlinks, files over 1 MB and YAML that does not parse.
  2. For each service, reads the host side of every devices: and volumes: entry, in short form (/host:/container) or long form (source: or src:).
  3. Counts the path when it is /dev, /proc, /sys, /run/udev, /run/docker.sock or /var/run/docker.sock, or anything below one of them, such as /dev/video0 or /sys/class/gpio.
  4. Skips host paths written with ${...}, which are not resolved. A :ro suffix does not change the result.
  5. Does not need an edge or GPU context: any service is checked. Reports HIGH once per service, on its devices: line when the service has one, otherwise on its volumes: line.

How to fix it

Mount only what the service needs. Here the agent only reports status, so it does not need the Docker socket at all. A service that must manage containers is better run as a host service under its own user; a socket proxy still mounts the socket and is still reported, so give that mount a suppression with a reason.

docker-compose.yml · YAML · the fix, against the flagged file
services:  fleet-agent:    image: ghcr.io/acme/fleet-agent:1.8.0    restart: always    volumes:Removed:       - /var/run/docker.sock:/var/run/docker.sock      - ./agent.toml:/etc/fleet-agent/agent.toml:ro    environment:      FLEET_API: https://fleet.example.com

When it can be wrong

  • A camera or serial device that the service really needs, such as /dev/video0, is reported the same way as a broad /dev mount. Keep the device specific and suppress it with a reason.
  • It misses a host path that comes from a variable, such as ${DOCKER_SOCKET}:/var/run/docker.sock.
  • The finding sits on the devices: or volumes: key, not on the mount itself. When a service has both keys it points at devices: even if the risky path is under volumes:.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put the marker on the reported volumes: or devices: line, or on a comment line directly above it.

    YAML
    volumes:  # skylos: ignore[SKY-D331] camera node needs /dev/video0
  • A marker on the mount line itself does not work: the finding is on the volumes: line above it, and only that line and the line before it are read.

  • [tool.skylos] ignore = ["SKY-D331"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.