GHSL-2024-252: Environment variable injection in Cloudflare workers-sdk
The write-prerelease-comment.yml workflow in Cloudflare workers-sdk is vulnerable to environment variable injection because it downloads an artifact from a triggering workflow and writes its contents into GITHUB_ENV without validation. An attacker could craft a malicious artifact to inject a BASH_ENV variable and execute arbitrary code in the context of a full-write GITHUB_TOKEN, potentially leaking secrets and gaining write access to the repository.
Originally disclosed on GitHub Security Lab
Cloudflare workers-sdk write-prerelease-comment.yml workflow is vulnerable to environment variable injection which may allow an attacker to leak secrets and gain write access to the repository.
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 report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary code with a GITHUB_TOKEN that has write permissions to many repository resources, potentially leaking secrets and gaining write access to the repository.
What the attacker needed
GitHub account; Ability to fork and create pull requests
The fix
The workflow should validate or sanitise artifact contents before writing them to GITHUB_ENV, or avoid using GITHUB_ENV for untrusted data.
How it was found
- Fork the cloudflare/workers-sdk repository.
- Create a new branch and modify the create-pullrequest-prerelease.yml workflow to upload a malicious runtime-versions.md artifact.
- Commit the change and create a pull request to cloudflare/workers-sdk.
- Wait for the Create Pull Request Prerelease workflow to finish.
- Observe the Write prerelease comment workflow run and check the output of the step that puts the pre-release report on the environment.
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 report has not been written yet. The Original tab links to the source.
This report is about a GitHub Actions workflow that automatically runs when another workflow finishes. The workflow downloads a file (artifact) created by the first workflow and puts its contents into environment variables without checking them. An attacker can make the first workflow produce a file that adds a special variable, causing the second workflow to run the attacker's commands with powerful permissions.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.