GitHub Actions Exploitation: Repo Jacking And Environment Manipulation
The article describes three misconfigurations in GitHub Actions workflows: repo jacking (referencing a non-existent action owner), unsafe writing to GITHUB_ENV from untrusted artifacts, and workflow command injection via set-output. An attacker could exploit these to execute arbitrary code in the workflow runner and steal secrets.
Published on synacktiv.com
Written by Hugo Vincent - 10/07/2024 - in Pentest - Download
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 workflows trust untrusted input (artifact contents or action references) without proper validation, allowing attackers to control environment variables or execute arbitrary code.
Impact
An attacker could execute arbitrary code in the workflow runner and steal secrets such as DockerHub credentials, but may not be able to push code to the repository if the GITHUB_TOKEN lacks write access.
What the attacker needed
A GitHub repository with a vulnerable workflow; Ability to fork the repository and trigger workflows; The workflow must download and process artifacts from forks
The fix
The issues were fixed by validating input (e.g., ensuring PR numbers are numeric) and by GitHub blocking dangerous environment variables like NODE_OPTIONS, though bypasses like LD_PRELOAD remained possible.
How it was found
- Fork the repository and create a workflow that uploads a malicious artifact.
- Trigger the vulnerable workflow (e.g., via workflow_run) so it downloads the artifact.
- The vulnerable workflow unzips the artifact and writes its content to GITHUB_ENV.
- The injected environment variable (e.g., LD_PRELOAD) causes arbitrary code execution in subsequent steps.
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 are automated tasks that run when code changes. If a workflow uses an action from a user or organisation that no longer exists, an attacker can register that name and provide their own malicious action. Also, if a workflow takes data from an untrusted source (like a pull request) and uses it to set environment variables, an attacker can inject commands that run on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.