Executive brief
GitPython is a library that manages Git repositories programmatically. When updating Git submodules from an untrusted .gitmodules file, the library fails to validate the path field, allowing attackers to create directories outside the repository and populate them with submodule content. This attack requires a specific application pattern where submodules are updated at historical commits rather than the latest version.
Technical details
The vulnerability is a path traversal in the Submodule.update() method (CWE-22). While GitPython's _to_relative_path() containment guard is correctly applied in add() and move(), the update() method reads the path field directly from .gitmodules without validation, passing it unguarded to os.makedirs() at the absolute checkout location. Exploitation requires application code that explicitly updates submodules at non-HEAD commits; the standard clone-then-update flow is unaffected because it re-derives the path from canonical tree data rather than the untrusted .gitmodules file.
Affected products
- GitPython GitPython before 3.1.62
Timeline
- 2026-09-26: disclosed
- 2026-09-26: patched: Fixed in GitPython 3.1.62