1. Vulnerability Background
What is this vulnerability?
- CVE-2026-41651 is a local privilege escalation in PackageKit, a D-Bus based package management abstraction used by many Linux distributions.
- The issue is a TOCTOU race on transaction metadata: an unprivileged user can corrupt transaction authorization flags after PackageKit has authorized a package install, but before the transaction is executed.
Why is it critical/important?
- PackageKit is a privileged system service that mediates package installation and removal.
- Exploitation allows arbitrary RPM installation as root, including execution of RPM scriptlets, from an unprivileged account.
- This bypasses local authentication controls and leads directly to root compromise on affected hosts.
What systems/versions are affected?
- PackageKit versions from 1.0.2 through 1.3.4 are affected.
- The fix is included in PackageKit 1.3.5.
- RPM-based distributions using PackageKit as the frontend and package backend are the primary impacted platforms.
2. Technical Details
Root cause analysis
- The root cause lies in
src/pk-transaction.c. InstallFiles()unconditionally writes user-supplied flags intotransaction->cached_transaction_flagseven if the transaction has already transitioned into an authorized or running state.pk_transaction_set_state()rejects backward transitions silently. If a second call attempts to move the transaction fromRUNNINGback toWAITING_FOR_AUTH, the state change is discarded, but the corrupted flags written byInstallFiles()remain.- The scheduler then reads
cached_transaction_flagsat dispatch time (lines 2273–2277), not at authorization time, meaning the backend can receive attacker-controlled flags later in the transaction lifecycle.
Attack vector and exploitation conditions
- The attacker needs local access to the PackageKit D-Bus API.
- The exploit requires a race between the authorization phase and execution phase of a transaction.
- The attacker triggers a legitimate transaction and then issues a second call that overwrites cached transaction flags before the system dispatches the backend.
- Because the state machine suppresses the invalid backward transition, the transaction continues running with corrupted flags rather than failing.
Security implications
- The attacker can force PackageKit to install arbitrary RPM packages as root.
- RPM scriptlets execute with root privileges, making it trivial to escalate to a full root shell or persist malicious code.
- The attack bypasses normal PackageKit authentication and policy controls.
- This is a direct local privilege escalation vulnerability, affecting any host where PackageKit runs and local user accounts exist.
3. Patch Analysis
What code changes were made?
- The patch is applied in PackageKit 1.3.5 and is referenced by commit
76cfb675fb31acc3ad5595d4380bfff56d2a8697. - The relevant fixes are in the transaction handling logic, specifically the code paths around
InstallFiles(),pk_transaction_set_state(), and scheduler dispatch.
How do these changes fix the vulnerability?
InstallFiles()is hardened so it no longer overwritestransaction->cached_transaction_flagsonce a transaction is already authorized or running.- The transaction state machine is tightened so illegal backward transitions cannot be discarded silently; invalid transitions now fail cleanly instead of allowing a corrupted transaction to continue.
- The scheduler is adjusted to use the authorized transaction flags as of the authorization moment, rather than reading potentially tampered flags at dispatch time.
Security improvements introduced
- The patch removes the race condition in transaction flag handling.
- It enforces stronger consistency between transaction state and authorization metadata.
- It reduces the attack surface of PackageKit’s asynchronous transaction model by preventing late-stage flag tampering.
4. Proof of Concept (PoC) Guide
Prerequisites for exploitation
- Local unprivileged account on a system running PackageKit 1.0.2–1.3.4.
- A distribution using PackageKit with the RPM backend.
- Access to PackageKit D-Bus methods or tools that can drive PackageKit transactions.
Step-by-step exploitation approach
- Create a PackageKit transaction that requires authorization for package installation.
- Allow the transaction to reach the state where authorization has been granted but execution has not yet completed.
- Issue a second
InstallFiles()-style call (or equivalent API request) that supplies attacker-controlled transaction flags. - Because
InstallFiles()unconditionally overwrites cached flags, the transaction now carries attacker-controlled flags. - Wait for the scheduler to dispatch the transaction; it reads
cached_transaction_flagsat execution time and uses the corrupted flags. - The backend proceeds to install the attacker-chosen RPM as root.
Expected behavior vs exploited behavior
- Expected behavior: PackageKit should preserve the flags authorized during the initial transaction setup and reject any unauthorized modification after that point.
- Exploited behavior: PackageKit accepts the second call, corrupts the cached transaction flags, silently ignores the invalid state regression, and executes the transaction with attacker-supplied privileges.
How to verify the vulnerability exists
- Attempt to perform an unauthorized install via PackageKit on a vulnerable version; if successful, the vulnerability exists.
- A practical test is to use a benign RPM with a root-owned scriptlet that writes to
/rootor a system directory. If the unprivileged user can cause the package to install and the scriptlet executes, the vulnerability is confirmed. - Verify with
rpm -qp --scripts <package>and check system logs for PackageKit transaction records. - On patched systems, the second flag overwrite should be rejected or the transaction should fail cleanly.
5. Recommendations
Mitigation strategies
- Upgrade PackageKit to version 1.3.5 or later immediately.
- If patching is not immediately possible, restrict local access to PackageKit’s D-Bus interface and disable PackageKit if it is not needed.
- Use SELinux/AppArmor policies to limit which users and processes can interact with package management services.
Detection methods
- Audit PackageKit D-Bus traffic and transaction method calls for unusual repeated state transitions.
- Monitor package installation logs for installs initiated by unexpected local accounts.
- Use system auditing to detect unauthorized access to
/usr/libexec/packagekitdor similar PackageKit daemon activity.
Best practices to prevent similar issues
- Avoid mutable cached authorization state in asynchronous workflows.
- Do not allow state machine transitions to fail silently; invalid transitions should return explicit errors and abort the operation.
- Read authorization flags at the time of authorization and bind them immutably to the transaction, rather than re-reading them at execution time.
- Review transaction-oriented code for TOCTOU vulnerabilities, especially when unprivileged input can influence privileged service state.