Linux
View all Worklets
LinuxLinux

CVE-2021-4034 Temporary Workaround for Pkexec

Removes setuid permissions from pkexec to temporarily mitigate the CVE-2021-4034 PwnKit vulnerability

Worklet Details

What the PwnKit mitigation Worklet does

This Automox Worklet™ mitigates CVE-2021-4034, a critical local privilege escalation vulnerability in Polkit's pkexec utility. The vulnerability, discovered in January 2022, allows any unprivileged local user to gain root access on vulnerable Linux systems.

The Worklet removes the setuid bit from /usr/bin/pkexec by changing its permissions from 4755 to 0755. This prevents the privilege escalation exploit from working while you prepare to deploy official patches.

Why apply the PwnKit temporary workaround

CVE-2021-4034 affects nearly every major Linux distribution because pkexec has been present since 2009, creating a decade-long window of exposure. The vulnerability is trivially exploitable with publicly available exploit code that any unprivileged local user can execute to gain root access. When attackers compromise a low-privilege account through phishing or credential theft, they use PwnKit to escalate to root, install persistent backdoors, disable security controls, and maintain complete control over the system.

Applying this workaround gives you time to test and deploy official vendor patches without leaving endpoints exposed. This approach follows defense-in-depth principles by reducing your attack surface while maintaining system availability.

Note that this workaround disables pkexec's normal functionality. Applications that rely on pkexec for privilege elevation will stop working until you restore the setuid bit (chmod 4755) or apply the official patch.

How PwnKit mitigation works

  1. Evaluation phase: The Worklet always triggers remediation (exit 1) because this is a run-once mitigation designed for immediate deployment.

  2. Remediation phase: Executes chmod 0755 on /usr/bin/pkexec to remove the setuid bit. The script reports success or failure of the permission change.

PwnKit mitigation requirements

  • Linux endpoints with pkexec installed at /usr/bin/pkexec

  • Root or sudo privileges for the Automox agent

  • If pkexec is in a different location, modify the location variable in the remediation script

  • Compatible with workstations and servers running any Linux distribution

Expected security state after mitigation

After remediation, the pkexec binary will have permissions of 0755 instead of 4755. The endpoint is protected against CVE-2021-4034 exploitation.

Verification: Run ls -la /usr/bin/pkexec and confirm the setuid bit (s) is no longer present in the permission string (should show -rwxr-xr-x instead of -rwsr-xr-x). Test that pkexec no longer grants root privileges by running pkexec whoami as a non-root user, which should fail. After applying official vendor patches, restore normal pkexec functionality by running chmod 4755 /usr/bin/pkexec or reinstalling the polkit package.

How to validate cve-2021-4034 temporary workaround for pkexec changes

  1. Run this Worklet on a pilot Linux endpoint and review evaluation output for cve-2021-4034 temporary workaround for pkexec.

  2. Confirm Automox activity logs show successful completion and exit code 0.

  3. Verify endpoint state using checks aligned to evaluation script logic, such as exit.

  4. Validate remediation effects from script operations such as else, then rerun evaluation for compliance.

For technical validation, compare endpoint state to the Worklet evaluation logic and remediation flow for cve-2021-4034 temporary workaround for pkexec. This supports repeatable security workflows, faster change control review, and auditable compliance evidence.

Useful script references for this Worklet include evaluation operations such as exit and remediation operations such as else. Use these indicators to verify that endpoint changes match intended policy outcomes.

View in app
evalutation image
remediation image

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

do more with worklets