From Self-Hosted GitHub Runner to Self-Hosted Backdoor
A leaked GitHub personal access token with repo scope allowed the red team to modify an existing GitHub Actions workflow to run malicious code on a self-hosted runner, leading to a backdoor in the internal network. The attacker could then escalate privileges and move laterally within the organisation.
Published on praetorian.com
Continuous Integration and Continuous Delivery (CI/CD) systems are powerful and configurable tools within modern environments. At Praetorian, we are seeing organizations migrate to SaaS solutions like GitHub (GitHub.com) as their source code management and CI/CD solution, instead of on-premises tools like BitBucket…
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 combination of a leaked personal access token with broad repo scope and the use of self-hosted runners that were not isolated, allowing code execution on the runner and persistence.
Impact
The attacker gained a persistent foothold on the self-hosted runner and used it to move laterally and gain substantial access within the internal environment; however, the attack relied on weak configurations and the Teams plan lacked audit logging that could have detected the activity.
What the attacker needed
A leaked GitHub personal access token; Token has repo scope; Organisation uses self-hosted runners; Attacker can modify a workflow file
The fix
Organisations should adopt a zero-trust posture for self-hosted runners, restrict network access, cycle runners regularly, enable logging and monitoring, and use fine-grained access tokens where possible.
How it was found
- Obtained a GitHub personal access token with repo scope.
- Identified that the organisation used self-hosted runners.
- Updated an existing GitHub Actions workflow file to run a malicious payload.
- Triggered the workflow, which executed on a self-hosted runner.
- Received a malware check-in to the attacker's command and control 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.
A GitHub personal access token is like a password that lets a program access GitHub. If someone finds it, they can use it to change code and run commands on the servers that build the code, which can give them access to the company's internal network.