Skip to content
RCE Disclosed report Intermediate

Code exec on Github runner via Pull request name

A GitHub Actions workflow used an untrusted pull request title inside a shell command, allowing an attacker to inject arbitrary commands. An attacker could run commands on the runner and read the repository's access token, potentially compromising the organisation.

another_dude Follow

Originally disclosed on HackerOne

Medium 6.0 View original
  • Triaged in 6 days
  • Fixed in 8 days
  • Paid in 8 days
  • Disclosed after 9 days

Hi, I have discovered command injection vulnerability in one of your Github repos. Apologies for any inconvenience if this type of bug is not of interest to you. Allow me to explain the problem. GitHub Actions, a powerful tool for automating workflows, can inadvertently introduce security vulnerabilities if not configured securely. Insecure GitHub Actions configuration can lead to various risks, including unauthorized access, data breaches, and code injection attacks. Currently https://github.com/hyperledger/cacti/tree/HEAD/.github/workflows/test_weaver-pre-release.yaml#L28 allows attacker to inject arbitrary command and run it on the Github runner. Note the usage of double quotes and untrusted pull_request.name.

Steps to reproduce

  • Create a new branch within your fork
  • Create a pull request with the U";cat $GITHUB_WORKSPACE/.git/config | xxd -p | base64; echo "D title
  • config file contains the access token in base64 form
  • Wait until check_release workflow will be triggered
  • Check job logs for encoded $GITHUB_TOKEN (by default Github will replace it with *** if you will try just echo it, that is why I used xxd + base64)
  • I refrained from creating a PR on your repository to prevent the disclosure of sensitive information to the public and to avoid publicly exposing the vulnerability.

Example run could be found in my fork, attached as screenshot.

Impact

Such scenario leaves possibility to access $GITHUB_TOKEN environment variable, potentially compromising the whole GitHub organization. Good explanation of the problem could be found at github docs: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions

There are few limits to the attack:

  • $GITHUB_TOKEN is a short lived token and for the real life attack, whole attack should be scripted until job is still running

Attachments

Screenshot_2024-04-19_at_18.27.28.png
Screenshot_2024-04-19_at_18.27.28.png From the original on HackerOne

The original report as published on HackerOne, by another_dude. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 interpolated the untrusted pull request title directly into a shell command inside double quotes, allowing command injection.

Impact

An attacker could access the $GITHUB_TOKEN environment variable, potentially compromising the whole GitHub organisation, though the token is short-lived and the attack must be scripted to complete before the job ends.

What the attacker needed

Ability to create a fork and pull request; workflow triggered by pull request

How it was found

  1. Create a new branch in a fork of the repository.
  2. Create a pull request whose title contains shell metacharacters and commands.
  3. Wait for the check_release workflow to be triggered.
  4. Check the job logs for the encoded token.

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. This workflow put the pull request's title directly into a command without cleaning it, so someone could put special characters in the title to make the runner execute extra commands. That let them read a secret token that gives access to the repository.

What is RCE?

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

More from Linux Foundation Decentralized Trust

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.