How do you secure self-hosted runners?
AdvancedProductionGitHub Actions and GitLab CI in Production
Answer
- Never attach self-hosted runners to public repos, since a fork PR can run arbitrary code on them.
- Use ephemeral runners (
--ephemeral, ARC scale sets) so each job starts clean. - Put them in a network segment without access to internal systems beyond what builds need.
- Use runner groups and restrict which repos and workflows may use them.
- Avoid mounting the Docker socket; run as non-root with rootless builders.
- Grant cloud access via OIDC role bound to repo/environment, not instance profiles broad enough for every job.
- Patch the runner image regularly; the runner application auto-updates, but the OS does not.
More on GitHub Actions and GitLab CI in Production
How do you organise reusable workflows for an organisation on GitHub?IntermediateHow do you reduce GitHub Actions minutes cost on private repos?IntermediateHow do you design the GitHub Actions OIDC trust policy for AWS safely?AdvancedHow do you handle approvals and deployments across environments in GitHub Actions?IntermediateHow do you handle required checks when workflows use path filters or matrices?AdvancedHow do you keep GitHub Actions workflow files themselves safe from unauthorised changes?Intermediate