# CVE-2021-4034: Red Hat Polkit Out-of-Bounds Read and Write

> Local attackers can exploit a memory corruption flaw in pkexec to execute arbitrary code and gain root privileges on Linux systems.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Yes, since 27 Jun 2022 (CISA KEV), used in ransomware
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 28 Jan 2022
- **Updated:** 15 Aug 2026
- **Also known as:** ALSA-2022:0267, AZL-8335, CLSA-2022-1643211736, CLSA-2022-1643211885, CLSA-2022-1643211942, CLSA-2022-1643212149, CLSA-2022-1643291562, DEBIAN-CVE-2021-4034, DLA-2899-1, DSA-5059-1, GHSA-qgr2-xgqv-24x8, MGASA-2022-0037, OESA-2022-1502, RHSA-2022:0265, RHSA-2022:0266, RHSA-2022:0267, RHSA-2022:0268, RHSA-2022:0269, RHSA-2022:0270, RHSA-2022:0271, RHSA-2022:0272, RHSA-2022:0273, RHSA-2022:0274, RLSA-2022:0267, SUSE-SU-2022:0189-1, SUSE-SU-2022:0190-1, SUSE-SU-2022:0191-1, UBUNTU-CVE-2021-4034, USN-5252-1, USN-5252-2, openSUSE-SU-2022:0190-1, openSUSE-SU-2024:11780-1

## What is CVE-2021-4034?

CVE-2021-4034 is a high-severity vulnerability in Canonical Ubuntu Linux, published on 28 Jan 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A local privilege escalation vulnerability was found on polkit's pkexec utility. The pkexec application is a setuid tool designed to allow unprivileged users to run commands as privileged users according predefined policies. The current version of pkexec doesn't handle the calling parameters count correctly and ends trying to execute environment variables as commands. An attacker can leverage this by crafting environment variables in such a way it'll induce pkexec to execute arbitrary code. When successfully executed the attack can cause a local privilege escalation given unprivileged users administrative rights on the target machine.

Weakness: CWE-125 (Out-of-bounds Read), CWE-787 (Out-of-bounds Write)

## Which versions are affected by CVE-2021-4034?

It affects 30 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `polkit` | AlmaLinux:8 | All versions | 0.115-13.el8_5.2 |
| `polkit-devel` | AlmaLinux:8 | All versions | 0.115-13.el8_5.2 |
| `polkit-docs` | AlmaLinux:8 | All versions | 0.115-13.el8_5.2 |
| `polkit-libs` | AlmaLinux:8 | All versions | 0.115-13.el8_5.2 |
| `polkit` | Red Hat:enterprise_linux:7::client | All versions | 0:0.112-26.el7_9.1 |
| `polkit-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 0:0.112-26.el7_9.1 |
| `polkit-devel` | Red Hat:enterprise_linux:7::client | All versions | 0:0.112-26.el7_9.1 |
| `polkit-docs` | Red Hat:enterprise_linux:7::client | All versions | 0:0.112-26.el7_9.1 |
| `polkit-debuginfo` | Red Hat:enterprise_linux:7::computenode | All versions | 0:0.112-26.el7_9.1 |
| `polkit-devel` | Red Hat:enterprise_linux:7::computenode | All versions | 0:0.112-26.el7_9.1 |
| `polkit-docs` | Red Hat:enterprise_linux:7::computenode | All versions | 0:0.112-26.el7_9.1 |
| `polkit` | Red Hat:enterprise_linux:7::server | All versions | 0:0.112-26.el7_9.1 |
| `polkit-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 0:0.112-26.el7_9.1 |
| `polkit-devel` | Red Hat:enterprise_linux:7::server | All versions | 0:0.112-26.el7_9.1 |
| `polkit-docs` | Red Hat:enterprise_linux:7::server | All versions | 0:0.112-26.el7_9.1 |
| `polkit` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.112-26.el7_9.1 |
| `polkit-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.112-26.el7_9.1 |
| `polkit-devel` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.112-26.el7_9.1 |
| `polkit-docs` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.112-26.el7_9.1 |
| `polkit` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-devel` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-docs` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-libs` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit-libs-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.115-13.el8_5.1 |
| `polkit` | Red Hat:rhel_aus:7.3::server | All versions | 0:0.112-12.el7_3.1 |
| `polkit-debuginfo` | Red Hat:rhel_aus:7.3::server | All versions | 0:0.112-12.el7_3.1 |
| `polkit-devel` | Red Hat:rhel_aus:7.3::server | All versions | 0:0.112-12.el7_3.1 |
| `polkit-docs` | Red Hat:rhel_aus:7.3::server | All versions | 0:0.112-12.el7_3.1 |
| `polkit` | Red Hat:rhel_aus:7.4::server | All versions | 0:0.112-12.el7_4.2 |
| `polkit-debuginfo` | Red Hat:rhel_aus:7.4::server | All versions | 0:0.112-12.el7_4.2 |
| `polkit-devel` | Red Hat:rhel_aus:7.4::server | All versions | 0:0.112-12.el7_4.2 |
| `polkit-docs` | Red Hat:rhel_aus:7.4::server | All versions | 0:0.112-12.el7_4.2 |
| `polkit` | Red Hat:rhel_aus:7.6::server | All versions | 0:0.112-18.el7_6.3 |
| `polkit-debuginfo` | Red Hat:rhel_aus:7.6::server | All versions | 0:0.112-18.el7_6.3 |
| `polkit-devel` | Red Hat:rhel_aus:7.6::server | All versions | 0:0.112-18.el7_6.3 |
| `polkit-docs` | Red Hat:rhel_aus:7.6::server | All versions | 0:0.112-18.el7_6.3 |
| `polkit` | Red Hat:rhel_aus:7.7::server | All versions | 0:0.112-22.el7_7.2 |
| `polkit-debuginfo` | Red Hat:rhel_aus:7.7::server | All versions | 0:0.112-22.el7_7.2 |

Products: Canonical Ubuntu Linux, Oracle Http Server, Oracle Zfs Storage Appliance Kit, Polkit Project Polkit, Redhat Enterprise Linux, Redhat Enterprise Linux Desktop, Redhat Enterprise Linux Eus, Redhat Enterprise Linux for Ibm Z Systems, Redhat Enterprise Linux for Ibm Z Systems Eus, Redhat Enterprise Linux for Power Big Endian, Redhat Enterprise Linux for Power Little Endian, Redhat Enterprise Linux for Power Little Endian Eus, Redhat Enterprise Linux for Scientific Computing, Redhat Enterprise Linux Server, Redhat Enterprise Linux Server Aus, Redhat Enterprise Linux Server Eus, Redhat Enterprise Linux Server Tus, Redhat Enterprise Linux Server Update Services for Sap Solutions, Redhat Enterprise Linux Workstation, Siemens Scalance Lpe9403 Firmware and 10 more.

## How do I fix CVE-2021-4034?

Apply the vendor's patch. US federal agencies must fix it by 18 Jul 2022.

## Is CVE-2021-4034 being exploited?

Yes. Attackers have exploited CVE-2021-4034 in the wild since at least 27 Jun 2022, including in ransomware campaigns.

Public exploit code:

- CVE-2021-4034 1day (github_poc): https://github.com/berdav/CVE-2021-4034
- Self-contained exploit for CVE-2021-4034 - Pkexec Local Privilege Escalation (github_poc): https://github.com/ly4k/PwnKit
- PoC for PwnKit: Local Privilege Escalation Vulnerability in polkit’s pkexec (CVE-2021-4034) (github_poc): https://github.com/arthepsy/CVE-2021-4034
- Proof of concept for pwnkit vulnerability (github_poc): https://github.com/PwnFunction/CVE-2021-4034
- Python exploit code for CVE-2021-4034 (pwnkit) (github_poc): https://github.com/joeammond/CVE-2021-4034
- PoC for CVE-2021-4034 dubbed pwnkit (github_poc): https://github.com/dzonerzy/poc-cve-2021-4034

## Other vulnerabilities in Canonical Ubuntu Linux

- [CVE-2020-11651](https://insights.sbomify.com/CVE-2020-11651/): SaltStack Salt Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2020-7247](https://insights.sbomify.com/CVE-2020-7247/): OpenSMTPD Remote Code Execution (critical 9.8, exploited in the wild)
- [CVE-2019-16928](https://insights.sbomify.com/CVE-2019-16928/): Exim Out-of-bounds Write (critical 9.8, exploited in the wild)
- [CVE-2018-6789](https://insights.sbomify.com/CVE-2018-6789/): Exim Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2015-2590](https://insights.sbomify.com/CVE-2015-2590/): Oracle Java SE and Java SE Embedded Remote Code Execution (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-4034 and fix it if it is affected.

What it is: CVE-2021-4034 is a high-severity vulnerability in Canonical Ubuntu Linux, published on 28 Jan 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: Yes. Attackers have exploited CVE-2021-4034 in the wild since at least 27 Jun 2022, including in ransomware campaigns.

Affected product: Canonical Ubuntu Linux. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-4034/ (Markdown: https://insights.sbomify.com/CVE-2021-4034/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-4034
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-4034
- OSV: https://osv.dev/vulnerability/CVE-2021-4034

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-4034/
Summaries are generated and may contain mistakes; the official description above is the record.
