GitPython, Path Traversal / Arbitrary Git Directory Creation, CVE-2026-XXXXX (Pending) -DC-Sep2026-2256

Listen to this Post

This vulnerability arises from a critical omission in GitPython’s denylist for unsafe `git clone` options. The `Repo.clone_from()` and `Repo.clone()` APIs allow arbitrary keyword arguments to be forwarded to the underlying `git clone` command. To prevent security risks, GitPython maintains a denylist, unsafe_git_clone_options, which is checked via Git.check_unsafe_options(). By default, `allow_unsafe_options` is False, meaning these unsafe options should be blocked.
The flaw exists because the `–separate-git-dir=` option is included in the denylist for `Repo.init()` (unsafe_git_init_options) but is completely missing from unsafe_git_clone_options. This is contradictory, as both `git init` and `git clone` accept this option, and the function’s own docstring explicitly lists `–separate-git-dir` as an option that `allow_unsafe_options=False` is supposed to block.
An attacker can exploit this by passing a `separate_git_dir=…` keyword argument into `Repo.clone_from()` or Repo.clone(). GitPython will render this as `–separate-git-dir=` on the command line. Since `–separate-git-dir` is not in the denylist, `Git.check_unsafe_options()` will not raise an UnsafeOptionError. The `git clone` command then executes, creating the entire Git metadata directory (including config, hooks, objects, refs, etc.) at the attacker-controlled path.
This allows arbitrary directory and file creation outside the intended clone destination, limited only by the filesystem permissions of the process. The impact is severe: an attacker can plant a Git repository structure (including a `hooks/` directory) at a chosen location. If this location collides with an existing directory, it can silently overwrite critical files like config, HEAD, and hooks/. Combined with later Git operations on that directory, this can escalate to remote code execution (RCE) through hook execution, matching the impact class of previously published high-severity CVEs.

DailyCVE Form:

Platform: GitPython
Version: 3.1.58 (HEAD)
Vulnerability : Path Traversal
Severity: High
date: 2026-08-05

Prediction: 2026-08-12

What Undercode Say:

Vulnerability Check
PYTHONPATH="<repo>:<repo>/gitdb:<repo>/smmap" python3 gitpython-001-poc.py /tmp/gitpython-001-poc
PoC Snippet (from )
import git
repo = git.Repo.clone_from(src, dest, separate_git_dir=target_gitdir)

Exploit: (Educational Purposes!)

To exploit, an attacker would need to influence the `separate_git_dir` keyword argument passed to `Repo.clone_from()` or `Repo.clone()` in a vulnerable application. The following steps outline the exploitation process:
1. Identify a target application that accepts user-controlled input to configure a `git clone` operation using GitPython.

2. Inject a `separate_git_dir=/path/controlled/by/attacker` argument.

  1. The application, with `allow_unsafe_options` left at its default False, will not block the option.
  2. GitPython will execute git clone --separate-git-dir=/path/controlled/by/attacker -- <url> <dest>.
  3. The attacker’s specified path will now contain the full Git metadata of the cloned repository, potentially overwriting existing files or planting malicious hooks.

Protection:

The primary protection is to immediately patch the application by updating GitPython to a version where this issue has been fixed. The fix involves adding `”–separate-git-dir”` to the `unsafe_git_clone_options` list in git/repo/base.py. As a workaround, applications should not accept user-controlled values for `separate_git_dir` or should manually validate and sanitize any such input before passing it to GitPython’s API.

Impact:

  • Arbitrary directory creation at an attacker-controlled path, enabling filesystem manipulation outside the intended sandbox.
  • Potential for integrity violation by overwriting existing Git metadata in shared or predictable locations.
  • Escalation to Remote Code Execution (RCE) if the attacker-planted Git directory is later used by the system, leading to execution of malicious hooks.

🎯Let’s Practice Exploiting & Learn Patching For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top