Exploiting PwnKit (CVE-2021–4034)
A memory corruption vulnerability in pkexec, a SUID-root program, allows any unprivileged user to gain root privileges. The exploit uses environment variables to load a malicious shared library, resulting in a root shell.
Published on medium.com
Let’s explore and exploit a high-impact vulnerability, hiding in the plain sight for 12+ years, enabling privilege escalation to root!
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an out-of-bounds write when pkexec processes command-line arguments, allowing environment variables to be manipulated to load a malicious library.
What the attacker needed
Local access to a vulnerable Linux system; pkexec version 0.105 installed
The fix
Apply patches for this vulnerability immediately.
How it was found
- Check the system information to identify the OS and kernel version.
- Find all SUID binaries to locate pkexec.
- Check the version of pkexec to confirm it is vulnerable.
- Save the exploit code from Packet Storm into three files: Makefile, evil-so.c, and exploit.c.
- Compile the exploit using make.
- Run the exploit binary to obtain a root shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
pkexec is a program that lets users run commands as another user, like sudo. A bug in how it handles certain settings allows a normal user to trick it into running their own code with full administrator rights, giving them complete control of the computer.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.