GitPython config_writer().set_value() Newline Injection RCE
A newline injection vulnerability in GitPython's `config_writer().set_value()` function enables remote code execution by manipulating the `core.hooksPath` Git configuration.
A newline injection vulnerability exists in GitPython’s config_writer().set_value() function, allowing attackers to achieve remote code execution. The vulnerability occurs because set_value() does not validate for newlines before passing values to Python’s configparser. GitPython’s writer converts embedded newlines into continuation lines, which Git still interprets as valid configuration. An attacker can inject a core.hooksPath configuration, causing Git to execute scripts from an attacker-controlled path whenever hooks are invoked. Discovered during an audit of MLRun’s project.push() method, the vulnerability is triggered when author_name or author_email are passed to config_writer().set_value() without sanitization. This affects GitPython versions up to 3.1.48, git 2.39+.
Attack Chain
- An attacker crafts a malicious input string containing a newline character followed by a
[core]section andhooksPathsetting. - The malicious string is passed as either the
author_nameorauthor_emailparameter to an application using GitPython. - The application calls
config_writer().set_value()with the attacker-controlled input, writing the malicious configuration to the.git/configfile. - GitPython converts the embedded newline into an indented continuation line but still writes it to the config.
- Git interprets the injected
[core]stanza as a valid section header, thus setting thecore.hooksPathto the attacker-specified path. - A Git operation that invokes hooks (e.g., commit, merge, checkout) is triggered.
- Git executes the scripts located in the attacker-controlled
hooksPath. - The attacker gains arbitrary code execution on the system.
Impact
Successful exploitation leads to persistent repository configuration poisoning. In multi-user environments, one user can poison a shared repository’s .git/config, causing the attacker’s hooks to run during subsequent Git operations by other users. The impact on single-user deployments depends on whether the application automatically invokes Git hooks. This vulnerability, now identified as CVE-2026-44244, can lead to privilege escalation and arbitrary code execution.
Recommendation
- Deploy the Sigma rule
Detect Git config hooksPath modificationto identify attempts to modify thecore.hooksPathsetting in the.git/configfile. - Audit all calls to
config_writer().set_value()in your codebase, especially where user-supplied input is used, as suggested in the overview. - Upgrade to a patched version of GitPython that raises an error on CR, LF, or NUL in config values, as described in the remediation section.
- Monitor process creation events for the execution of scripts from unusual or unexpected paths specified in the
core.hooksPathusing the ruleSuspicious Git Hook Execution.
Detection coverage 2
Detect Git config hooksPath modification
highDetects attempts to modify the core.hooksPath setting in the .git/config file, which can lead to arbitrary code execution.
Suspicious Git Hook Execution
highDetects execution of git hooks from unusual or attacker controlled locations.
Detection queries are kept inside the platform. Get full rules →