Executive brief
GitPython is a popular Python library used to interact with Git repositories. A vulnerability in how it handles command-line options allows an attacker to bypass security checks and inject malicious configuration settings during a repository clone operation. If an application uses GitPython to clone repositories based on user-provided input, an attacker could execute arbitrary code on the system.
Technical details
An argument injection vulnerability exists in GitPython's `_clone()` and `Submodule.update()` functions. The library performs security validation on the `multi_options` list before it is transformed by `shlex.split`. An attacker can provide a single string containing multiple arguments (e.g., '--branch main --config core.hooksPath=/path'); because the validation check only uses `startswith`, it fails to detect the forbidden `--config` flag embedded later in the string. When the string is subsequently split and passed to the Git binary, the injected configuration is applied, allowing the attacker to define malicious hooks that execute arbitrary code during the clone process. This is fixed in version 3.1.47.
Affected products
- gitpython-developers GitPython < 3.1.47
Timeline
- 2026-04-22: disclosed
- 2026-04-25: advisory
- 2026-04-25: patched: Released in version 3.1.47
References
- https://api.github.com/users/Texuguinho1234
- https://github.com/Texuguinho1234
- https://api.github.com/users/Texuguinho1234/gists%7B/gist_id%7D
- https://api.github.com/users/Texuguinho1234/repos
- https://avatars.githubusercontent.com/u/180200014?v=4
- https://api.github.com/users/Texuguinho1234/events%7B/privacy%7D