
CVE-2026-41651 - PackageKit 1.0.2-1.3.4 TOCTOU local privilege escalation, independent C implementation (PoC + exploit by thiscitze)
Independent C implementation of the PackageKit "Pack2TheRoot" TOCTOU
privilege escalation. No python3-gi, no shell wrapper: one binary drives
the system bus, builds the packages and waits for the SUID shell.
PackageKit 1.0.2 .. 1.3.4 vulnerable
PackageKit >= 1.3.5 fixed
Lab use only: run it as an unprivileged user on a VM you own.
PackageKit keeps the caller-supplied flags and paths in
transaction->cached_transaction_flags / cached_full_paths and only
re-validates them at dispatch time (pk-transaction.c). Three cooperating
bugs make the window usable:
InstallFiles() stores both values unconditionally, even while the
transaction is already RUNNING.pk_transaction_set_state() silently drops backward transitions
(RUNNING → WAITING_FOR_AUTH) but the overwrite already happened.Sequence:
CreateTransaction()
InstallFiles(SIMULATE, dummy.deb) -> no polkit prompt, state READY
InstallFiles(NONE, payload.deb) -> flags/paths overwritten, state stays
RUNNING
idle callback -> install payload as root -> postinst runs install -m 4755
SIMULATE is a PkBitfield: on 1.3.x the enum value is 2, so the wire value
is 1 << 2 = 4. NONE is 0.
Needs glib-2.0, gio-2.0 and their headers:
# Debian/Ubuntu
sudo apt install build-essential pkg-config libglib2.0-dev
# RHEL/Fedora
sudo dnf install gcc pkgconf-pkg-config glib2-devel
make
CI is not wired up; the tree is compile-checked with
zig cc -target x86_64-linux-gnu against the Debian 12 glib headers, and
builds on any distro with the packages above.
./pk2root # first safe dir, 90s wait
./pk2root --timeout 180
./pk2root --suid-dir /dev/shm
./pk2root --keep # keep the generated .deb/.rpm for inspection
The tool prints every step and exits non-zero when no SUID file appears
(patched host or lost race). On success it execs the SUID bash with -p.
Requirements on the target:
dpkg-deb or rpmbuild available to that usernosuid/noexec (probed automatically)<dir>/.pk2root_suid; remove it after testing.pk-transaction.c, commit 76cfb675)0xBlackash and Vozec — useful for cross-checking the
D-Bus sequence; this implementation is written independently and shares no
code with them.MIT — see LICENSE.