{"id":"DHI-ozpw-x3jg-vnj2-lbch","summary":"### Impact","details":"### Impact\r\n\r\n[TestKit](https://docs.gradle.org/current/userguide/test_kit.html) runs Gradle builds from tests and from build logic, mostly to test Gradle plugins. Its `GradleRunner` uses a dedicated directory, the TestKit directory, as the Gradle user home of the builds it runs. It holds their `gradle.properties`, init scripts, dependency caches and daemon registry. This advisory is about a vulnerability in TestKit.\r\n\r\nWhen the TestKit directory is not configured, and `GradleRunner` does not run in Gradle's `Test` task, TestKit uses `.gradle-test-kit` in the temporary directory of the JVM, given by the `java.io.tmpdir` system property. On Linux this is `/tmp` by default, so the directory is `/tmp/.gradle-test-kit`. The path is the same for every user, and TestKit uses an existing directory at that path as long as it can write to it, whoever owns it. A local attacker who creates that directory before the victim does controls the Gradle user home of the victim's TestKit builds. Gradle loads the `gradle.properties` and init scripts it finds in that directory. Files the attacker places there therefore run code with the privileges of the user running the build, and expose the secrets available to it.\r\n\r\n[GHSA-89qm-pxvm-p336](https://github.com/gradle/gradle/security/advisories/GHSA-89qm-pxvm-p336) (CVE-2021-29428) reported this vulnerability for Gradle versions before 7.0, where TestKit always used `.gradle-test-kit-\u003cuser name\u003e` in the system temporary directory. Its fix was incomplete. Since Gradle 7.0, tests run by Gradle's `Test` task use a TestKit directory in the build directory, and are not affected. The system temporary directory remains in use when:\r\n\r\n* build logic or a plugin calls `GradleRunner` from a task or a worker action, so in the Gradle daemon or a worker process;\r\n* tests run in an IDE's own test runner rather than through Gradle.\r\n\r\nBuilds running on **shared, multi-user Linux hosts** are the most at risk, such as CI agents running jobs as different users. The attacker can create the directory before the victim's first TestKit build on the host, or whenever it is removed afterwards, for instance by `systemd-tmpfiles` or at reboot when `/tmp` is a `tmpfs`. Windows and macOS use a temporary directory per user and are not affected. Neither are Linux setups giving each user or job a private `/tmp`.\r\n\r\nThis vulnerability is not exploitable from a remote network connection.\r\n\r\n### Patches\r\n\r\nWhen the TestKit directory is not configured and `GradleRunner` does not run in Gradle's `Test` task, TestKit now uses `.gradle-test-kit-\u003cuser name\u003e` in the system temporary directory, and creates it accessible to its owner only.\r\n\r\nIf that path already exists, TestKit uses it only when it is a real directory, rather than a symbolic link, that belongs to the current user and that no other user can write to. Otherwise, TestKit leaves it untouched, does not run the build, and fails with `Unable to use \u003cpath\u003e as the TestKit directory: \u003creason\u003e.`\r\n\r\nA TestKit directory set with `GradleRunner.withTestKitDir()` or the `org.gradle.testkit.dir` system property, and the one used under Gradle's `Test` task, are unchanged. The previous `.gradle-test-kit` directory in the system temporary directory is no longer used and can be deleted.\r\n\r\n| Fix version | Availability |\r\n| ---------- | ----------- |\r\n| 9.9.2 | OSS |\r\n| 9.8.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.7.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.6.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.5.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.4.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.3.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 9.2.4 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n| 8.14.8 | OSS |\r\n| 7.6.9 | [Gradle Security Subscription](https://gradle.org/security-subscription/) |\r\n\r\n### Workarounds\r\n\r\nUpgrading Gradle is our recommended fix.\r\n\r\nIf you cannot upgrade immediately:\r\n\r\n* **Set the TestKit directory explicitly.** Call [`GradleRunner.withTestKitDir()`](https://docs.gradle.org/current/javadoc/org/gradle/testkit/runner/GradleRunner.html#withTestKitDir(java.io.File)) with a directory only you can write to, for example in the build directory, or set the `org.gradle.testkit.dir` system property in the JVM that runs `GradleRunner`. For an IDE test runner, add `-Dorg.gradle.testkit.dir=PATH` to the JVM options of the run configuration.\r\n* **Run tests through Gradle's `Test` task**, which places the TestKit directory in the build directory since Gradle 7.0.\r\n* **Do not run builds on shared, multi-user machines**, or give each user or job a private temporary directory.\r\n\r\n### Forensics\r\n\r\nTestKit never creates `gradle.properties` or an `init.d` directory in the TestKit directory. On Linux, check the owner and permissions of the directory and look for these files. Before Gradle 7.0, the directory is `/tmp/.gradle-test-kit-\u003cuser name\u003e`. Adjust the path if `java.io.tmpdir` is set to another directory.\r\n\r\n    ls -la /tmp/.gradle-test-kit /tmp/.gradle-test-kit/init.d\r\n    cat /tmp/.gradle-test-kit/gradle.properties\r\n\r\nA directory owned by another user, writable by other users, or containing files you did not create indicates an attempt.\r\n\r\nA TestKit build failing with `Unable to write to test kit directory: /tmp/.gradle-test-kit` means that another user created the directory first, maliciously or not.\r\n\r\nA fixed version reports a directory it refuses instead of using it: `Unable to use /tmp/.gradle-test-kit-\u003cuser name\u003e as the TestKit directory: it is owned by another user.` The other reasons are `it is a symbolic link`, `it is not a directory` and `it is writable by other users`.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e The lack of such traces cannot be used to conclude no such attack was performed. Their presence is not a confirmation that an attack happened, but an indication that more investigations are needed.\r\n\r\n### References\r\n\r\n* [Testing Build Logic with TestKit](https://docs.gradle.org/current/userguide/test_kit.html)\r\n* Prior Gradle vulnerabilities: [GHSA-89qm-pxvm-p336](https://github.com/gradle/gradle/security/advisories/GHSA-89qm-pxvm-p336), [GHSA-465q-w4mf-4f4r](https://github.com/gradle/gradle/security/advisories/GHSA-465q-w4mf-4f4r)\r\n\r\nMore about this type of vulnerabilities:\r\n\r\n* https://cwe.mitre.org/data/definitions/379.html\r\n* https://cwe.mitre.org/data/definitions/283.html","modified":"2026-11-28T06:30:06.545740564Z","published":"2026-11-20T13:17:39Z","upstream":["GHSA-99wf-vhq9-wm2x"],"database_specific":{"coverage":"partial","coverage_exclusions":["legacy_package_image_owner"]},"references":[{"type":"ADVISORY","url":"https://scout.docker.com/v/DHI-ozpw-x3jg-vnj2-lbch"},{"type":"ADVISORY","url":"https://github.com/gradle/gradle/security/advisories/GHSA-99wf-vhq9-wm2x"}],"affected":[{"package":{"name":"gradle-8","ecosystem":"Docker Hardened Images:Alpine:3.23","purl":"pkg:apk/dhi/gradle-8"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"8.14.8-r0"}]}],"versions":["8.14.4-r0","8.14.4-r1","8.14.4-r2","8.14.4-r3","8.14.5-r3","8.14.5-r4","8.14.5-r5","8.14.5-r6","8.14.5-r7","8.14.5-r8","8.14.5-r9","8.14.6-r0","8.14.6-r1","8.14.6-r2","8.14.7-r0"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}},{"package":{"name":"gradle-9","ecosystem":"Docker Hardened Images:Alpine:3.23","purl":"pkg:apk/dhi/gradle-9"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"9.9.2-r0"}]}],"versions":["9.4.0-r0","9.4.0-r1","9.4.1-r1","9.4.1-r2","9.5.0-r2","9.5.0-r3","9.5.1-r3","9.6.0-r3","9.6.1-r3","9.6.1-r4","9.6.1-r5","9.6.1-r6","9.7.0-r1","9.7.1-r0","9.7.1-r1","9.8.0-r1","9.8.1-r0","9.8.2-r0","9.8.2-r1","9.9.0-r0","9.9.1-r0"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}},{"package":{"name":"wiremock","ecosystem":"Docker Hardened Images:Alpine:3.23","purl":"pkg:apk/dhi/wiremock"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.13.2-r0"}]}],"versions":["3.13.2-r0","3.13.2-r1","3.13.2-r10","3.13.2-r11","3.13.2-r12","3.13.2-r13","3.13.2-r14","3.13.2-r15","3.13.2-r16","3.13.2-r17","3.13.2-r18","3.13.2-r19","3.13.2-r2","3.13.2-r20","3.13.2-r21","3.13.2-r22","3.13.2-r23","3.13.2-r24","3.13.2-r25","3.13.2-r26","3.13.2-r27","3.13.2-r28","3.13.2-r29","3.13.2-r3","3.13.2-r30","3.13.2-r31","3.13.2-r32","3.13.2-r33","3.13.2-r34","3.13.2-r35","3.13.2-r36","3.13.2-r37","3.13.2-r38","3.13.2-r39","3.13.2-r4","3.13.2-r40","3.13.2-r41","3.13.2-r42","3.13.2-r5","3.13.2-r6","3.13.2-r7","3.13.2-r8","3.13.2-r9"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}},{"package":{"name":"wiremock","ecosystem":"Docker Hardened Images:Alpine:3.24","purl":"pkg:apk/dhi/wiremock"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.13.2-r0"}]}],"versions":["3.13.2-r0","3.13.2-r1","3.13.2-r10","3.13.2-r11","3.13.2-r12","3.13.2-r13","3.13.2-r14","3.13.2-r15","3.13.2-r16","3.13.2-r17","3.13.2-r18","3.13.2-r19","3.13.2-r2","3.13.2-r20","3.13.2-r21","3.13.2-r22","3.13.2-r23","3.13.2-r24","3.13.2-r25","3.13.2-r26","3.13.2-r27","3.13.2-r28","3.13.2-r29","3.13.2-r3","3.13.2-r30","3.13.2-r31","3.13.2-r32","3.13.2-r33","3.13.2-r34","3.13.2-r35","3.13.2-r36","3.13.2-r37","3.13.2-r38","3.13.2-r39","3.13.2-r4","3.13.2-r40","3.13.2-r41","3.13.2-r42","3.13.2-r5","3.13.2-r6","3.13.2-r7","3.13.2-r8","3.13.2-r9"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}},{"package":{"name":"wiremock-gui","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/wiremock-gui"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.13.191-0"}]}],"versions":["3.13.191-0","3.13.192-0","3.13.193-0","3.13.193-1","3.13.193-2","3.13.194-0","3.13.195-0","3.13.195-1","3.13.195-2","3.13.195-3","3.13.195-4","3.13.195-5","3.13.195-6","3.13.195-7","3.13.197-0","3.13.197-1","3.13.197-2","3.13.197-3","3.13.198-0","3.13.198-1","3.13.198-2","3.13.198-3","3.13.198-4","3.13.199-1","3.13.199-2","3.13.199-3","3.13.199-4","3.13.199-5","3.13.199-6","3.13.199-7","3.13.199-8","3.13.208-0","3.13.211-0","3.13.212-0","3.13.213-0","3.13.214-0","3.13.215-0","3.13.216-0","3.13.217-0","3.13.217-1","3.13.217-2","3.13.217-3","3.13.217-4"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}},{"package":{"name":"wiremock","ecosystem":"Docker Hardened Images:Debian:13","purl":"pkg:deb/dhi/wiremock"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.13.2-0"}]}],"versions":["3.13.2-0","3.13.2-1","3.13.2-10","3.13.2-11","3.13.2-12","3.13.2-13","3.13.2-14","3.13.2-15","3.13.2-16","3.13.2-17","3.13.2-18","3.13.2-19","3.13.2-2","3.13.2-20","3.13.2-21","3.13.2-22","3.13.2-23","3.13.2-24","3.13.2-25","3.13.2-26","3.13.2-27","3.13.2-28","3.13.2-29","3.13.2-3","3.13.2-30","3.13.2-31","3.13.2-32","3.13.2-33","3.13.2-34","3.13.2-35","3.13.2-36","3.13.2-37","3.13.2-38","3.13.2-39","3.13.2-4","3.13.2-40","3.13.2-41","3.13.2-42","3.13.2-5","3.13.2-6","3.13.2-7","3.13.2-8","3.13.2-9"],"database_specific":{"owner_kind":"HSP","source":"https://github.com/docker-hardened-images/advisories/blob/main/dhi/osv/2026/DHI-ozpw-x3jg-vnj2-lbch.json"}}],"schema_version":"1.9.2"}