From Git Rebase to Remote Code Execution: An Unpatched Argument I
GitHub Desktop passes branch names to git without a '--' separator, so a branch named like a git option is interpreted as an argument. An attacker can create a repository with a branch named '--exec=<command>' and set it as default; when a victim clones it and performs a rebase, the command runs on the victim's machine.
Published on medium.com
Hi, my name is Tommaso Bona (ParzivalHackon Github). I’m an independent OSS and AI Security Researcher from Italy.
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 the missing '--' end-of-options separator before branch names in the git rebase invocation, allowing branch names starting with '--' to be parsed as git options.
Impact
A victim who clones an attacker-controlled repository and performs a rebase in GitHub Desktop executes attacker-supplied code with their full user privileges, silently; the exploit is fully deterministic and works on any machine, with only the payload string differing between Windows and macOS.
What the attacker needed
Victim clones attacker repo via GitHub Desktop; victim performs a rebase in GitHub Desktop; attacker can create and share a repository
The fix
The fix would be to insert the '--' separator before the branch names in the git rebase invocation; the text says it is currently unpatched.
How it was found
- Create a repository with diverged history and a branch named '--exec=calc'.
- Push the repository and set the malicious branch as the default branch.
- A victim clones the repository through GitHub Desktop's Clone Repository dialog, which checks out the default branch.
- The victim clicks 'Rebase' in GitHub Desktop.
- GitHub Desktop runs git rebase with the branch name, git interprets it as --exec, and the command executes.
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 Desktop is a program that helps you use git, a tool for tracking code changes. When you ask it to rebase (reapply your commits on top of another branch), it runs a git command. The bug is that it doesn't put a '--' before branch names, so a branch name that starts with '--' is treated as an instruction to git rather than a branch name. An attacker can name a branch '--exec=calc' so that git runs the calculator program when you rebase.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.