PwnKit (CVE-2021-4034): root from any account through pkexec
On 2022-01-25 Qualys published PwnKit, a bug in pkexec, the setuid-root helper of polkit. Any local user could become root. In the words of Qualys it "is exploitable instantly, reliably, in an architecture-independent way", also when the polkit daemon is not running. Qualys exploited it on Ubuntu, Debian, Fedora and CentOS; pkexec was installed by default on all major distributions, and the bug had been in it since the first version of May 2009.
What broke
pkexec runs a program as another user, like sudo, according to polkit rules. For that it is installed setuid root: whoever starts it, it runs as root and decides what to allow.
Every program receives its arguments (argv) and its environment (envp) as two lists that lie next to each other in memory. Programs usually assume that argv has at least one entry, the program name, and pkexec did too. Started with an empty argument list, it read the "first argument" from the slot after the end of argv, which is the first environment variable, and later wrote a value back there.
How the attack worked
The loader removes dangerous variables such as GCONV_PATH from the environment of a setuid program, because they tell a program where to load code from. Through the out-of-bounds write, the attacker put such a variable back into the environment of pkexec after that clean-up. When pkexec then printed an error message in another character set, glibc read GCONV_PATH, loaded a conversion library from a directory the attacker controlled, and ran attacker code as root.
The CVSS v3.1 score is 7.8 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H). CISA added the CVE to the KEV catalog on 2022-06-27 and marks it as used by ransomware groups.
Local bugs on a server
A server may have only one human user, but many local accounts run code: www-data for the web server, the PHP-FPM pool, CI runners, database extensions, cron jobs of applications. An attacker who gets code execution in a web application runs as one of these accounts, and PwnKit or a similar local bug makes that root in one step. Rank local bugs below remote bugs on internet-facing services, but patch them within weeks, not months.
How to check a server
Check whether pkexec is installed, setuid, and from a fixed package:
ls -l /usr/bin/pkexec
pkexec --version
dpkg-query -W pkexec policykit-1 2>/dev/null # Debian, Ubuntu
rpm -q polkit 2>/dev/null # RHEL family
Debian 12 has polkit 122, which is not affected. A minimal Rocky Linux 9 container does not have polkit at all. Fixed packages on older Debian releases:
| Release | Fixed version |
|---|---|
| Debian 9 | 0.105-18+deb9u2 (DLA-2899-1) |
| Debian 10 | 0.105-25+deb10u1 (DSA-5059-1) |
| Debian 11 | 0.105-31+deb11u1 (DSA-5059-1) |
For Ubuntu and the RHEL family, look up CVE-2021-4034 in their trackers.
The s in -rwsr-xr-x is the setuid bit. pkexec is mainly used in desktop sessions; if nothing on the server uses it, the server does not need the bit.
Mitigation without an update
Qualys gave this mitigation for systems without a patch:
sudo chmod 0755 /usr/bin/pkexec
Without the setuid bit, pkexec runs with the rights of the caller and cannot give root to anyone. A package update may set the bit again, so check after updates, or remove the package if nothing depends on it. On Debian 12, dpkg -r pkexec shows what it would remove along with it.
How it was fixed
The fix (polkit commit a2bf5c9 of 2022-01-25, by Jan Rybar of Red Hat) makes pkexec exit when it gets an empty argument list and stops it from writing past the end of argv. The first upstream release with it was polkit 121 in June 2022; the distributions shipped it earlier as a patch (Debian in DSA-5059-1 and DLA-2899-1). OpenBSD was never exploitable: its kernel refuses to start a program with an empty argument list.
Other setuid programs
pkexec had been in use for twelve years when Qualys found the bug. Every setuid program on a server carries the same kind of risk. List them, and remove the bit or the package where you can:
sudo find / -xdev -perm -4000 -type f 2>/dev/null
Signs of use
According to Qualys, its technique leaves one of two messages in the logs: "The value for the SHELL variable was not found the /etc/shells file" or "The value for environment variable [...] contains suscipious content" (sic). Search the auth log or the journal for them. Qualys also says the bug can be used without leaving traces, so a clean log is not proof.
Sources
- Qualys Security Advisory: pwnkit (mechanism, history since May 2009, mitigation, timeline)
- CVE-2021-4034 record (description, CVSS from CISA ADP)
- Debian security tracker: CVE-2021-4034 (fixed versions)
- polkit commit a2bf5c9 (the fix:
argc < 1check, no write pastargv) and the polkit NEWS (0.120 in September 2021, 121 in June 2022) - CISA KEV catalog, version 2026.11.25 (added 2022-06-27, ransomware use)
- Package checks in
debian:bookworm-20261027-slimandrockylinux/rockylinux:9.9.20261112.0containers on 2026-11-26
Check your servers every day
The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.