$ ./sudo-hax-me-a-sandwich 1
** CVE-2021-3156 PoC by blasty <peter@haxx.in>
using target: Ubuntu 20.04.1 (Focal Fossa) - sudo 1.8.31, libc-2.31 ['/usr/bin/sudoedit'] (56, 54, 63, 212)
** pray for your rootshell.. **
# id
uid=0(root) gid=0(root) groups=0(root)
CVE-2019-14287
Affected Versions: < 1.8.28
Pre-requisites
It had to allow a user in the /etc/sudoers file to execute a specific command (and this command is the one that will be run as root)
Sample Scenario
Check sudo privileges
Use the -1 id when executing sudo
Polkit
PolicyKit (polkit) is an authorization service on Linux-based operating systems that allows user software and system components to communicate with each other if the user software is authorized to do so. To check whether the user software is authorized for this instruction, polkit is asked.
Polkit works with two groups of files.
actions/policies (/usr/share/polkit-1/actions)
rules (/usr/share/polkit-1/rules.d)
The most interesting functionality is pkexec because it acts similary to sudo
CVE-2021-4034
Download and compile the exploit
Run the exploit
Dirty Pipe
CVE-2022-0847
Affected Versions: 5.8 - 5.17
Download and compile the exploit
We can use 2 exploits
The first exploit version (exploit-1) modifies the /etc/passwd and gives us a prompt with root privileges
Verify kernel version
Run exploit 1
The 2nd exploit version (exploit-2), we can execute SUID binaries with root privileges.
Find binaries with SUID set
Run exploit 2 with the binary as the parameter
Net Filter
Netfilter is a Linux kernel module that provides, among other things, packet filtering, network address translation, and other tools relevant to firewalls
This kernel module has three main functions:
Packet defragmentation
Connection tracking
Network address translation (NAT)
When the module is activated, all IP packets are checked by the Netfilter before they are forwarded to the target application of the own or remote system. In 2021 (CVE-2021-22555), 2022 (CVE-2022-1015), and also in 2023 (CVE-2023-32233), several vulnerabilities were found that could lead to privilege escalation.