GHSL-2020-371: Arbitrary code execution in tophat workflows
The GitHub Actions workflows in several tophat repositories used the pull_request_target event and then checked out and ran code from the pull request's fork. An attacker could open a pull request from a fork to execute arbitrary code with access to the base repository's write token and secrets, allowing unauthorised modification of the base repository or exfiltration of secrets.
The GitHub workflows pull-request.yml in multiple branches of tophat/networkjs, tophat/commit-utils, tophat/commit-watch, tophat/sanity-runner and commit-watch.yml in tophat/commit-watch are vulnerable to unauthorized modification of the base repository or secrets exfiltration from a Pull Request.
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 the privileged pull_request_target event but then explicitly checked out and executed untrusted code from the pull request's fork.
Impact
The vulnerability allows for unauthorized modification of the base repository and secrets exfiltration.
What the attacker needed
Ability to open a pull request from a fork
The fix
The issue was partially fixed and then resolved after the vendor was informed about the remaining unfixed parts.
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.
GitHub Actions are automated tasks that run when something happens in a repository, such as a pull request. The pull_request_target event gives the workflow powerful permissions and access to secrets, but it runs in the context of the base repository. If the workflow then checks out and runs code from the pull request's fork, an attacker can run their own code with those powerful permissions.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.