Skip to content
Write-up Intermediate

Github Actions Exploitation: Untrusted Input

Several open-source GitHub Actions workflows used privileged triggers such as pull_request_target and workflow_run while consuming attacker-controlled data, including branch names, pull request titles, markdown files and uploaded artifacts. An attacker could inject commands or overwrite scripts to run arbitrary code in the runner and steal secrets or push to the repository.

Hugo Vincent Follow

Published on synacktiv.com

Rédigé par Hugo Vincent - 02/07/2024 - dans Pentest - Téléchargement

Hugo Vincent (@hugow_vincent), on synacktiv.com

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely workflows that run in a privileged context concatenate untrusted event data or download untrusted code and artifacts without sanitising or validating them.

Impact

An attacker could execute arbitrary code in the runner, exfiltrate secrets such as cloud keys, tokens and API keys, and with write permissions push code to widely used repositories.

What the attacker needed

A GitHub account; ability to fork and open a pull request; target uses a privileged trigger

The fix

Workflows should avoid privileged triggers with untrusted input, sanitise event data, pin checkouts to trusted refs and validate artifact contents.

How it was found

  1. Fork the target repository and create a pull request with a malicious branch name, markdown file, package file or artifact.
  2. The privileged workflow is triggered by the pull request or comment.
  3. The untrusted value is concatenated into a shell or script command, or the untrusted code is checked out and installed.
  4. Arbitrary code runs in the runner and secrets or write access are abused.

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 write-up has not been written yet. The Original tab links to the source.

GitHub Actions are automated jobs that run when something happens in a repository, such as a pull request. Some of these jobs run with extra powers, like access to secret passwords or permission to change the code. If a job takes text from an outsider and pastes it into a command without cleaning it, the outsider can sneak in their own commands and run them with those extra powers.

More by Hugo Vincent

View all

4 more disclosed reports, best first.

Similar reports

Same bug class and techniques, clearest first.