Skip to content
Kaiov0.8.0

Agents that want the socket

Some agent platforms start a sandbox container for each task, and to do that their Compose file mounts the Docker socket. OpenHands is the best known; its local setup runs:

Terminal window
docker run -it --rm --pull=always \
-e AGENT_SERVER_IMAGE_REPOSITORY=ghcr.io/openhands/agent-server \
-e AGENT_SERVER_IMAGE_TAG=1.26.0-python \
-e LOG_ALL_EVENTS=true \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.openhands:/.openhands \
-p 3000:3000 \
--add-host host.docker.internal:host-gateway \
--name openhands-app \
docker.openhands.dev/openhands/openhands:1.8

Their documentation marks that local GUI as deprecated in favour of a newer installer; the line that matters here is the same in many tools.

-v /var/run/docker.sock:/var/run/docker.sock is not access to “Docker”. It is the daemon’s full API, and the daemon runs as root: whoever can write to that socket can start a container that mounts / from the host, with every capability, and that is root on the machine. A sandbox the agent starts through it is only as contained as the agent decides it is.

For an agent, the agent deciding is the problem. It picks its next action from text it was given: a web page, an issue, a file in the repository it was asked to fix. Any of those can carry instructions, and with the socket in reach the worst instruction is no longer limited to the container.

Kaio reads every Compose file it deploys for what makes a container root on the host: a bind mount of the Docker, Podman or containerd socket, a bind mount of /, privileged: true, a host namespace, or the ALL, SYS_ADMIN or SYS_MODULE capability. The OpenHands line above is the first of these.

  • Every way in refuses it first. A deploy, an apply, a rollback, a copy, or a restart or up that has to bring the stack up, whose file hands the host to a service is refused with the risks named, code host_access (for a copy, when nothing else stops it), until the caller says it accepts them. An import writes the stack without starting it, so the question comes when it is first brought up. Nothing is deployed in between.
  • From the web UI, the deploy dialog stops on a list of them and the button becomes Deploy anyway; Apply changes and a rollback ask the same question in a confirmation before going ahead.
  • From the CLI, stack deploy, stack apply, stack rollback, stack copy, and a stack restart that has to bring the stack up, stop and name the risks, until run again with --accept-risks; the TUI asks in a confirmation and goes ahead on y.
  • Through MCP, kaio_stack_deploy, kaio_stack_apply, kaio_stack_rollback and kaio_stack_copy refuse and name the risks, until the agent calls again with accept_risks: true.
  • Over HTTP, the same calls take accept_risks: in the body of POST /api/stacks, as a query parameter on apply and rollback.
  • Afterwards, the stack carries the mark for as long as the file does: HOST ACCESS on its row and host on its cluster board card, ◈ host in the TUI, a HOST column in stack ls, host_access in kaio_overview and kaio_stack_host_access in metrics.
  • Everywhere, the deploy leaves a warn event naming them, beside the version and the audit log entry that say who made it. POST /api/stacks/{name}/risks answers the same list without deploying, for a pipeline that wants to fail on it.
The deploy dialog for an edge-proxy stack stopped on a red panel: traefik mounts the container runtime socket, quoted as the file writes it, and the button reads Deploy anyway.
A Traefik that reads container labels needs the socket. The dialog names it before anything runs, and the deploy goes ahead only on a second click.

Kaio warns; it does not forbid. A stack that needs the socket, a reverse proxy reading container labels or Kaio itself, is a legitimate thing to run, and the decision is yours. The check makes sure it is made on purpose.

Let it act through Kaio instead. An agent that has to deploy, update or restart stacks does not need the socket: give it Kaio’s MCP server with a credential at read or write, as An agent that runs Kaio does. There is no shell tool, every call is logged under its name, and taking the access back is one line in the proxy.

Give it a host of its own. If the platform truly needs to start containers, run it on a server that holds nothing else: no other stack, no credentials, no route to your internal network. Join it to the cluster like any other node and manage it from the cluster board; a stack that owns its host has nothing left to escape to.

Use a daemon it cannot hurt. Rootless Docker or Podman runs the daemon as an ordinary user, so the socket hands over that user rather than root. Kaio runs against Podman as well.

Never on a shared host. A socket-mounting agent next to your production stacks can read their volumes, their environment and their secrets through the daemon, and Kaio’s secret masking does not apply to a process that talks to Docker directly.

Kaio, built by Régis Gaidot