Originally published on kuryzhev.cloud
The scenario
A pull request from a contributor changes a Jenkinsfile , and the build runs on a long-lived agent that also builds your release branch. Nothing in the pipeline looks malicious. However, the agent has a Docker socket mounted, a cloud credentials file in the home directory, and a workspace left over from the last job. Jenkins agent hardening exists to make that situation boring. A build can run arbitrary code, so the machine running it should have nothing worth stealing and no way to reach beyond its own job.
The Jenkins project documents the controller/agent trust model in its controller isolation guide . The short version is that anyone who can change a pipeline can execute code on an agent, so agents are a trust boundary.…