Executive brief
GitPython, a popular Python library for interacting with Git repositories, is vulnerable to a path traversal flaw when processing submodules. An attacker can create a malicious repository that, when cloned and initialized by a victim, creates and populates a full Git repository at an arbitrary location on the victim's filesystem. This could be used to overwrite sensitive files or establish a foothold in automated environments like CI/CD pipelines and IDEs.
Technical details
GitPython fails to validate the 'name' field of submodules defined in the .gitmodules file. The `sm_name()` function in `util.py` extracts the name without sanitization, which is subsequently used by `Submodule._module_abspath()` to construct a filesystem path using `os.path.join`. Because `os.path.join` does not normalize directory traversal sequences (e.g., `../`), an attacker can provide a malicious name that escapes the repository's working tree. When `submodule_update(init=True)` is called, GitPython uses `os.makedirs()` and `git clone --separate-git-dir` on the manipulated path, resulting in arbitrary directory creation and repository population. This vulnerability is a reimplementation flaw similar to CVE-2018-11235 in core Git. A fix is available in version 3.1.58.
Affected products
- gitpython-developers GitPython <= 3.1.57
Timeline
- 2026-08-04: disclosed
- 2026-08-07: advisory
- 2026-08-07: patched: Fixed in version 3.1.58