Securing Self-Hosted GitHub Actions Runners

A self-hosted Actions runner executes whatever workflow code ships in an incoming pull request — on a public repository, that means an attacker-controlled PR can potentially run on it, unless it's gated. Here are the real hardening steps, whether the runner sits on GitHub itself or on a self-hosted host.

The actual risk, stated plainly

This isn't theoretical — security researchers have documented it repeatedly: a self-hosted runner registered against a public repo will run a workflow defined in a pull request from anyone who opens one, by default. The runner doesn't know the difference between a trusted maintainer's push and an unknown contributor's PR unless it's configured to.

The real fixes, in order

  1. Require approval for outside contributors. In repo settings, require a maintainer to approve workflow runs from first-time or outside contributors before anything executes.
  2. Use ephemeral, single-job runners. A runner that tears down after one job can't carry state or a compromised environment into the next run.
  3. Isolate the runner. Run it in its own container or VM with no access to production secrets, deploy keys, or other repos' credentials.
  4. Scope runner labels/groups narrowly. Only the repos that actually need that specific runner should be able to target it.

Same rules, self-hosted host or not

Rithub's self-hosted runner (built-in CI runners, see also GitHub Actions alternative, self-hosted) runs on the same model, so the same four rules apply directly — the difference is the host itself sits on your own infrastructure rather than being shared with arbitrary public internet traffic the way github.com is, which shrinks the blast radius if something does get through.

Sign up freeImport from GitHub