Polkit Local Privilege Escalation – PwnKit and CVE-2021-3560
Polkit (PolicyKit) is an authorization framework present by default on Ubuntu, Debian, RHEL, Fedora, and virtually every Linux desktop and most servers. Two major CVEs — PwnKit (CVE-2021-4034) and a D-Bus race condition (CVE-2021-3560) — allow any local user to escalate to root with no sudo permissions required. Both are pre-authentication from a local user perspective.
Prerequisites Check
Confirm Polkit is installed and pkexec is SUID:
Check exact version — this determines which CVE applies:
Version-to-vulnerability mapping:
Distro | Vulnerable versions | CVE |
|---|---|---|
Ubuntu 20.04 | polkit < 0.105-26ubuntu1.2 | CVE-2021-4034 |
Ubuntu 18.04 | polkit < 0.105-20ubuntu0.18.04.6 | CVE-2021-4034 |
Debian 10 | polkit < 0.105-25+deb10u1 | CVE-2021-4034 |
Debian 11 | polkit < 0.105-33 | CVE-2021-4034 |
RHEL 7/8 | polkit < 0.115-13.el8_5.1 | CVE-2021-4034 |
Ubuntu 20.04 | polkit < 0.105-26ubuntu1.1 | CVE-2021-3560 |
CVE-2021-4034 — PwnKit
Affected: All pkexec versions before January 2022 patches — essentially every Linux system running polkit for the past 12 years.
A memory corruption vulnerability in pkexec. It mishandles the argc=0 argument count edge case, causing it to read from envp as if it were argv, allowing an attacker to inject environment variables that control which shared library gets loaded. Results in root code execution. Extremely reliable — does not require specific kernel version, filesystem, or configuration.
Quick Verification
A cleaner check:
Exploit — Blasty PoC (Simplest)
Root shell drops immediately. No configuration required.
Exploit — Single-File C Version (No git required)
When the target has no internet access and you need a minimal transfer:
Exploit — Python Version (No gcc required)
When gcc is absent on the target:
CVE-2021-3560 — D-Bus Race Condition
Affected: Specific Ubuntu versions — Ubuntu 20.04 with polkit < 0.105-26ubuntu1.1, and RHEL 8 with polkit < 0.115-13.el8_5.1.
A race condition in how Polkit handles D-Bus connections that disconnect before the authorization check completes. By killing a dbus-send call at exactly the right moment, Polkit falls back to allowing the action as root. This predates PwnKit and is less reliable (race-dependent) but works on different affected versions.
Check Version
Exploit — Automated Race
The script loops sending a dbus-send for account creation while simultaneously killing it at varying timing intervals. Typically succeeds within 10-30 seconds.
Manual Race (Understanding the Technique)
The exploit sends a D-Bus call to create a privileged user account, then kills it partway through:
If the timing hits the race window, a user is created. Then set its password:
Then authenticate:
Permissive Policy Files
Custom or third-party Polkit policies sometimes grant unauthenticated access to dangerous actions:
If allow_any is yes on a dangerous action (service management, package install, user creation), trigger it directly via pkexec or the associated D-Bus method without authentication.
Check local override rules which can be more permissive than system defaults:
systemd-run Bypass (Misconfigured Environments)
On some systems, systemd-run triggers Polkit authorization that is misconfigured to allow unprivileged users:
If this drops a root shell, Polkit policy for org.freedesktop.systemd1.manage-units is too permissive.
References
-
Qualys PwnKit Advisorywww.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt (opens in new tab)
Original vulnerability disclosure
-
Policy and design documentation
-
CVE-2021-4034 PoCgithub.com/berdav/CVE-2021-4034 (opens in new tab)
berdav Clean multi-file PwnKit exploit with Makefile.
-
CVE-2021-3560 PoCgithub.com/hakivvi/CVE-2021-3560 (opens in new tab)
hakivvi Automated race condition exploit for the D-Bus timing attack.
Was this helpful?
Your feedback helps improve this page.