Google & Apache Found Vulnerable to GitHub Environment Injection
A GitHub Actions workflow in Google Firebase repositories downloaded an untrusted artifact and wrote its content into the GITHUB_ENV file, allowing an attacker to set arbitrary environment variables. This could lead to code execution in a privileged context and a software supply chain attack.
Published on legitsecurity.com
In this blog post, we'll discuss a new type of GitHub Actions workflow vulnerability we called "GitHub Environment Injection". We've found a couple of top-tier open-source organizations vulnerable to this attack: Google Firebase and Apache.
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 sanitisation, allowing newline injection to set arbitrary environment variables.
Impact
An attacker could execute code in the privileged workflow, potentially leading to a software supply chain attack that modifies build artifacts, releases, tags, or source code.
What the attacker needed
Public repository with vulnerable workflow; ability to fork and create pull request; workflow triggered by pull request
The fix
Google and Apache fixed their workflows, and the report recommends never writing untrusted input to the environment file, restricting token permissions, using action outputs instead of environment variables, and requiring human approval for forked repositories.
How it was found
- Fork one of the vulnerable Firebase repositories
- Create a workflow that uploads a malicious artifact
- Create a pull request to the original repository
- The NODE_OPTIONS payload dumps the process environment variables to the console with all the sensitive secrets and keys
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 runs automated tasks (workflows) when code changes. A workflow can download files (artifacts) created by another workflow. If it then writes the content of those files into a special environment file without checking, an attacker can sneak in extra settings. Those settings can make the workflow run the attacker's code, potentially stealing secrets or altering the software.