CVE-2023-40267
📋 TL;DR
GitPython before version 3.1.32 contains an incomplete fix for CVE-2022-24439, allowing insecure non-multi options in clone and clone_from operations. This vulnerability could allow attackers to execute arbitrary code or manipulate git operations when cloning from untrusted repositories. Anyone using vulnerable GitPython versions in applications that clone repositories is affected.
💻 Affected Systems
- GitPython
📦 What is this software?
Gitpython by Gitpython Project
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise when cloning from malicious repositories
Likely Case
Arbitrary file write/read, git repository manipulation, or limited code execution depending on application context
If Mitigated
No impact if patched or if applications only clone from trusted sources with proper input validation
🎯 Exploit Status
Exploitation requires tricking users/applications into cloning malicious repositories
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 3.1.32 and later
Vendor Advisory: https://github.com/gitpython-developers/GitPython/security/advisories
Restart Required: No
Instructions:
1. Update GitPython: pip install --upgrade GitPython>=3.1.32
2. Verify installation: pip show GitPython
3. Test clone operations in your application
🔧 Temporary Workarounds
Validate repository URLs
allOnly allow cloning from trusted, whitelisted repository sources
Use multi-option clones
allForce use of multi-options in clone operations which are not vulnerable
🧯 If You Can't Patch
- Implement strict input validation for all repository URLs before passing to GitPython
- Run GitPython in isolated containers or sandboxes with minimal privileges
🔍 How to Verify
Check if Vulnerable:
Check GitPython version: python -c "import git; print(git.__version__)"
Check Version:
python -c "import git; print(git.__version__)" or pip show GitPython
Verify Fix Applied:
Verify version is 3.1.32 or higher and test clone operations with known safe repositories
📡 Detection & Monitoring
Log Indicators:
- Unexpected git clone operations
- Clone attempts from unusual repository URLs
- Errors in git operations
Network Indicators:
- Git protocol traffic to unexpected domains
- SSH git operations to unknown hosts
SIEM Query:
Search for process executions containing 'git clone' with suspicious URLs or from untrusted sources
🔗 References
- https://github.com/gitpython-developers/GitPython/commit/ca965ecc81853bca7675261729143f54e5bf4cdd
- https://github.com/gitpython-developers/GitPython/pull/1609
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AV5DV7GBLMOZT7U3Q4TDOJO5R6G3V6GH/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/PF6AXUTC5BO7L2SBJMCVKJSPKWY52I5R/
- https://github.com/gitpython-developers/GitPython/commit/ca965ecc81853bca7675261729143f54e5bf4cdd
- https://github.com/gitpython-developers/GitPython/pull/1609
- https://lists.debian.org/debian-lts-announce/2024/10/msg00030.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AV5DV7GBLMOZT7U3Q4TDOJO5R6G3V6GH/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/PF6AXUTC5BO7L2SBJMCVKJSPKWY52I5R/