Our executor runs as root, and we are keeping it
Every machine in Kosken runs two programs. kosken-agent talks to our servers and runs as a user with no privileges. kosken-exec runs the recipes, and it runs as root.
Some security teams have a rule against any service that runs as root. For them we planned an install option: the executor would run as a plain user and call sudo for each step that needs root, with a sudoers file that lists the exact commands Kosken may run. The plan was approved this week. Today we dropped it. This post explains why, and what limits the executor instead.
What the sudoers file would have needed
Before we wrote the installer, we counted what the file would have to allow. The recipes in our catalog have 1,540 command steps, and they call 133 different programs. Most of the steps are Proxmox calls (pvesh alone appears 904 times), then systemctl, docker, apt-get and dnf.
The arguments of those steps come from parameters: the name of a unit, a package, a container, a guest. sudoers matches arguments as text, so the file would need lines like systemctl *. With the right arguments, systemctl starts any unit you write, docker mounts the root file system into a container, apt-get installs a package with any script in it, and runuser becomes anyone. Each of those lines is root with extra steps.
Then there are 27 steps that are not commands. They are code inside the executor: write a config file and keep the old one for rollback, set a GPU power limit, run a restic backup, start a vLLM container. sudo checks the command line of a new process. It has nothing to say about code inside a process that already runs.
Plain Linux capabilities do not help either. A user with CAP_DAC_OVERRIDE can write /etc, but apt-get, dnf and systemctl check for user 0 and stop.
The last version of the plan was one sudo rule per need that hands each signed step to a short-lived root helper. That works. It also keeps the same boundary we have today, the signature on the recipe and the order, and it adds a line to the sudo log. The executor already writes its own log on the host.
What limits the executor today
The systemd unit does most of the work. Its key lines:
PrivateNetwork=yes
RestrictAddressFamilies=AF_UNIX
ProtectHome=yes
PrivateTmp=yes
CapabilityBoundingSet=CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_KILL CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_AUDIT_WRITE CAP_SYS_PTRACE CAP_SYS_RESOURCE
MemoryMax=512M
The executor has no network. Nothing can connect to it from outside, and it cannot send anything out. Orders reach it from the agent over a local socket. By itself, it cannot mount a file system, load a kernel module, change the clock or touch the network configuration, because those capabilities are not in its bounding set, and no program it starts can get them back.
It runs only recipes signed by a key that chains to our root key, which is kept offline. Each step is a fixed list of arguments, never a shell string. Each order is signed with a second key, names one machine, expires, and runs once.
When a recipe needs more, for example CAP_SYS_ADMIN to change a GPU power limit, it declares a need. A person with root on that host turns the need on with kosken-agent enable gpu, which writes a systemd drop-in. Kosken cannot do that from our side.
What does not limit it
While writing the help page for auditors, I found a mistake in our own notes. They said the executor sees a read-only file system. It does not. The unit does not set ProtectSystem, because recipes install packages and edit files in /etc. With the capabilities above, the executor can write any file outside the home directories, and a process that can write a systemd unit can get full root on the next boot. On a host with Docker, a recipe that runs docker can do the same.
So the sandbox limits the reach of the executor, and the signature decides what runs. If someone took over our platform and its signing keys, they could sign a recipe, until we revoke the key with the offline root key. That is true of any tool that manages servers remotely, with sudo or without it. What you get from us is a record you can check without trusting us: the executor writes each order to /var/lib/kosken/exec/audit.log on your host, with a hash chain.
Check it yourself
systemctl cat kosken-exec.service
ls /etc/systemd/system/kosken-exec.service.d/
systemd-analyze security kosken-exec.service
sudo /usr/local/lib/kosken/current/kosken-agent log-audit
The full list of limits, with what each need adds, is in the help page Why the executor runs as root. The sudo design is still in our spec. If your policy does not allow a root service, tell us: the design is there for that case.