DEV Community

andreagomez
andreagomez

Posted on

Gradle's repository fallback could swap an expected artifact for another source's package

Gradle's repository fallback could swap an expected artifact for another source's package

Gradle resolves dependencies from repositories in declaration order. Its expected behavior is to fail when a repository cannot answer, rather than continue to a later repository and silently accept a different source. In affected releases, some exceptions were not treated as fatal, so resolution could continue down the list.

The issue is CVE-2026-22865, with a closely related CVE-2026-22816 covering another failure path. Versions through 8.14.3 and from 9.0.0 through 9.2.1 are affected. The fixed releases are 8.14.4 and 9.3.0. GitHub rates CVE-2026-22865 High with a CVSS score of 8.0.

A network failure can become a supply-chain decision

Build systems often have an internal mirror followed by a public repository. The first entry is supposed to be the trusted source, and a fallback is useful when the mirror lacks an unrelated package. That convenience becomes dangerous when the expected repository is unavailable and a package with the same coordinates exists elsewhere.

An attacker does not need to compromise the build server. The attacker can register a package name or coordinate that the build will request after the primary repository fails. If Gradle substitutes that artifact, the build may compile and test successfully while shipping attacker-controlled code.

The advisory classifies the issue around integrity checking and untrusted control spheres. The practical review should ask whether repository ordering is being used as a trust control, and whether any repository can satisfy coordinates that should belong to another.

Upgrade and make repository scope explicit

Upgrade to Gradle 8.14.4 or 9.3.0. Then inspect repository declarations in build.gradle, settings.gradle, included builds and plugin management. Use exclusive content filters or repository rules so a repository can only answer for the groups it owns. Remove broad public fallbacks when an internal mirror is intended to serve all approved dependencies.

Enable dependency verification for security-sensitive builds. Store checksums and signatures under review, and fail the build on an unknown artifact. A lock file helps reproducibility, but it should not be the only control because an attacker may change what a coordinate resolves to before the lock is regenerated.

Retest builds with the primary repository deliberately unavailable in an isolated environment. The expected result is a failed resolution, not a successful fetch from a public source. Log the selected repository and artifact hash for every dependency in release builds.

Investigate a historical fallback

Compare resolved artifacts with the approved repository list for each past release. Look for packages whose coordinates appear in a later repository despite being expected from the mirror. Check publication dates, signer identity and source repository metadata. A hash mismatch is strong evidence of substitution; a hash match may still mean the same artifact was mirrored twice.

Rotate CI credentials if a malicious artifact may have executed inside the build. Treat generated release artifacts as suspect until their provenance is reviewed. The build cache is part of the blast radius because a poisoned task output can be reused after the repository is fixed.

The patch closes a runtime path. Repository design determines whether a future network error can become another source-selection event.

References

Top comments (0)