GitPython is a python library used to interact with Git repositories. Prior to version 3.1.48, a vulnerability in GitPython allows attackers who can supply a crafted reference path to an application using GitPython to write, overwrite, move, or delete files outside the repository’s .git directory via insufficient validation of reference paths in reference creation, rename, and delete operations. This issue has been patched in version 3.1.48.
GitPython versions prior to 3.1.48 contain a path traversal vulnerability (CWE-22) allowing attackers to write, overwrite, move, or delete files outside the repository's .git directory through crafted reference paths. With CVSS 7.1 and active exploits available, this poses significant risk to organizations using GitPython for repository management. Immediate patching to version 3.1.48 or later is critical.
IMMEDIATE ACTIONS:
1. Inventory all systems and applications using GitPython across your organization
2. Identify GitPython versions currently deployed (check pip list, requirements.txt, poetry.lock files)
3. Isolate or restrict network access to systems running vulnerable GitPython versions
PATCHING GUIDANCE:
1. Upgrade GitPython to version 3.1.48 or later immediately: pip install --upgrade gitpython>=3.1.48
2. Update all dependent applications and services that rely on GitPython
3. Test patches in development environment before production deployment
4. Implement automated dependency scanning to prevent future vulnerable versions
COMPENSATING CONTROLS (if immediate patching not possible):
1. Restrict GitPython operations to trusted users only
2. Implement strict file system permissions on repository directories
3. Monitor and log all GitPython reference operations
4. Use SELinux or AppArmor to restrict file system access
5. Disable untrusted reference creation/modification operations
DETECTION RULES:
1. Monitor for unusual file modifications outside .git directories in repositories
2. Alert on GitPython operations with path traversal patterns (../, ..\)
3. Log and review all reference creation, rename, and delete operations
4. Implement file integrity monitoring on critical repository files
5. Monitor process execution of git commands with suspicious arguments
الإجراءات الفورية:
1. قم بحصر جميع الأنظمة والتطبيقات التي تستخدم GitPython في مؤسستك
2. حدد إصدارات GitPython المنتشرة حالياً (تحقق من pip list و requirements.txt و poetry.lock)
3. عزل أو تقييد الوصول إلى الشبكة للأنظمة التي تقوم بتشغيل إصدارات GitPython الضعيفة
إرشادات التصحيح:
1. قم بترقية GitPython إلى الإصدار 3.1.48 أو أحدث فوراً: pip install --upgrade gitpython>=3.1.48
2. قم بتحديث جميع التطبيقات والخدمات التابعة التي تعتمد على GitPython
3. اختبر التصحيحات في بيئة التطوير قبل نشرها في الإنتاج
4. تنفيذ المسح التلقائي للتبعيات لمنع الإصدارات الضعيفة في المستقبل
الضوابط البديلة (إذا لم يكن التصحيح الفوري ممكناً):
1. تقييد عمليات GitPython للمستخدمين الموثوقين فقط
2. تنفيذ أذونات نظام الملفات الصارمة على دلائل المستودع
3. مراقبة وتسجيل جميع عمليات المرجع في GitPython
4. استخدام SELinux أو AppArmor لتقييد الوصول إلى نظام الملفات
5. تعطيل عمليات إنشاء/تعديل المراجع غير الموثوقة
قواعد الكشف:
1. مراقبة تعديلات الملفات غير العادية خارج دلائل .git في المستودعات
2. تنبيهات على عمليات GitPython بأنماط اجتياز المسار (../ و ..\)
3. تسجيل ومراجعة جميع عمليات إنشاء وإعادة تسمية وحذف المراجع
4. تنفيذ مراقبة سلامة الملفات على ملفات المستودع الحرجة
5. مراقبة تنفيذ أوامر git بحجج مريبة