cve.bz

CVE-2021-32751 gradle gradle: OS Command Injection

7.5 highExploit referenceEPSS 2.7%

High (7.5) in gradle gradle. EPSS 2.7% estimated probability of exploitation activity in the next 30 days.

On this page
Gradle is a build tool with a focus on build automation. In versions prior to 7.2, start scripts generated by the `application` plugin and the `gradlew` script are both vulnerable to arbitrary code execution when an attacker is able to change environment variables for the user running the script. This may impact those who use `gradlew` on Unix-like systems or use the scripts generated by Gradle in thieir application on Unix-like systems. For this vulnerability to be exploitable, an attacker needs to be able to set the value of particular environment variables and have those environment variables be seen by the vulnerable scripts. This issue has been patched in Gradle 7.2 by removing the use of `eval` and requiring the use of the `bash` shell. There are a few workarounds available. For CI/CD systems using the Gradle build tool, one may ensure that untrusted users are unable to change environment variables for the user that executes `gradlew`. If one is unable to upgrade to Gradle 7.2, one may generate a new `gradlew` script with Gradle 7.2 and use it for older versions of Gradle. Fpplications using start scripts generated by Gradle, one may ensure that untrusted users are unable to change environment variables for the user that executes the start script. A vulnerable start script could be manually patched to remove the use of `eval` or the use of environment variables that affect the application's command-line. If the application is simple enough, one may be able to avoid the use of the start scripts by running the application directly with Java command.

Severity

CVSS 3.1

7.5 high
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
EPSS
2.7% (unchanged from 2.7% a week ago; 2.7% 30 days ago) estimated probability of exploitation activity in the next 30 days; 86th percentile. Scored 2026-11-22. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: none · Automatable: yes · Technical impact: total, assessed 2026-10-08. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWE
CWE-78 Improper Neutralization of Special Elements used in an OS Command (OS Command Injection)
OWASP Top 10
A05:2025 Injection
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2021-32751 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2021-32751?via=ask-ai-copy and https://cve.bz/cve/CVE-2021-32751?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2021-32751 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
gradle:gradlebefore 7.2

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian12, 13, 14gradleno fix listedDEBIAN-CVE-2021-32751
Ubuntu16.04:LTS, 20.04:LTS, 22.04:LTS and 5 moregradleno fix listedUBUNTU-CVE-2021-32751
SUSELinux Enterprise Module for Development Tools 15 SP4, Linux Enterprise Real Time 15 SP3gradle4.4.1-150200.3.10.1SUSE-SU-2023:2203-1
openSUSELeap 15.4gradle4.4.1-150200.3.10.1SUSE-SU-2023:2203-1
Alpinev3.15, v3.16, v3.17 and 7 moregradle7.2-r0ALPINE-CVE-2021-32751

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; SUSE security data, CC BY 4.0; the Alpine secdb, CC BY-SA 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · SUSE · openSUSE · Alpine.

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

To exploit this vulnerability, an attacker needs to be able to set the value of particular environment variables and have those environment variables be seen by the vulnerable scripts. This requirement makes this CVE of a Moderate impact.

Red Hat's mitigation

CI/CD systems using the Gradle build tool

- You are not vulnerable if untrusted users are unable to change environment variables for the user that executes gradlew.

- If you are unable to upgrade to Gradle 7.2, you can generate a new gradlew script with Gradle 7.2 and use it for older versions of Gradle.

Applications using start scripts generated by Gradle

- You are not vulnerable if untrusted users are unable to change environment variables for the user that executes the start script.

- If you are unsure, the vulnerable start script could be manually patched to remove the use of eval or the use of environment variables that affect the application's command-line.

- If the application is simple enough, you may be able to avoid the use of the start scripts by running the application directly with the Java command.

ProductPackageStateAdvisory
Red Hat JBoss Enterprise Application Platform 6gradleOut of support scope
Red Hat JBoss Enterprise Application Platform 7gradleNot affected
Red Hat JBoss Enterprise Application Platform Expansion PackgradleNot affected
Red Hat Software Collectionsrh-maven36-byte-buddyWill not fix

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2021-32751.

Attack patterns (CAPEC)

  • CAPEC-6 Argument Injection Likelihood: High · Severity: High
  • CAPEC-15 Command Delimiters Likelihood: High · Severity: High
  • CAPEC-43 Exploiting Multiple Input Interpretation Layers Likelihood: Medium · Severity: High
  • CAPEC-88 OS Command Injection Likelihood: High · Severity: High
  • CAPEC-108 Command Line Execution through SQL Injection Likelihood: Low · Severity: Very High

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits.

References

Check your stackJSON