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, reliably and on any CPU architecture. Qualys exploited it on Ubuntu, Debian, Fedora and CentOS, and pkexec was installed by default on all major distributions. The bug had been there since pkexec was first written in May 2009.
What broke
pkexec runs a program as another user, like sudo, according to polkit rules. To do 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 argv has at least one entry, the program name. pkexec assumed so too. If it was 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, in plain terms
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 could 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.
Qualys summarised it: pkexec is installed by default on all major distributions, the bug existed since its creation, any unprivileged user could use it, and it "is exploitable instantly, reliably, in an architecture-independent way", even when the polkit daemon was not running.
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 it to the KEV catalog on 2022-06-27 and marks it as used by ransomware groups.
Why a local bug matters 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. With PwnKit or a similar local bug, that becomes root in one step. This is how a bug in a web application turns into a full server compromise.
How to check a server today
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
On Debian 12, polkit is version 122 and 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 bit is not needed.
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 restore the bit; check again after updates, or remove the package if nothing depends on it. dpkg -r pkexec on Debian 12 shows what would be removed 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 as a patch. Debian shipped it in DSA-5059-1 and DLA-2899-1; other distributions published their own updates. OpenBSD was never exploitable: its kernel refuses to start a program with an empty argument list.
What to take from it
-
Every setuid program is attack surface. List them and remove the bit or the package where you can:
sudo find / -xdev -perm -4000 -type f 2>/dev/null -
Local bugs need patches too. Rank them below remote bugs on internet-facing services, but do not leave them for months: they turn any web application bug into root.
-
Old code is not proven code. pkexec was reviewed and used for twelve years before this was found.
-
Look for signs of use. Qualys notes that 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 agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.