CVE-2021-29428: Local privilege escalation through system temporary directory
In Gradle before version 7.0, on Unix-like systems, the system temporary directory can be created with open permissions that allow multiple users to create and delete files within it. Gradle builds could be vulnerable to a local privilege escalation from an attacker quickly deleting and recreating files in the system temporary directory. This vulnerability impacted builds using precompiled script plugins written in Kotlin DSL and tests for Gradle plugins written using ProjectBuilder or TestKit. If you are on Windows or modern versions of macOS, you are not vulnerable. If you are on a Unix-like operating system with the "sticky" bit set on your system temporary directory, you are not vulnerable. The problem has been patched and released with Gradle 7.0. As a workaround, on Unix-like operating systems, ensure that the "sticky" bit is set. This only allows the original user (or root) to delete a file. If you are unable to change the permissions of the system temporary directory, you can move the Java temporary directory by setting the System Property java.io.tmpdir. The new path needs to limit permissions to the build user only. For additional details refer to the referenced GitHub Security Advisory.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Gradleto a version that resolves this vulnerability.Fixed in 7.0 - Configuration
Ensure the sticky bit is set on the system temporary directory; this limits deletion of files to the original user or root.
Unix-like operating system system temporary directory sticky bit = set - Configuration
If the system temporary directory permissions cannot be changed, set the System Property java.io.tmpdir to a new path whose permissions limit access to the build user only.
Java java.io.tmpdir = a build-user-only temporary directory
Event History
Frequently Asked Questions
What is CVE-2021-29428?
CVE-2021-29428 is a vulnerability in Gradle before version 7.0 on Unix-like systems, where the system temporary directory can be created with open permissions that allow multiple users to create and delete files within it.
What is the severity of CVE-2021-29428?
CVE-2021-29428 has a severity rating of 7.8, which is considered high.
Which software versions are affected by CVE-2021-29428?
CVE-2021-29428 affects Gradle versions up to exclusive version 7.0 and Quarkus versions up to inclusive version 2.2.3.
How can an attacker exploit CVE-2021-29428?
An attacker could exploit CVE-2021-29428 by quickly deleting and recreating files in the system temporary directory, potentially leading to local privilege escalation.
Where can I find more information about CVE-2021-29428?
You can find more information about CVE-2021-29428 in the following references: [GitHub Advisory](https://github.com/gradle/gradle/security/advisories/GHSA-89qm-pxvm-p336), [Red Hat Security Advisory](https://access.redhat.com/errata/RHSA-2022:4623), [Red Hat CVE](https://access.redhat.com/security/cve/cve-2021-29428).