GitHub Actions Exploitation: Self Hosted Runners
Public repositories used non-ephemeral self-hosted GitHub Actions runners, allowing unauthenticated users to execute arbitrary code on the runner via a pull request. This gave access to the internal network, the ability to backdoor the runner, and potential theft of GitHub tokens from other workflows.
Published on synacktiv.com
Rédigé par Hugo Vincent - 17/07/2024 - dans Pentest - Téléchargement
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the misconfiguration of using self-hosted runners with public repositories, where workflows triggered by pull requests from forks execute on the runner without proper isolation or restrictions.
Impact
An attacker could access the internal network, backdoor the non-ephemeral runner for persistent access, and steal GitHub tokens with write privileges from other workflows, potentially leading to further compromise.
What the attacker needed
Public repository; self-hosted runner; ability to create pull request
How it was found
- Identify a public repository that uses a self-hosted runner by examining workflow files and run logs.
- Create a pull request that modifies a workflow to run on the self-hosted runner and includes a step to download and execute a script.
- The script runs on the runner, collecting system information and sending it to an attacker-controlled server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
GitHub Actions is a service that runs automated tasks (workflows) when code changes. A self-hosted runner is a computer you manage that runs these tasks. If a public repository allows anyone to trigger a workflow on such a runner, an attacker can run their own commands on that machine, potentially reaching internal systems.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.