Skip to content
RCE Write-up Advanced

GitHub RCE Writeup

The SSH front-end accepted a username containing newlines, which let the attacker inject environment variables into the forked SSH process. By combining a preload library, an askpass program and a display setting, the attacker got a shell as the git user on the GitHub backend.

Joern Schneeweisz Follow

Published on 0day.click

GitHub blogged a while ago about some internal tool called gerve: https://github.com/blog/530-how-we-made-github-fast

joernchen (@joernchen), on 0day.click

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 username was passed into a shell or environment setup without stripping newline characters, so injected lines became environment variables for the forked SSH process.

Impact

An attacker could run arbitrary commands as the git user on the GitHub backend, which hosted the repositories.

What the attacker needed

Ability to connect to github.com over SSH; a username containing newline characters

How it was found

  1. Set the SSH username to a value containing newlines and environment variable assignments.
  2. Use a preload library so the SSH binary believes it is running as root.
  3. Set an askpass program and a display value so SSH calls that program when it cannot prompt on a terminal.
  4. Have the askpass program run a shell, giving a shell as the git user.

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.

When you connect over SSH, the server uses your username to look things up. Here the username was not cleaned, so extra lines in it were treated as settings for the program that started next. Those settings made SSH run a program of the attacker's choosing, which gave them a command shell on the server.

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 Joern Schneeweisz

View all

4 more disclosed reports, best first.

More from GitHub

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.