GHSL-2024-255: Possible secret exfiltration and repository manipulation via environment variable injection in docker-mailserver
The docs-preview-deploy workflow reads a pr.env file from an artifact that can be controlled by a pull request author, allowing injection of environment variables such as LD_PRELOAD. An attacker could then execute arbitrary code, exfiltrate secrets, and gain write permissions to the repository.
Originally disclosed on GitHub Security Lab
docker-mailserver docs-preview-deploy.yml workflow is vulnerable to Environment Variable injection which may lead to secret exfiltration and repository manipulation.
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
Root cause
The workflow trusts and uses an artifact (pr.env) from a pull request without validating its contents, allowing environment variable injection.
Impact
An attacker could gain full write permissions to the repository and exfiltrate secrets NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID.
What the attacker needed
Ability to create a pull request
The fix
The workflow was fixed.
How it was found
- Clone the repository and edit the docs-preview-prepare.yml workflow to include a malicious pr.env file with LD_PRELOAD set to a malicious shared library.
- Create a pull request with this change.
- The modified workflow triggers on pull_request and runs, producing the malicious artifact.
- Upon completion, the vulnerable workflow is triggered, downloads the artifact, and reads pr.env into the environment.
- Subsequent steps execute node, which loads the malicious library and runs arbitrary code.
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.
A GitHub Actions workflow is a set of automated steps that run when something happens, like a pull request. This workflow downloaded a file from an untrusted source and used it to set environment variables, which are settings that programs read. By setting a special variable, an attacker could make the system run their own code and steal secrets.