Gradle runs work — compilation, tests, and Worker API actions — in forked worker processes that communicate with the long-lived Gradle daemon. The worker ↔ daemon socket is a loopback TCP connection that performs no authentication of the connecting peer. The connection is accepted on a first-come basis during a short window while a worker starts. Each message on that channel can be encoded with a per-type serializer but uses Java serialization as a fallback. This advisory is about a vulnerability on this communication channel.
An attacker who can place bytes on this channel can cause the daemon to deserialize a hostile object graph which can lead to remote code execution in the daemon JVM or a denial of service (a crash or resource exhaustion from a malformed or deeply nested graph). This has been demonstrated with a proof-of-concept. Code execution in the daemon runs with the privileges of the user running the build and exposes in-memory and on-disk secrets available to it. This advisory does not publish the proof-of-concept.
Builds running on shared / multi-user build hosts are the most at risk. The vulnerability requires an actively running Gradle build and requires the attacker to win a race to connect during the short window between a worker process starting and the daemon accepting a connection from it.
This vulnerability is not exploitable from a remote network connection.
Gradle has updated the worker/daemon protocol to use a per-connection secret for authentication.
| Fix version | Availability |
|---|---|
| 9.8.1 | OSS |
| 9.7.2 | Gradle Security Subscription |
| 9.6.2 | Gradle Security Subscription |
| 9.5.2 | Gradle Security Subscription |
| 9.4.2 | Gradle Security Subscription |
| 9.3.2 | Gradle Security Subscription |
| 9.2.2 | Gradle Security Subscription |
| 9.1.1 | Gradle Security Subscription |
| 8.14.6 | OSS |
| 7.6.7 | Gradle Security Subscription |
Upgrading Gradle is our recommended fix.
If you cannot upgrade immediately:
If you cannot apply these mitigations, restrict which users and processes share a host with your builds until you can upgrade.
When a message not originating from the worker takes over the connection, the worker process will fail its connection attempt and Gradle will report this error in the build output:
org.gradle.internal.remote.internal.ConnectException: Could not connect to server [<id> port:<port>, addresses:[/127.0.0.1]]. Tried addresses: [/127.0.0.1].
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:…)
…
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:…)
Caused by: java.net.ConnectException: Connection refused
This error will then be reported as a failure of the task or operation that started the worker.
[!IMPORTANT] The lack of a log entry cannot be used to conclude no such attack was performed. The presence of a log entry is not a confirmation that an attack happened, but an indication that more investigations are needed.
* Gradle architecture standard ADR-0002, "Avoid using Java serialization" — Gradle's own guidance to move off Java serialization, citing deserialization security among the reasons.
More about this type of vulnerabilities:
{
"coverage": "partial",
"coverage_exclusions": [
"legacy_package_image_owner"
]
}