# PYSEC-2026-3982: GitPython before 3.1.60 fails to properly validate the git directory location, allowing attackers to impersonate the git directory using tracked files like gitdir, commondir, and HEAD

- Database: PyPA
- Published: 2026-09-09
- Modified: 2026-09-17

## Tracked as

- [CVE-2026-87817](https://cve.now/CVE-2026-87817.md): GitPython before 3.1.60 Remote Code Execution via Git Directory Impersonation

## Also published as

- [GHSA-239G-WHFQ-7XJ9](https://cve.now/GHSA-239G-WHFQ-7XJ9.md) (GitHub)

## Affected versions

- gitpython (PyPI): fixed in 3.1.60

## Description

GitPython before 3.1.60 fails to properly validate the git directory location, allowing attackers to impersonate the git directory using tracked files like gitdir, commondir, and HEAD. Attackers can execute arbitrary code by placing a malicious pre-commit hook in the tracked hooks directory that executes when a victim calls index.commit() on a cloned or opened repository.

## References

- https://www.vulncheck.com/advisories/gitpython-before-3.1.60-remote-code-execution-via-git-directory-impersonation
- https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-239g-whfq-7xj9

Page: https://cve.now/PYSEC-2026-3982

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
