what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Github Remote Command Execution

Github Remote Command Execution
Posted Feb 24, 2014
Authored by joernchen

Github suffered from a remote command execution vulnerability via variable injection.

tags | exploit, remote
SHA-256 | 9f7a407ba51e7296ee3742308b11d9a6e7b6f2bcb28af5feb69321525261aeef

Github Remote Command Execution

Change Mirror Download
GitHub RCE by Environment variable injection Bug Bounty writeup

Disclaimer: I'll keep this really short but I hope you'll get the key points.

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

Upon git+sshing to github.com gerve basically looks up your permission
on the repo you want to interact with. Then it bounces you further in
another forced SSH session to the back end where the repo actually is.

At some point I figured that it is possible to inject some environment
variables into gerve/the forked SSH process by setting my username to
something like "joerchen\n\nLD_ASSUME_KERNEL=1\n\n".

LD_ASSUME_KERNEL=1 will prevent the actual command from being run, just
like this:

---
joernchen ~ $ LD_ASSUME_KERNEL=1 uname -a
uname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
---

For the details on this, check man 8 ld.so.

So far so good, how can we use this fact to make SSH execute arbitrary
commands?

The technique I came up with used both features of ld.so and SSH itself:

LD_PRELOAD=/path/to/libfakeroot.so
SSH_ASKPASS=/usr/bin/ex
DISPLAY=:1

How and why did this work?

1.) libfakeroot makes SSH think it's root (we can inject this via
LD_PRELOAD because the ssh binary is not setuid)
2.) ssh tries to read /root/.ssh/known_hosts
3.) ssh fails reading 'cause it's actually running as the git user
4.) ssh connects to $backend and wants to ask the user if
$backend_hostkey is OK.
5.) ssh has no terminal and DISPLAY is set
6.) ssh invokes the command specified in SSH_ASKPASS

From being dropped in /usr/bin/ex we could just say:
!/bin/sh
and be happy with having a shell as git@github.com

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    16 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close