GHSL-2020-241: Arbitrary code execution and shell command injection in getsentry/sentry workflow
The GitHub Actions workflow 'acceptance.yml' used 'pull_request_target' and checked out code from a fork, allowing untrusted code to run with access to secrets and write permissions. Additionally, the branch name from a fork was interpolated into a shell command, enabling command injection. An attacker could execute arbitrary code, exfiltrate secrets, and modify the base repository.
The ‘acceptance.yml’ GitHub workflow is vulnerable to arbitrary code execution and shell command injection.
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 'pull_request_target' (which gives access to secrets and write tokens) but then checked out and ran code from the fork, and also interpolated the untrusted branch name directly into a shell command.
Impact
An attacker could execute arbitrary code, exfiltrate secrets and the temporary GitHub token, and potentially modify the base repository, although the token expires after the workflow finishes.
What the attacker needed
Ability to create a pull request from a fork
The fix
The issues were resolved by the maintainer.
How it was found
- Create a pull request from a fork with a branch name containing shell metacharacters.
- The workflow runs and uses the branch name in a git merge-base command, executing the injected commands.
- The attacker can exfiltrate secrets and the temporary GitHub token to a server they control.
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 runs automatically when someone opens a pull request. The workflow was set up in a way that let code from an outside contributor run with special permissions, so an attacker could steal secrets or change the main repository. Also, the name of the branch was inserted directly into a command, letting an attacker run their own commands.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.