Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 3 min read

CVE-2026-22816: CVE-2026-22816: Improper Repository Failure Handling and Dependency Confusion in Gradle

CVE-2026-22816: Improper Repository Failure Handling and Dependency Confusion in Gradle Vulnerability ID: CVE-2026-22816 CVSS Score: 7.4 Published: 2026-11-23 CVE-2026-22816 (GHSA-w78c-w6vf-rw82) is a high-severity

CVE-2026-22816: Improper Repository Failure Handling and Dependency Confusion in Gradle

Vulnerability ID: CVE-2026-22816
CVSS Score: 7.4
Published: 2026-11-23

CVE-2026-22816 (GHSA-w78c-w6vf-rw82) is a high-severity flaw in Gradle's dependency resolution engine affecting versions prior to 8.14.4 and versions 9.0.0 through 9.2.1. Due to improper error handling when transient network errors or connection failures exhaust their retry limits, Gradle fails to mark unreachable repositories as disabled and does not abort the resolution queue. Instead, it silently falls through to subsequent repositories configured in the build script. This behavior enables dependency confusion and supply chain attacks when an internal or primary repository experiences connectivity issues, unresolvable DNS, or domain registration lapses.

TL;DR

Gradle versions prior to 8.14.4 and 9.0.0 through 9.2.1 fail to disable repositories or halt dependency resolution after exhausting retries on transient network and connection failures. This causes Gradle to silently fall back to secondary or public repositories (such as Maven Central), allowing attackers to execute dependency confusion and supply chain attacks by publishing packages matching internal dependency coordinates.

⚠️ Exploit Status: POC

Technical Details

  • CVE ID: CVE-2026-22816 (GHSA-w78c-w6vf-rw82)
  • Weakness Class: CWE-829 / CWE-494 (Dependency Confusion via Repository Fall-Through)
  • CVSS v3.1 / v4.0: 7.4 HIGH (v3.1) / 8.6 HIGH (v4.0)
  • Attack Vector: Network (AV:N) via Unreachable Primary Repository & Public Fallback
  • Affected Versions: Gradle < 8.14.4 and 9.0.0 - 9.2.1
  • Patched Versions: Gradle 8.14.4 and 9.3.0
  • EPSS Score: 0.17% (6.84th Percentile)
  • CISA KEV Status: Not Listed

Affected Systems

  • Gradle Build Tool (< 8.14.4)
  • Gradle Build Tool (9.0.0 - 9.2.1, including 9.3.0 pre-releases)
  • Gradle: < 8.14.4 (Fixed in: 8.14.4)
  • Gradle: >= 9.0.0, < 9.3.0 (Fixed in: 9.3.0)

Code Analysis

Commit: e5707d0

Disable repository on max retries exceeded and clear repository resolution queue on disabled repositories

--- a/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/ivyservice/ivyresolve/ConnectionFailureRepositoryDisabler.java
+++ b/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/ivyservice/ivyresolve/ConnectionFailureRepositoryDisabler.java
@@ -46,14 +46,14 @@ public Optional<Throwable> getDisabledReason(String repositoryId) {
     }

     @Override
-    public boolean tryDisableRepository(String repositoryId, Throwable reason) {
+    public boolean tryDisableRepository(String repositoryId, Throwable reason, boolean maxRetriesExceeded) {
         boolean disabled = isDisabled(repositoryId);

         if (disabled) {
             return true;
         }

-        if (isCriticalFailure(reason)) {
+        if (isCriticalFailure(reason) || maxRetriesExceeded) {
             LOGGER.debug("Repository {} has been disabled for this build due to connectivity issues", repositoryId);
             disabledRepositories.put(repositoryId, reason);
             return true;

Commit: 4f2e3bb

Abort resolution queue in DynamicVersionResolver and RepositoryChainComponentMetaDataResolver when repository is disabled

+    private static void handleFailure(List<RepositoryResolveState> queue, RepositoryResolveState request, RepositoryFailureCollector failures, Exception t) {
+        failures.addFailure(t);
+        if (request.isRepositoryDisabled() && !request.isContinueOnConnectionFailure()) {
+            // Clear the queue only if repo is now disabled, and we can't continue with it disabled
+            queue.clear();
+            failures.markFatalError();
+        }
+    }

Mitigation Strategies

  • Upgrade Gradle distributions and project Gradle Wrappers to patched releases (8.14.4 or 9.3.0+).
  • Configure explicit Repository Content Filtering using includeGroup, includeGroupByRegex, and excludeGroup directives to prevent internal namespaces from being queried against public repositories.
  • Enable Gradle Dependency Verification (gradle/verification-metadata.xml) to enforce SHA-256 checksums and PGP signature validation on all resolved artifacts.
  • Audit build scripts across all repositories to remove deprecated, misspelled, or expired repository domain names.
  • Route all external dependency requests through a single authenticated internal repository manager (e.g., Nexus, Artifactory) acting as a proxy rather than declaring public repositories directly in build scripts.

Remediation Steps:

  1. Identify all projects using Gradle versions < 8.14.4 or >= 9.0.0 and < 9.3.0 by inspecting gradle/wrapper/gradle-wrapper.properties.
  2. Update Gradle 8.x projects by executing: ./gradlew wrapper --gradle-version 8.14.4
  3. Update Gradle 9.x projects by executing: ./gradlew wrapper --gradle-version 9.3.0
  4. Verify the distributionSha256Sum in gradle-wrapper.properties matches the official checksum published by Gradle.
  5. Add repository content filtering rules in settings.gradle or build.gradle to restrict internal groupId prefixes exclusively to internal Maven/Ivy repositories.
  6. Generate and enforce dependency verification metadata using: ./gradlew --write-verification-metadata sha256,pgp help

References

Read the full report for CVE-2026-22816 on our website for more details including interactive diagrams and full exploit analysis.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.