CVE-2026-76221 in GitPython
Summary
by MITRE • 08/19/2026
GitPython before 3.1.58 contains a config-name injection vulnerability in the option-name validator that allows attackers to forge arbitrary git-config directives by injecting equals signs, hash symbols, and whitespace into option names. Attackers can inject malicious option names like 'sshCommand = touch /tmp/RCE #' to execute arbitrary commands via core.sshCommand or core.hooksPath on the next git operation.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 08/20/2026
GitPython versions prior to 3.1.58 are susceptible to a critical configuration injection vulnerability stemming from insufficient validation of option names within its internal config parser. This flaw allows an attacker who can influence the input passed to GitPython's configuration handling mechanisms to inject arbitrary git-config directives into the repository or global configuration files. The root cause lies in the lack of strict sanitization for special characters such as equals signs, hash symbols, and whitespace when validating option names. By exploiting this weakness, malicious actors can bypass intended security boundaries and manipulate how Git interprets subsequent commands, effectively turning a standard version control operation into a vector for remote code execution or system compromise.
The technical mechanism of the attack relies on the structure of git-config files, which use key-value pairs separated by equals signs. When an attacker injects characters like '=' or '#' into an option name field, they can artificially create new configuration entries that Git will process during its next operation. For instance, injecting a payload such as 'sshCommand = touch /tmp/RCE #' results in the creation of a core.sshCommand directive with the value 'touch /tmp/RCE'. The hash symbol serves to comment out any trailing malicious content or noise, ensuring the configuration remains syntactically valid while achieving the desired side effect. This manipulation is particularly dangerous because it does not require direct shell access; instead, it exploits the trust Git places in its own configuration files when executing commands that interact with external systems or hooks.
The operational impact of this vulnerability is severe, as it can lead to arbitrary command execution on the target system under the context of the user running the git operation. If an application uses GitPython to handle untrusted repository data or allows users to specify custom option names without proper validation, an attacker could force the execution of malicious scripts via core.hooksPath or execute commands through SSH by manipulating core.sshCommand. This can result in full system compromise, data exfiltration, or lateral movement within a network if the compromised host is used as a pivot point. The vulnerability affects any environment where GitPython processes configuration inputs derived from untrusted sources, including CI/CD pipelines, web applications interacting with git repositories, and automated development tools that parse user-supplied metadata.
This issue aligns with CWE-94 Improper Control of Generation of Code (Code Injection) as it involves the injection of executable commands through misconfigured parameters. In terms of MITRE ATT&CK framework, this vulnerability facilitates techniques related to Command and Scripting Interpreter abuse, specifically allowing attackers to execute arbitrary code via system utilities or hooks without direct shell access. The attack vector is often classified under Input Validation flaws, where insufficient sanitization allows malicious payloads to be interpreted as legitimate configuration directives.
To mitigate this risk, organizations must immediately upgrade GitPython to version 3.1.58 or later, which includes patches for the option-name validator that strictly enforce allowed character sets and prevent injection of structural delimiters like equals signs and hashes into key names. Developers should also implement defense-in-depth strategies by validating all user-supplied input against a whitelist of acceptable characters before passing them to any git-related functions. Additionally, auditing existing codebases for instances where GitPython configuration options are dynamically constructed from external inputs is crucial. Ensuring that the execution context has minimal privileges can further reduce the blast radius in case of future vulnerabilities or successful exploitation attempts.