GitPython versions up to 3.1.57 contain a vulnerability in the IndexFile.from_tree, reset, and merge_tree methods where unguarded forwarding of treeish arguments to git read-tree allows an attacker to overwrite arbitrary files with a valid git-index blob. This occurs because the methods do not guard against unsafe options or use a '--' separator, enabling injection of the --index-output option to specify an arbitrary output path. The impact is arbitrary file overwrite at the privileges of the host process, potentially destroying important files. A fix is available in version 2.4.5_4.
GitPython versions up to 3.1.53 contain a vulnerability in the check_unsafe_options guard that can be bypassed by smuggling an unsafe git option token inside the value of a single-character keyword argument. This bypass enables arbitrary OS command execution via the --upload-pack option in all guarded methods such as clone, fetch, pull, and others. The flaw arises because the guard only inspects option keys, not values, allowing crafted values to inject unsafe commands. A proof of concept demonstrates file creation via this method. A fix is available in versions after 3.1.53.
GitPython's Diffable.diff() method improperly forwards user-supplied arguments to git diff commands without validating unsafe options. This allows an attacker to inject the '--output' argument, causing git to overwrite arbitrary files with diff content at the process privilege level. The vulnerability affects versions up to and including 3.1.53. A fix is available that adds validation to prevent unsafe options or changes argument ordering to block option injection.
GitPython versions prior to 2.4.5_2 have a vulnerability where environment variables in URLs passed to Repo.create_remote() or Remote.add() are expanded and embedded into the repository configuration. This can lead to sensitive environment variables being written into .git/config and transmitted to an attacker-controlled server during fetch or pull operations. The issue arises because the fix for a previous similar vulnerability did not cover these API calls, leaving the default behavior of expanding variables enabled. A patch is available in version 2.4.5_2.
GitPython versions up to 3.1.53 contain a vulnerability in the Commit.count() method where unguarded forwarding of keyword arguments to git rev-list allows an attacker to specify the --output option. This causes git rev-list to truncate an arbitrary file to zero bytes, leading to file destruction. The vulnerability is due to missing safety checks present in sibling methods. The impact is medium since the attacker can only truncate files but not control content, and the method uses a fixed commit SHA limiting reachability.
GitPython versions up to 3.1.53 have an incomplete denylist for unsafe git clone options that omits the --template option. This omission allows an attacker who can influence clone options and stage a malicious post-checkout hook in a directory to achieve arbitrary OS command execution during a git clone operation. The vulnerability requires the attacker to have write access to a directory used as a template containing executable hooks. A fix is available in version 2.4.5_2.
GitPython versions >=0.7.0 and <2.4.5_3 contain vulnerabilities in the IndexFile.checkout() and TagReference.create() methods that allow unguarded forwarding of git command options. This enables arbitrary file overwrite via the --prefix option in git checkout-index and arbitrary file read via the -F/--file option in git tag. Both vulnerabilities allow an attacker with repository write access to influence file system operations outside the repository, potentially leading to code execution or sensitive file disclosure.
GitPython's Repo.archive() method uses an incomplete denylist for unsafe git archive options, omitting --add-file and --add-virtual-file. These options allow an attacker to read arbitrary files from the filesystem or inject attacker-controlled content into archives created by the method. The vulnerability requires the embedding application to forward caller-controlled options to Repo.archive(). It does not allow code execution but enables arbitrary file read at the process privilege level. A fix is available in version 2.4.5_3.
A vulnerability in GitPython's config_writer() allows newline injection in the section parameter, bypassing the patch for CVE-2026-42215. This enables an attacker to inject arbitrary section headers into the .git/config file, including a forged [core] section with hooksPath pointing to an attacker-controlled directory. This leads to remote code execution (RCE) when any git hook is triggered. The issue affects versions >=0.7.0 and <2.4.4_1 and is fixed in version 2.4.4_1.
GitPython version 3.1.50 contains a vulnerability in its handling of unsafe git clone options. The default safety gate blocks unsafe options like --upload-pack and -u unless explicitly allowed, but it fails to recognize joined short-option forms such as -u<helper>. This allows an attacker controlling clone options to bypass the safety check and execute local commands via the upload-pack helper during a clone operation. The issue affects the fdroidserver product versions >=2.4.4_1 and <2.4.5_1. A fix is available in version 2.4.5_1.
GitPython versions from 0.7.0 up to but not including 2.4.5_1 contain command injection vulnerabilities via unguarded Git options in methods such as Repo.archive(), git.ls_remote(), and arbitrary file operations in Repo.iter_commits and Repo.blame. These vulnerabilities allow an attacker to execute arbitrary commands or cause file truncation by passing crafted arguments that bypass internal safety checks. The issue arises because certain keyword arguments are transformed into Git command options without proper validation, enabling injection of malicious commands. The vulnerabilities are fixed in version 2.4.5_1.
GitPython versions up to 3.1.50 contain a vulnerability where the Repo.clone_from() method expands environment variables in the clone URL using os.path.expandvars(). This allows an attacker controlling the URL argument to embed environment variable tokens that get expanded to secret values from the server's environment and sent to an attacker-controlled host. The flaw arises because the URL is expanded without scheme validation before being passed to git clone, leading to secret exfiltration. A fix is available in version 2.4.5_1.
A vulnerability in fdroidserver related to the Paramiko library's rsakey.py component allows the use of the SHA-1 algorithm. This affects versions of fdroidserver prior to 2.4.5_4. The issue is addressed in version 2.4.5_4.
GitPython's config_writer().set_value() method does not validate input values for newline characters, allowing injection of a crafted core.hooksPath configuration. This enables an attacker to specify an arbitrary hooks directory, causing Git to execute attacker-controlled scripts during Git operations that invoke hooks. The vulnerability affects GitPython versions from 0.7.0 up to but not including 2.4.4 and is fixed in version 2.4.4. The issue is particularly impactful in multi-user or shared repository environments where untrusted inputs are passed to set_value().
GitPython versions from 0.7.0 up to but not including 2.4.4 contain a vulnerability in the _clone() method where unsafe option validation is performed on the original multi_options list before it is transformed by shlex.split. This allows an attacker to embed unsafe git clone options such as '--config core.hooksPath=<dir>' within a string that passes validation but is split into multiple options at execution time, enabling execution of attacker-controlled git hooks during cloning or submodule updates.
GitPython in fdroidserver versions from 2.1.2 up to but not including 2.4.4 contains a command injection vulnerability due to improper validation of Python kwargs that bypass the unsafe Git option checks. This allows attacker-controlled input to execute arbitrary commands via Git operations such as clone, fetch, pull, and push. The issue arises because the validation checks raw kwarg names before they are normalized from underscore to dash form, enabling dangerous options like upload_pack and receive_pack to bypass safety checks. A fix is available in version 2.4.4.
GitPython versions up to 3.1.52 contain a vulnerability where attacker-controlled submodule names can inject arbitrary configuration directives into the .git/config file. This occurs because section names are insufficiently sanitized, allowing crafted names to break out of intended config sections and set directives like core.sshCommand, enabling remote code execution on the next git operation. This vulnerability is distinct from prior newline injection issues and affects the handling of section headers without proper escaping.
GitPython versions from 0.7.0 up to but not including 2.4.5_1 contain a command injection vulnerability due to incomplete blocking of unsafe git options. The fix for CVE-2026-42215 implemented in version 3.1.47 blocks dangerous git options by exact matching after normalizing underscores to hyphens, but does not account for git's acceptance of unambiguous long-option prefix abbreviations. This allows attackers controlling keyword argument keys to bypass the blocklist and execute arbitrary commands via git clone, fetch, pull, or push operations. The vulnerability is exploitable when attacker-controlled keys are passed to GitPython calls with unsafe options disallowed (allow_unsafe_options=False). A patch is available in version 2.4.5_1.
A path traversal vulnerability in GitPython allows attackers who can supply crafted reference paths to write, overwrite, move, or delete files outside the repository's .git directory. This occurs due to insufficient validation of reference paths before filesystem write, rename, and delete operations. The vulnerability affects GitPython versions up to 3.1.46 and the current main branch (3.1.47 locally). Exploitation requires the ability to influence reference names passed to GitPython APIs, with no authentication required at the library boundary. The flaw can lead to arbitrary file write and deletion, potentially corrupting application state or causing denial of service.
CVE-2024-22190 is a vulnerability in fdroidserver related to GitPython's handling of untrusted search paths on Windows. It arises from an incomplete fix for a previous issue (CVE-2023-40590). When GitPython runs git commands through a shell or executes hook scripts using bash.exe, it may inadvertently run malicious executables named git.exe or bash.exe located in the current repository directory. This can lead to arbitrary code execution if an attacker places such executables in a repository or working directory. The vulnerability affects fdroidserver versions from 0.7.0 up to but not including 2.2.1_4. A fix is available in version 2.2.1_4.