Vulnerable GitHub Actions Workflows Part 1: Privilege Escalation Inside Your CI/CD Pipeline
The report describes how GitHub Actions workflows triggered by the workflow_run event can be exploited for privilege escalation. An attacker can run untrusted code or inject scripts in a privileged context, potentially modifying repository resources and stealing secrets.
Published on legitsecurity.com
At Legit Security, we’re focused on preventing software supply chain attacks and securing the SDLC for our customers and the broader cybersecurity community. We recently discovered GitHub-Actions pipeline privilege escalation vulnerabilities that can open the door to software supply chain attacks and we’re publishing…
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 workflow_run event runs in a privileged context but processes untrusted input from forked pull requests without proper sanitisation, such as checking out attacker-controlled code or interpolating untrusted data into scripts.
Impact
An attacker could modify repository build artifacts, releases, and tags, potentially initiating a supply chain attack, and could steal repository secrets to expand the attack to other SDLC assets.
What the attacker needed
Ability to fork the repository; ability to open a pull request; workflow_run trigger configured
The fix
The issue should be fixed by never checking out user code in workflow_run context, using environment variables instead of string interpolation, restricting GitHub token permissions, and requiring human approval for forked workflows.
How it was found
- Fork the target repository.
- Modify a file (e.g., package.json) to include malicious code.
- Open a pull request to the base repository.
- The workflow_run workflow triggers and runs the malicious code with elevated permissions.
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 tool that automatically runs tasks like building and testing code when changes are made. A workflow_run event starts a privileged workflow after another workflow finishes, and if it uses untrusted input from a pull request, an attacker can run their own code with high permissions. This could let them change the software or steal secret keys.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.