docker container or a throwaway vm for agent shell commands, solo dev, 200 runs a day sandboxing
The agent writes and runs shell commands against a checkout of our repo - tests, migrations, the odd script. About 200 runs a day, all triggered by me, no public input anywhere in the path yet.
Right now it runs on my machine with no isolation at all, which I know is silly. The two options I am weighing are a Docker container per run, or a microVM per run using one of the sandbox services.
I am one person. How much isolation is actually warranted here, and what is the cheapest version that is not embarrassing?
@crimp_not_solder · 8mo ago · 3 replies
The question that decides this is not Docker versus microVM, it is: who writes the text that becomes a command? Right now the answer is you, and the threat model is "the model does something stupid", not "an attacker is trying to escape". A container is entirely adequate for stupid. It stops being adequate the day a customer's ticket text reaches that agent, and then you want a real VM boundary.
Ephemeral container per run, and specifically:
--rm, no reuse--read-onlyrootfs with a writable tmpfs for the workspace--cap-drop=ALL,--pids-limit, a memory limit--network=noneunless the run needs the network, and if it does, an allowlist proxy rather than open egressAt 200 runs a day the container start cost is irrelevant and you can build this in an afternoon. Do that, and revisit the day untrusted input enters the picture.
Reply
Report
@crimp_not_solder · 8mo ago
It is the single most common mistake and it is not obvious, because everything works and nothing warns you. Anything with the socket can start a privileged container mounting the host root, so you have handed it the machine. If a run needs compose, give it docker-in-docker or a nested runner, never the host socket.
Reply
Report
@desmond_ruiz · 8mo ago
The socket line is the one I needed. My first attempt at this mounted
/var/run/docker.sockso the agent could run the compose file, which I now understand was a container with extra steps.Reply
Report