These write-ups are not threat intelligence and are not kept up to date as an incident develops. They are here to show how each attack worked, so you can find and fix the same techniques in your own setup. For the latest on an incident, read its sources.
Self-hosted runner takeovers (PyTorch and others)
2023–2024 · Ongoing
By fixing a typo to become a contributor, researchers got their pull requests to run without approval on non-ephemeral self-hosted runners of GitHub's runner-images, PyTorch and TensorFlow, stayed on the machines, and took the write tokens, PATs and cloud keys of the release jobs that ran there next.
- Access held
- T2Contents: WritePATs and AWS release keys
- Read the rest
- One supply chain attack to rule them all ↗
Full summary
A self-hosted runner attached to a public repository runs any workflow that asks for it, including one from a fork's pull request. By default a fork's pull request only needs approval if its author has never contributed, so fixing a typo is enough to skip it. A runner set up with the default steps is non-ephemeral: it keeps its files and lets a process started by one job keep running into the next. Adnan Khan used this against GitHub's own actions/runner-images, which had such a runner from February to July 2023, and could reach internal GitHub infrastructure and secrets used to build the hosted runner images; GitHub paid him 20,000 dollars. With John Stawinski he then did the same to PyTorch: a typo fix made them contributors, a pull request put a persistent foothold on a self-hosted runner, and later workflows on it gave up GITHUB_TOKENs with write access, personal access tokens and the pytorchbot AWS keys for the S3 buckets that hold PyTorch releases. Praetorian found the same setup in TensorFlow, which Google accepted as a critical supply chain issue. All were found and reported by researchers.
How it unfolded
Pick a step to zoom into it. A dashed line is a step the sources do not state. Blue dots are the checklist items that break the step.
Whole path
The whole attack, one row per step. Pick a step on the left, or click a box in its row.
By default a pull request from a fork runs its workflows without approval once its author has contributed before. Khan, Stawinski and Praetorian each became contributors with a trivial change, such as fixing a typo in a markdown file.
What breaks this step
- Audit every use of pull_request_target and remove or restructure risky ones
- Set the default GITHUB_TOKEN permission to read-only at the org level
- Require approval for first-time/external contributor workflow runs on forks
- Disallow self-hosted runners on public repositories
- Limit who and what can trigger workflows with workflow execution protections
- Pass untrusted values through env variables instead of ${{ }} expressions in run steps.
- Make self-hosted runners ephemeral.
- Lint workflows with zizmor or a similar tool in CI.
- Require approval for every outside contributor, not only first-time ones: one merged typo fix skips the default.
A self-hosted runner attached to a public repository, or to an organization runner group the repository can use, picks up any workflow whose runs-on matches it, including one from a fork. Praetorian's Gato tool finds such runners; in TensorFlow it found one running ARM64 Linux builds.
A runner registered with the default steps is non-ephemeral: files and background processes survive the job. A payload in the pull request starts a process that stays on the machine and watches the jobs that follow.
On PyTorch's runners the researchers took GITHUB_TOKENs with write access from running workflows, personal access tokens, and the pytorchbot user's AWS keys, which could write to the S3 buckets holding PyTorch releases. On GitHub's actions/runner-images, vulnerable from February to July 2023, the same position reached internal infrastructure and the secrets used to build every hosted runner image.
What breaks this step
- Third-party Actions pinned to a full commit SHA instead of a mutable tag or branch
- Restrict which Actions can run to GitHub-verified creators or an internal allow-list
- Set the default GITHUB_TOKEN permission to read-only at the org level
- Limit where workflow jobs can connect to, starting with release and deploy jobs
- Set `persist-credentials: false` on actions/checkout wherever later steps do not push
- Limit each self-hosted runner group to the repositories that need it
All of these were found and reported by researchers. GitHub paid Khan 20,000 dollars for runner-images through its bug bounty, Google accepted Praetorian's TensorFlow report as a critical supply chain vulnerability, and the projects moved away from non-ephemeral runners on public pull requests.
Frameworks
Ongoing. First seen January 2023. Mapping by ghtier, not yet reviewed. Threat landscape
Sources
- researchOne supply chain attack to rule them all
- researchTensorFlow supply chain compromise via self-hosted runner attack
- researchPyTorch supply chain compromise
- researchGitHub, PyTorch and more orgs vulnerable to self-hosted runner attacks
- trackerPyTorch GitHub misconfiguration (Wiz cloud threat landscape)
- trackerTensorFlow GitHub misconfiguration (Wiz cloud threat landscape)
Reported by: Adnan Khan / John Stawinski