GitPython Improper Input Validation Leads to Command Injection
GitPython version 3.1.50 contains an input validation vulnerability that allows attackers to bypass security gates by using joined short-option forms, potentially leading to arbitrary command execution during repository cloning.
GitPython versions prior to 3.1.51 contain an improper input validation vulnerability (CVE-2026-67324) that affects applications using the Repo.clone_from method. The library implements an 'unsafe-option' gate designed to prevent the injection of dangerous Git command-line options when allow_unsafe_options is set to False. However, the parser fails to correctly identify and block joined short-option forms, such as -u<value>, which represent the --upload-pack flag.
An attacker capable of influencing the arguments passed to Repo.clone_from can provide a malicious value for the -u flag, such as -u<malicious_helper_command>. Because the library's security gate does not properly sanitize this joined format, the underlying Git process executes the attacker-supplied command. This vulnerability poses a significant risk to CI/CD pipelines, automated build systems, and any application that uses GitPython to clone untrusted repositories. The issue is resolved in version 3.1.51.
Impact
Successful exploitation allows an attacker to achieve arbitrary OS command execution with the privileges of the application running the GitPython library. This can lead to full system compromise, exfiltration of credentials or source code, and persistence within the affected environment. The vulnerability impacts any infrastructure utilizing GitPython 3.1.50 for automated repository management.
Recommendation
- Upgrade the GitPython library to version 3.1.51 or later immediately across all environments.
- Audit codebases for any use of
Repo.clone_fromwhere input from external sources or untrusted users is used to construct themulti_optionsargument. - Implement strict input validation or allowlisting for repository clone options if upgrading is not immediately feasible.
- Review system logs for unexpected child processes spawned by services executing Git operations, focusing on processes originating from the Python interpreter environment.