Why is running builds as root, or with the Docker socket mounted, a Jenkins security problem?
IntermediateConceptCredentials & security
Answer
Builds run untrusted-ish code: dependencies, test suites, PR changes. With the host Docker socket, any build can start a privileged container that mounts the host filesystem, read other builds' workspaces and credentials, and pivot to the node. On Kubernetes, prefer rootless builders, runAsNonRoot tool containers, dedicated builder nodes, NetworkPolicies, and separate agents for trusted (main branch, deploy) vs untrusted (PRs) builds.
More on Credentials & security
What credential types does Jenkins support out of the box?BeginnerWhat is the difference between Global and System credential scope?IntermediateHow do folder-scoped credentials help multi-team controllers?IntermediateHow does Jenkins mask secrets in logs and what are its limits?AdvancedWhat authorization strategies are available?IntermediateWhat are the key permissions to understand in matrix auth?Intermediate