How We Found Another GitHub Action Environment Injection Vulnerability in a Google Project
A GitHub Actions workflow in a Google repository downloaded an artifact from a fork and wrote its content into the GITHUB_ENV file, allowing an attacker to inject environment variables. An attacker could gain code execution in the privileged workflow and use the exposed GitHub token to approve pull requests or post malicious comments.
Published on legitsecurity.com
This blog shows another case of a GitHub Actions environment injection vulnerability in a Google repository. We previously found vulnerabilities in Firebase repositories and a detailed explanation can be found here including the underlying mechanism that allows this type of vulnerability.
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
The workflow wrote untrusted artifact content directly into the GITHUB_ENV file without validation, allowing environment variable injection.
Impact
An attacker could gain code execution in the privileged workflow and use the exposed GitHub token to approve malicious pull requests or comment with malicious links, depending on the token's permissions.
What the attacker needed
Ability to fork the repository; Ability to open a pull request
The fix
The vulnerable workflows were removed by Google.
How it was found
- Fork the repository
- Create a workflow file that uploads a crafted artifact
- Open a pull request to the base repository
- The completion of the malicious workflow triggers the vulnerable workflow and exploitation
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 Actions workflow is an automated script that runs when something happens, like a pull request. This workflow trusted a file uploaded by anyone who forked the repository and used its content to set environment variables, which can be abused to run commands. The attacker could then act as the workflow's bot account, for example approving pull requests.