# Self-Hosted GitHub Actions Runner Security

> Self-hosted GitHub Actions runner security: the threat model, public repos, one job per VM, least privilege, pinned actions, egress and a 12-point checklist.

- URL: https://flockvm.com/learn/self-hosted-runner-security
- Last updated: 2026-11-10

A self-hosted GitHub Actions runner runs whatever code reaches its workflows, with the job's secrets and the machine's network access. Securing it comes down to five rules: never attach it to a public repository, give each job a fresh machine that is deleted after, isolate that machine from the host and from other jobs, give each job the least privilege it needs, and watch what registers as a runner and what the runner can reach. GitHub's own guide says why: self-hosted runners "can be persistently compromised by untrusted code in a workflow."

The checklist, in short:

1. No self-hosted runner on a public repository.
2. One job per machine, deleted after (ephemeral or JIT runners).
3. A VM boundary per job, not only a container, for code you don't fully trust.
4. Organization runners in groups, limited to the repositories that need them.
5. `permissions:` set on every workflow, read-only by default.
6. OIDC to cloud providers instead of long-lived keys.
7. Deploy secrets in environments, and deploy jobs off shared runners.
8. Third-party actions pinned to a full commit SHA, updated by Dependabot.
9. No `pull_request_target` that checks out pull request code.
10. Approval required for fork pull request workflows; reviews on `.github/workflows/`.
11. Runner egress limited: no cloud metadata, no internal network, an allowlist where you can.
12. Runner registrations audited: an unknown runner is an incident.

GitHub's guidance on this page was read on its documentation on 8 November 2026. flockvm sells self-hosted runners; where it covers a point and where it doesn't is in [what a managed runner covers](#what-a-managed-runner-covers).

## The threat model: who can run code on your runner?

More people than the list of committers:

- **Anyone who can push a workflow.** A workflow file is code that runs on the runner, with the secrets it names.
- **Anyone who can open a pull request**, when workflows run on `pull_request`. In a public repository that is anyone with a GitHub account. In a private one, GitHub notes that anyone who can fork it and open a pull request, "generally those with read access", could compromise the runner, its secrets and a `GITHUB_TOKEN` that may have write access.
- **Every dependency your build installs**, and every action it uses: a compromised npm package or action runs with the job's rights.
- **Other repositories**, on organization or enterprise runners: "GitHub can schedule workflows from multiple repositories onto the same runner."

What an attacker gets from that code: the job's secrets and token, anything on the machine (SSH keys, cloud credentials, caches), whatever the machine can reach on the network (GitHub cites cloud metadata services), and, on a persistent runner, every job that runs after.

## Never on public repositories

GitHub is blunt: "self-hosted runners should almost never be used for public repositories on GitHub, because any user can open pull requests against the repository and compromise the environment." Runner groups follow the same default: only private repositories can use a group's runners until an owner changes it.

Keep public repositories on GitHub-hosted runners. If one workflow serves both, choose the runner from the repository's visibility:

```yaml
jobs:
  test:
    runs-on: ${{ github.event.repository.private && 'my-self-hosted-label' || 'ubuntu-latest' }}
```

## One job per machine

A persistent runner keeps its disk, Docker images, caches and processes from job to job, so one compromised job can poison every later one. GitHub also notes that a secret passed as a command-line argument can be seen by another job on the same runner with `ps x -w`.

Register runners as ephemeral (`config.sh --ephemeral`) or start them from a just-in-time configuration, and delete the machine after its one job. GitHub "recommends implementing autoscaling with ephemeral self-hosted runners; autoscaling with persistent self-hosted runners is not recommended." [Ephemeral GitHub Actions runners](/learn/ephemeral-github-actions-runners) shows the three ways to set it up, with the commands.

GitHub tempers this itself: destroying the runner after every job is less effective than it looks, because "there is no way to guarantee that a self-hosted runner only runs one job." Treat one job per machine as one layer, check that your autoscaler really creates a new machine for each job, and keep the least-privilege rules below.

## Isolation: process, container or VM?

| Runner on | Separates jobs from the host by | Shared with other jobs |
|---|---|---|
| A server, as a process | Unix users, at best | The kernel, the disk, the network |
| A container per job (ARC pods, Docker) | Namespaces, cgroups, seccomp | The node's kernel |
| A VM per job | Hardware virtualization, its own guest kernel | The hypervisor |

Containers are a reasonable boundary for code you trust. For code you don't (contributors' pull requests, unreviewed dependencies, coding agents), a kernel exploit or container escape reaches the node and every job on it. Docker-in-Docker makes it worse: in ARC's dind mode, "the Docker-in-Docker container requires privileged mode." A VM per job, such as a Firecracker microVM, puts a guest kernel between the job and the host. [MicroVM vs container](/learn/microvm-vs-container) goes through the difference.

## Least privilege for each job

**Set `permissions:`** at the top of every workflow, read-only, and widen it per job. GitHub: "make sure that the `GITHUB_TOKEN` is granted the minimum required permissions."

```yaml
permissions:
  contents: read

jobs:
  release:
    permissions:
      contents: write   # only this job can push tags
    runs-on: ubuntu-latest
```

**Use OIDC instead of long-lived cloud keys.** The job requests a short-lived token from the cloud provider, and you "stop storing these credentials as long-lived secrets":

```yaml
permissions:
  id-token: write   # to request the OIDC token
  contents: read

jobs:
  deploy:
    runs-on: my-self-hosted-label
    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/ci-deploy
          aws-region: eu-west-3
```

Scope the role's trust policy to one repository and branch with the `sub` claim, such as `repo:acme/api:ref:refs/heads/main`, so a pull request cannot assume it.

**Keep deploy secrets in environments with required reviewers**, and know their limit on self-hosted runners: GitHub warns that such workflows "are not run in an isolated environment and are still susceptible to the same risks". A deploy job on a shared persistent runner exposes its secrets to whatever ran there before. Run deploys on ephemeral runners, in a separate runner group.

## Supply chain: actions and triggers

**Pin third-party actions to a full commit SHA**, not a tag that can be moved:

```yaml
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
```

GitHub adds: "you should verify it is from the action's repository and not a repository fork." Its secure-use guide now ranks a workflow dependency lockfile, which records "the exact commit for every action your workflows depend on, including transitive dependencies", above SHA pinning for repositories that adopt it.

**Let Dependabot update the pins**, so pinned does not mean stale:

```yaml title=".github/dependabot.yml"
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
```

**Be careful with `pull_request_target`.** It runs with the base repository's secrets and a write token, on pull requests from forks. GitHub: "Avoid using the `pull_request_target` workflow trigger if it's not necessary", and workflows that use it "must not explicitly check out untrusted code". The same applies to `workflow_run` workflows that handle artifacts from a pull request.

**Gate who can change workflows.** Require approval for fork pull request workflows in **Settings → Actions → General**, and require reviews on `.github/workflows/` with branch protection or CODEOWNERS.

## Network egress: what can a job reach?

A job can reach whatever the runner's machine can. On a server in your data center or VPC, that can be internal services, databases and the cloud metadata endpoint (`169.254.169.254`), which hands out the machine's own cloud credentials. GitHub asks: "Does the machine have network access to sensitive services? For example, Azure or AWS metadata services."

- Put runners on a network segment of their own, with no route to internal services they don't need.
- Block the cloud metadata endpoint from inside job machines, or give the instance a role with no permissions.
- Allowlist outbound destinations where the build allows it: package registries, GitHub, your artifact store.

StepSecurity's Harden-Runner action "monitors network egress, file integrity, and process activity" on runners and can block outbound traffic outside an allowlist (`egress-policy: block`). On self-hosted runners it needs a paid plan: "Self-hosted runners require an Enterprise subscription, even for public repositories."

```yaml
steps:
  - uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
    with:
      egress-policy: audit
```

## Runner groups and labels: who can target which runner?

Labels choose a runner; they don't restrict who may use it. Any workflow in a repository that can see a runner can target it with its labels. Access control lives in **runner groups**: an organization owner can limit a group to "a specific list of repositories", and set which workflows can use it. Use separate groups for build runners and for deploy runners with production access, and keep the default group empty.

## Audit: an unknown runner is an incident

In the Shai-Hulud npm campaign of November 2025, as analysed by [Sysdig](https://www.sysdig.com/blog/how-threat-actors-are-using-self-hosted-github-actions-runners-as-backdoors) in January 2026, the malware registered infected machines as self-hosted runners named `SHA1HULUD` on repositories its operators controlled, then triggered commands on them through a workflow. Its advice: "actively monitor their GitHub runner inventory for unauthorized registrations", using the `repo.register_self_hosted_runner` audit log event.

- Review **Settings → Actions → Runners** in each organization and repository: every runner should map to a machine you know.
- Alert on runner registration events in the organization's audit log.
- With ephemeral runners the list should be nearly empty between jobs; a runner that stays is worth a look.
- Watch runner processes for unexpected outbound connections.

## What a managed runner covers

A managed runner provider takes some of this list off your hands, not all of it. With flockvm, read from its [CI security](/docs/ci/security) and [isolation](/docs/security/isolation) docs:

| Checklist item | With flockvm |
|---|---|
| 1. Public repositories | Refused: a job from a public repository fails at once, with no VM and no cost |
| 2. One job per machine | Yes: a JIT runner per job, in a VM created for it and deleted after, never reused; the runner is removed from your repository |
| 3. VM boundary | A Firecracker microVM per job, under the jailer, with its own guest kernel and its own uid on the host |
| 11. Egress | The host drops traffic to itself, to other VMs, to private ranges and to `169.254/16` (cloud metadata); port 25 is refused; known-bad destinations are blocked. Outbound Internet over IPv4 is open, and there is no per-customer allowlist |
| Access to the machine | No SSH key on runner VMs: nobody can log in, you included |
| Runner credentials | The JIT config reaches the VM through its metadata service and is never logged |

What stays yours: `permissions:`, OIDC, environments, pinned actions, triggers, who can change workflows (items 4 to 10), and egress allowlisting inside the job if you need it. The flockvm GitHub App works on the repositories you select, asks for Administration read and write to register and remove each job's runner, and has no write access to your code or your workflows ([its permissions](/docs/ci/security#what-the-github-app-can-do)).

And the limits, stated plainly: flockvm has no security certification (no SOC 2 report); runners run on one host in France, at most 4 runner VMs at once across all organizations; Linux x64 only. It suits a small team's private Linux jobs; [GitHub Actions runners on Firecracker](/github-actions-runners) has the rest, and [GitHub Actions pricing](/learn/github-actions-pricing) and [how to speed up GitHub Actions](/learn/speed-up-github-actions) cover cost and speed.

## FAQ

### Are self-hosted runners safe?

For private repositories, with ephemeral runners on isolated machines and least-privilege workflows, they can be. A persistent runner on a server with network access to your internal systems is the risky setup: one compromised job can affect every later job and reach whatever the server can.

### Can I use a self-hosted runner with a public repository?

GitHub advises against it: "self-hosted runners should almost never be used for public repositories", because any user can open a pull request that runs code on it. Keep public repositories on GitHub-hosted runners, which give each job a new VM.

### Are ephemeral runners enough to secure a self-hosted runner?

No. They stop one job from affecting the next, but not a malicious job from using its own secrets, its token or the machine's network. Add least-privilege `permissions:`, OIDC, pinned actions and egress limits.

### Is a container per job enough isolation?

For code you trust, often. For untrusted code it shares the node's kernel with other jobs, and Docker-in-Docker setups run privileged containers. A VM per job puts a guest kernel between the job and the host.

### How do I find unauthorized self-hosted runners?

List the runners in **Settings → Actions → Runners** of each organization and repository, and alert on the `repo.register_self_hosted_runner` event in the audit log. The Shai-Hulud malware registered infected machines as runners named `SHA1HULUD`.

## Sources

- [GitHub Docs: Secure use reference (self-hosted runners, public repositories, GITHUB_TOKEN, OIDC, pinning, pull_request_target, runner groups)](https://docs.github.com/en/actions/reference/security/secure-use) (accessed 2026-11-08)
- [GitHub Docs: Managing access to self-hosted runners using groups](https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/manage-access) (accessed 2026-11-08)
- [GitHub Docs: Configuring OpenID Connect in Amazon Web Services](https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws) (accessed 2026-11-08)
- [GitHub Docs: Keeping your actions up to date with Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) (accessed 2026-11-08)
- [GitHub Docs: Self-hosted runners reference (ephemeral runners)](https://docs.github.com/en/actions/reference/runners/self-hosted-runners) (accessed 2026-11-08)
- [GitHub Docs: Deploying runner scale sets with ARC (Docker-in-Docker mode)](https://docs.github.com/en/actions/how-tos/manage-runners/use-actions-runner-controller/deploy-runner-scale-sets) (accessed 2026-11-08)
- [Sysdig: How threat actors are using self-hosted GitHub Actions runners as backdoors (13 January 2026)](https://www.sysdig.com/blog/how-threat-actors-are-using-self-hosted-github-actions-runners-as-backdoors) (accessed 2026-11-08)
- [step-security/harden-runner README (egress policy, self-hosted runner support)](https://github.com/step-security/harden-runner) (accessed 2026-11-08)
- [GitHub API: actions/checkout tag v4.2.2 (commit SHA)](https://api.github.com/repos/actions/checkout/git/ref/tags/v4.2.2) (accessed 2026-11-08)
