Skip to content
RCE Advisory Intermediate

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.

jarlob Follow

Originally disclosed on GitHub Security Lab

The ‘acceptance.yml’ GitHub workflow is vulnerable to arbitrary code execution and shell command injection.

jarlob, on GitHub Security Lab

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

  1. Create a pull request from a fork with a branch name containing shell metacharacters.
  2. The workflow runs and uses the branch name in a git merge-base command, executing the injected commands.
  3. 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.

More by jarlob

View all

192 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.