GHSL-2024-319: Poisoned Pipeline Execution (PPE) via code injection in Trino DB
The Trino upload-test-results workflow interpolated the pull request branch name directly into a Bash script, allowing an attacker to inject commands. This could let them exfiltrate the TEST_RESULTS_AWS_SECRET_ACCESS_KEY secret and, because the workflow had write-all permissions, use the GITHUB_TOKEN to gain write access to the repository.
Originally disclosed on GitHub Security Lab
Trino’s upload-test-results.yml workflow is vulnerable to Code Injection which may allow a malicious actor to gain write access to the repository and exfiltrate secrets such as TESTRESULTSAWSSECRETACCESSKEY.
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 used GitHub Actions expression interpolation to insert the untrusted pull request branch name directly into a Bash script, without sanitising it.
Impact
This could lead to secret exfiltration of TEST_RESULTS_AWS_SECRET_ACCESS_KEY and, because the workflow runs with write-all permissions, an attacker could use the GITHUB_TOKEN to gain write access to the repository.
What the attacker needed
Ability to open a pull request; branch name controls injected value
The fix
The issue was fixed by merging a pull request.
How it was found
- Create a pull request from a branch whose name contains shell command substitution.
- Wait for the ci or docs workflow to complete, which triggers the vulnerable workflow.
- The workflow reaches the Upload test results to S3 step and executes the injected command.
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 an automated script that runs when something happens, like a pull request. Here, the workflow took the name of the pull request's branch and pasted it directly into a shell command without cleaning it. An attacker could name their branch in a way that includes extra shell commands, so when the workflow ran, those commands executed with the workflow's permissions.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.