Junglewise Threat Intelligence

CVE-2026-78676: GitPython config parser multi-line value injection in write

CVE-2026-78676 · Severity: critical · CVSS 9.8 · Published 2026-09-08

Executive brief

GitPython's configuration file parser incorrectly re-serializes multi-line git config values when writing back to disk, converting legitimately-encoded dormant values into active configuration directives. An attacker can pre-position a malicious value in a repository's git config file (or via the standard git include mechanism) that becomes a live `core.hooksPath` directive after any unrelated GitPython write operation, leading to arbitrary code execution when git invokes hooks during commit, checkout, or other operations.

Technical details

The vulnerability is a read-then-corrupt-on-rewrite defect in git/config.py's GitConfigParser class. When reading config files, GitConfigParser._read() correctly decodes standard git multi-line syntax (backslash-continuation with escaped newlines) via string_decode() (line 460), converting escape sequences like `\n` into real embedded newlines in memory—this is legitimate and mirrors git's own behavior. However, when flushing the parser via _write()/write_section() (lines 694–712), the code uses the unsafe _value_to_string() path (not _value_to_string_safe()) and "handles" embedded newlines with a bare `.replace("\n", "\n\t")`, emitting an unquoted real newline followed by a tab. Real git does not recognize indentation-only continuation; a value only continues across lines if the prior line ends in a literal backslash. Thus, when GitPython re-serializes a multi-line value this way, the second "line" becomes an independent config entry on re-parse. If that dormant value contains `<anything>\nhooksPath = <attacker-path>`, it becomes a live core.hooksPath directive after one write, executing arbitrary hooks. The root cause is asymmetric: earlier fixes (c417af46, PR #2176) added UNSAFE_CONFIG_CHARS_RE guards to all setter-argument entry points but explicitly did not address values already resident in _sections via _read(). Exploitation requires only an attacker-influenced config file plus one ordinary config write—no unsafe caller argument is needed. Attack vector is network/local depending on how the config file is obtained; preconditions include read-write access to the parser and a dormant payload in the file.

Affected products

  • GitPython Developers GitPython <= 3.1.58

Timeline

  • 2026-08-10: disclosed
  • 2026-09-08: advisory
  • 2026-09-08: kev added

References