Build Runners Aren't Cattle: The Credential Debt Piling Up in Self-Hosted CI
Photo by Photo by Valentin Lacoste on Unsplash on Unsplash
The premise of self-hosted CI is that the runner is interchangeable. A job lands, the machine builds, the machine is torn down. Elastic capacity, no drift, no pets. That is the design intent. In practice, a surprising number of runners are closer to long-lived workstations with a build agent bolted on — machines that have been in service for eighteen months, carry a home directory full of half-cleaned workspaces, and hold credentials that were granted for a single job and never revoked.
The reason is not negligence. It is that CI infrastructure is invisible in the way that plumbing is invisible. It works, it is not customer-facing, and it sits between two things that do get attention: the source code and the shipped product. Which makes it an excellent place to persist.
Disposable in Theory Only
Ask a simple question about any runner fleet: if this machine were compromised right now, what would the attacker hold?
In a properly ephemeral fleet, the answer is a short-lived token scoped to a single job, valid for minutes, and useless once the job ends. In many real fleets, the answer includes a deploy key for the release repository, a long-lived cloud access key, package registry credentials, an SSH key with access to an artifact host, a code-signing certificate, and a local Docker daemon socket. Some of those were added years ago to solve a specific problem and never revisited.
A runner that caches dependencies between jobs is genuinely faster. It is also a persistence mechanism. A poisoned Maven or NuGet cache, a modified build tool in a shared toolchain directory, or a tampered artifact in a workspace that was never wiped will be picked up by the next ten jobs before anyone notices.
What a Runner Remembers
Inventory is the unglamorous first step, and it is usually sobering. Runners commonly retain:
- Cloud credentials — environment variables, instance profiles, or metadata-service access that lets any process on the host mint tokens.
- Version control secrets — deploy keys, personal access tokens, or app credentials embedded in job configuration.
- Artifact and registry access — credentials for internal package feeds, container registries, and build caches.
- Signing material — certificates and keys for Windows or macOS binaries, the sort of thing that matters enormously for a game build headed to a storefront.
- Platform SDK credentials — console vendor tooling and storefront publishing tokens for the deployment pipeline.
- Orchestration state — kubeconfig files, deployment manifests with embedded secrets, Helm values with plaintext passwords.
- Workspace residue — source trees, uncommitted configuration, build logs containing diagnostics.
Each item was added for a defensible reason. Taken together, they describe a machine with more authority than most developer laptops and less oversight than a production server.
The Pivot Path
Chain these together and the value of a runner becomes clear.
A compromised runner usually begins with something small: a malicious dependency that executes during install, a pull request from an external contributor that runs on a shared label, or a build script in a repository the team does not fully control. From there, the first move is reading what is available — environment variables, credential files, the metadata endpoint. The second move is using that to reach source control, then artifact storage, then the deployment path.
Because the runner sits upstream of the artifact that production consumes, this is not a lateral move. It is a straight line. In studios, the same runner that publishes internal builds frequently holds the path to the storefront pipeline, which means the difference between an internal nuisance and a signed build distributed to customers can be a single unscoped credential.
Isolation: Beyond the Container
Containerizing builds is a good first step and rarely sufficient. A container running with the Docker socket mounted is not isolated; it is a proxy for root on the host. A job that can reach the cloud metadata endpoint can obtain the host's instance credentials regardless of what the container's filesystem looks like.
Isolation worth the name includes network egress controls scoped to the destinations a job genuinely needs, no access to host metadata services or a token-brokered equivalent, no shared host directories across jobs, and separate runner pools by trust level. That last point carries the most weight. Builds triggered by forks or external contributors should never share a pool with builds that touch release infrastructure. The convenience of one label for everything is not worth the blast radius.
Scoping Credentials to the Job, Not the Fleet
The single highest-value change most organizations can make is eliminating standing credentials. Issue tokens through workload identity at job start, scope them to the artifact path the job writes to, and let them expire in minutes. Where a long-lived credential is genuinely unavoidable — signing material is the usual culprit — isolate it behind a service that performs the specific operation and refuses everything else, rather than handing the key to the runner.
Rotate on a schedule and on suspicion. A signing credential that has been in the same vault slot for two years has no known provenance and no way to determine exposure.
Lifecycle Discipline
The claim that runners are ephemeral should be verifiable. Automate teardown at the host level, not the workspace level. A job that deletes its working directory has not cleaned anything if the layer beneath it retains the toolchain, the caches, and the environment files. Recycle hosts on a fixed interval regardless of apparent health, and treat any host that cannot be reimaged cleanly as a finding rather than an inconvenience.
A Hardening Checklist
- Every job runs on a host created after the job was queued.
- Trust levels map to separate runner pools; untrusted contributions never touch release pools.
- No standing cloud keys on hosts; credentials are minted per job and expire in minutes.
- Egress is allowlisted by destination; metadata endpoints are blocked or token-brokered.
- Docker socket mounts and privileged containers are prohibited outside a documented exception list.
- Package and build caches are validated, partitioned by trust level, and periodically discarded.
- Signing and publishing operations are mediated by a dedicated service, not performed directly on the runner.
- Runner inventory is reconciled monthly against what the fleet management system reports.
- Logs from the runner host are shipped off-host and retained long enough to reconstruct a build.
- A named owner exists for every runner group, with an expiry date on the group itself.
Do the Inventory First
None of this requires a new platform. It requires an afternoon with the fleet, a spreadsheet, and the uncomfortable exercise of writing down what each machine can reach. Most teams find two or three credentials that nobody can account for and one runner group that has been running since a proof of concept three years ago.
The runner is not cattle if it holds the keys to the build. Fortify the stack by treating the build floor with the same discipline as the production perimeter — because from an attacker's point of view, it is the same perimeter.