# CVE-2021-29427: Repository content filters do not work in Settings pluginManagement

> Gradle ignores repository content filters in pluginManagement, allowing attackers to leak internal package names or inject malicious dependencies via name squatting.

- **Severity:** High 8.0 (`CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 Apr 2021
- **Updated:** 3 Aug 2024
- **Also known as:** BIT-gradle-2021-29427, GHSA-jvmj-rh6q-x395

## What is CVE-2021-29427?

CVE-2021-29427 is a high-severity vulnerability in gradle, published on 13 Apr 2021. An attacker needs administrator access to exploit it, with no action from the victim.

### Official description

In Gradle from version 5.1 and before version 7.0 there is a vulnerability which can lead to information disclosure and/or dependency poisoning. Repository content filtering is a security control Gradle introduced to help users specify what repositories are used to resolve specific dependencies. This feature was introduced in the wake of the "A Confusing Dependency" blog post. In some cases, Gradle may ignore content filters and search all repositories for dependencies. This only occurs when repository content filtering is used from within a `pluginManagement` block in a settings file. This may change how dependencies are resolved for Gradle plugins and build scripts. For builds that are vulnerable, there are two risks: 1) Information disclosure: Gradle could make dependency requests to repositories outside your organization and leak internal package identifiers. 2) Dependency poisoning/Dependency confusion: Gradle could download a malicious binary from a repository outside your organization due to name squatting. For a full example and more details refer to the referenced GitHub Security Advisory. The problem has been patched and released with Gradle 7.0. Users relying on this feature should upgrade their build as soon as possible. As a workaround, users may use a company repository which has the right rules for fetching packages from public repositories, or use project level repository content filtering, inside `buildscript.repositories`. This option is available since Gradle 5.1 when the feature was introduced.

Weakness: CWE-829 (Inclusion of Functionality from Untrusted Control Sphere)

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

1 open source package ship an affected version, including gradle. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `gradle` | Bitnami | From 5.1.0 | 7.0.0 |

Products: Gradle Gradle, Quarkus Quarkus.

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

Upgrade gradle to 7.0.0 or later.

## Is CVE-2021-29427 being exploited?

There is no known exploitation of CVE-2021-29427 in the wild and no public exploit code.

Public exploit code:

- gradle cve (github_poc): https://github.com/arsalanraja987/gradle-cve-2021-29427-demo

## Other vulnerabilities in gradle

- [CVE-2019-15052](https://insights.sbomify.com/CVE-2019-15052/): Information disclosure in n/a (critical 9.8)
- [CVE-2016-6199](https://insights.sbomify.com/CVE-2016-6199/): Deserialization in n/a (critical 9.8)
- [CVE-2021-29428](https://insights.sbomify.com/CVE-2021-29428/): Local privilege escalation through system temporary directory (high 8.8)
- [CVE-2026-22816](https://insights.sbomify.com/CVE-2026-22816/): Gradle fails to disable repositories which can expose builds to malicious artifacts (high 8.6)
- [CVE-2026-22865](https://insights.sbomify.com/CVE-2026-22865/): Gradle's failure to disable repositories failing to answer can expose builds to malicious artifacts (high 8.6)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-29427 is a high-severity vulnerability in gradle, published on 13 Apr 2021. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-29427 in the wild and no public exploit code.

Affected packages and fixed versions:
- gradle (Bitnami): affected from 5.1.0; fixed in 7.0.0

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-29427/ (Markdown: https://insights.sbomify.com/CVE-2021-29427/index.md)
```

## Sources

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

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