Skip to content
RCE Write-up Intermediate

CVE-2023-49291 and More - A Potential Actions Nightmare

The tj-actions/branch-names GitHub Action used unsanitised branch names in a run step, allowing arbitrary code execution when triggered by pull_request_target or issues events. An attacker could exploit this to backdoor the action and steal secrets from repositories using it.

Adnan Khan Follow

Published on adnanthekhan.com

I’ve been doing a lot of scanning and reporting of GitHub Actions injection and pwn request vulnerabilities throughout GitHub. Most of my scanning and testing focused on workflows - that is yaml files in the .github/workfows directory - and my regexes didn’t look at files in other directories, such action.yml, which…

Adnan Khan, on adnanthekhan.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

The action used the branch name in a shell command without sanitising it, allowing shell injection.

Impact

An attacker could execute arbitrary code in the context of the workflow, potentially stealing secrets and the GITHUB_TOKEN, and then use that access to backdoor the action and pivot to other repositories.

What the attacker needed

Victim uses the action by tag; workflow triggered by pull_request_target or issues

The fix

The vulnerability was fixed by the maintainer, as indicated by the security advisory and the fix date.

How it was found

  1. Create a branch with a name containing shell injection characters.
  2. Trigger a workflow that uses the tj-actions/branch-names action on events like pull_request_target or issues.
  3. The action runs the injected commands, allowing arbitrary code execution.

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.

A GitHub Action is a reusable piece of code that runs in your repository's workflows. This action took the name of a branch and put it directly into a shell command without cleaning it first. That meant someone could create a branch with a malicious name that would run their own commands on the server when the action ran.

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 Adnan Khan

View all

4 more disclosed reports, best first.

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.