Gradle is a build automation tool, and its native-platform tool provides Java bindings for native APIs. When resolving dependencies in versions before 9.3.0, some exceptions were not treated as fatal errors and would not cause a repository to be disabled. If a build encountered one of these exceptions, Gradle would continue to the next repository in the list and potentially resolve dependencies from a different repository. An exception like NoHttpResponseException can indicate transient errors. If the errors persist after a maximum number of retries, Gradle would continue to the next repository. This behavior could allow an attacker to disrupt the service of a repository and leverage another repository to serve malicious artifacts. This attack requires the attacker to have control over a repository after the disrupted repository. Gradle has introduced a change in behavior in Gradle 9.3.0 to stop searching other repositories when encountering these errors.
Gradle versions before 9.3.0 fail to treat certain exceptions as fatal errors during dependency resolution, allowing attackers to disrupt legitimate repositories and inject malicious artifacts from alternative repositories. This supply chain attack vector poses significant risk to organizations using Gradle for build automation, particularly those with multiple configured repositories. The vulnerability requires attacker control over a downstream repository but could compromise entire software supply chains.
1. IMMEDIATE ACTIONS:
- Audit all Gradle installations across development environments and CI/CD pipelines
- Document all configured repositories in Gradle build files (build.gradle, settings.gradle)
- Review dependency resolution logs for NoHttpResponseException or similar transient errors
- Implement repository access controls and network segmentation
2. PATCHING GUIDANCE:
- Upgrade Gradle to version 9.3.0 or later immediately
- Update gradle-wrapper.properties in all projects to reference patched version
- Rebuild all artifacts with patched Gradle version
- Verify integrity of previously built artifacts against known-good checksums
3. COMPENSATING CONTROLS (if immediate patching not possible):
- Restrict repository list to single trusted internal mirror/proxy
- Implement repository pinning with explicit version constraints
- Enable strict dependency verification using gradle-dependency-verify plugin
- Monitor HTTP response codes and connection failures in build logs
- Implement artifact signature verification for all dependencies
4. DETECTION RULES:
- Alert on NoHttpResponseException or ConnectException in Gradle build logs
- Monitor for repository fallback behavior (switching between configured repos)
- Track changes to build.gradle repository configurations
- Audit artifact downloads from non-primary repositories
- Implement SBOM generation and comparison for build artifacts
1. الإجراءات الفورية:
- تدقيق جميع تثبيتات Gradle عبر بيئات التطوير وخطوط أنابيب CI/CD
- توثيق جميع المستودعات المكونة في ملفات بناء Gradle (build.gradle و settings.gradle)
- مراجعة سجلات حل التبعيات بحثاً عن NoHttpResponseException أو أخطاء عابرة مماثلة
- تنفيذ عناصر تحكم الوصول إلى المستودع وتقسيم الشبكة
2. إرشادات التصحيح:
- ترقية Gradle إلى الإصدار 9.3.0 أو أحدث على الفور
- تحديث gradle-wrapper.properties في جميع المشاريع للإشارة إلى الإصدار المصحح
- إعادة بناء جميع القطع الأثرية باستخدام إصدار Gradle المصحح
- التحقق من سلامة القطع الأثرية المبنية مسبقاً مقابل المجاميع المعروفة الجيدة
3. الضوابط البديلة (إذا لم يكن التصحيح الفوري ممكناً):
- تقييد قائمة المستودع إلى مرآة/وكيل داخلي موثوق واحد
- تنفيذ تثبيت المستودع مع قيود الإصدار الصريحة
- تمكين التحقق الصارم من التبعيات باستخدام مكون gradle-dependency-verify
- مراقبة رموز استجابة HTTP وأخطاء الاتصال في سجلات البناء
- تنفيذ التحقق من توقيع القطع الأثرية لجميع التبعيات
4. قواعد الكشف:
- تنبيه على NoHttpResponseException أو ConnectException في سجلات بناء Gradle
- مراقبة سلوك الرجوع إلى المستودع (التبديل بين المستودعات المكونة)
- تتبع التغييرات في تكوينات مستودع build.gradle
- تدقيق تنزيلات القطع الأثرية من المستودعات غير الأساسية
- تنفيذ إنشاء SBOM والمقارنة لقطع البناء