GitPython before 3.1.62 Path Traversal via gitmodules path
What fixes it
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
GitPython before 3.1.62 does not validate the path field read from an untrusted .gitmodules file when updating submodules. While a prior fix (GHSA-hmq2-w58f-27jc) added Submodule._validated_name() to constrain the name field, and GitPython's own containment guard Submodule._to_relative_path() is applied in add() and move(), Submodule.update() derives the absolute checkout location from the raw path value without that guard. A .gitmodules entry containing directory traversal components (e.g., path = ../../../tmp/escaped) can therefore cause directories to be created via os.makedirs() outside the repository working tree, populated from the submodule URL on the clone path, and removed via shutil.rmtree() when force_remove is used. Exploitation requires an application flow that updates submodules at a non-HEAD commit (such as a historical-commit API); the common clone-then-update flow re-derives the path from a canonical tree lookup and is not affected. The issue is fixed in GitPython 3.1.62.
Text from CVE List
Affected versions 53
- GitPythonaffected: all versions before 3.1.62CVE List
- GitPythonunaffected: 3.1.62CVE List
- gitpython, PyPIfrom first release, fixed in 3.1.62OSV
- gitpython, PyPI0.1.7OSV
- gitpython, PyPI0.2.0-beta1OSV
- gitpython, PyPI0.3.0-beta1OSV
- gitpython, PyPI0.3.0-beta2OSV
- gitpython, PyPI0.3.1-beta2OSV
- gitpython, PyPI0.3.2OSV
- gitpython, PyPI0.3.2.1OSV
- gitpython, PyPI0.3.2.RC1OSV
- gitpython, PyPI0.3.3OSV
- gitpython, PyPI0.3.4OSV
- gitpython, PyPI0.3.5OSV
- gitpython, PyPI0.3.6OSV
- gitpython, PyPI0.3.7OSV
- gitpython, PyPI1.0.0OSV
- gitpython, PyPI1.0.1OSV
- gitpython, PyPI1.0.2OSV
- gitpython, PyPI2.0.0OSV
- gitpython, PyPI2.0.1OSV
- gitpython, PyPI2.0.2OSV
- gitpython, PyPI2.0.3OSV
- gitpython, PyPI2.0.4OSV
- gitpython, PyPI2.0.5OSV
- gitpython, PyPI2.0.6OSV
- gitpython, PyPI2.0.7OSV
- gitpython, PyPI2.0.8OSV
- gitpython, PyPI2.0.9OSV
- gitpython, PyPI2.0.9.dev0OSV
- gitpython, PyPI2.0.9.dev1OSV
- gitpython, PyPI2.1.0OSV
- gitpython, PyPI2.1.1OSV
- gitpython, PyPI2.1.10OSV
- gitpython, PyPI2.1.11OSV
- gitpython, PyPI2.1.12OSV
- gitpython, PyPI2.1.13OSV
- gitpython, PyPI2.1.14OSV
- gitpython, PyPI2.1.15OSV
- gitpython, PyPI2.1.2OSV
- gitpython, PyPI2.1.3OSV
- gitpython, PyPI2.1.4OSV
- gitpython, PyPI2.1.5OSV
- gitpython, PyPI2.1.6OSV
- gitpython, PyPI2.1.7OSV
- gitpython, PyPI2.1.8OSV
- gitpython, PyPI2.1.9OSV
- gitpython, PyPI3.0.0OSV
- gitpython, PyPI3.0.1OSV
- gitpython, PyPI3.0.2OSV
- gitpython, PyPI3.0.3OSV
- gitpython, PyPI3.0.4OSV
- gitpython, PyPI3.0.5OSV