# CVE-2026-78677: GitPython before 3.1.59 Path Traversal via separate-git-dir

The Markdown version of <https://upatch.dev/cve/CVE-2026-78677>. Last updated 25 Nov 2026.

## At a glance

CVE-2026-78677 is rated High 8.7 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X). It affects GitPython (gitpython-developers) and was published on 25 Aug 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.7%: the estimated chance it is exploited in the next 30 days, as of 24 Nov 2026. The upatch `cve-2026-78677-git-block` mitigates it, and is vetted (merged into the registry).

A upatch is a signed BPF program that shirudo loads into a running Linux kernel to block the code path this CVE's exploit takes. It holds the line until the fix ships; it does not replace patching.

## The vulnerability

CVE-2026-78677 (`GHSA-8mcc-hrx5-hvxc`) is a path traversal and arbitrary directory creation flaw in GitPython before 3.1.59, published in August 2026. `Repo.unsafe_git_init_options` in `git/repo/base.py` listed `--separate-git-dir`, whereas `Repo.unsafe_git_clone_options` omitted it. When a service passes user-controlled options to `Repo.clone_from()` or `Repo.clone()`, an attacker can supply `separate_git_dir` (even with `allow_unsafe_options=False`), causing GitPython to spawn `git clone` with `--separate-git-dir=<path>` and write repository metadata and a `hooks/` directory to an arbitrary filesystem path outside the clone destination.

### Official description

GitPython before 3.1.59 omits --separate-git-dir from unsafe_git_clone_options, allowing attackers to create arbitrary git directories outside the intended clone destination. Attackers can pass a separate_git_dir parameter to Repo.clone_from() or Repo.clone() to redirect repository metadata to an attacker-controlled filesystem path, enabling arbitrary directory creation and potential hook execution.

## What the upatch does

Two BPF programs work together using a `BPF_MAP_TYPE_TASK_STORAGE` map (`flagged_tasks`) so argument inspection happens in the caller's address space before `execve` switches `mm` and enforcement happens on the resolved target executable at the LSM hook:

| Hook                      | Role                                                                                                                                                                                                                                                       |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tp_btf/sys_enter`        | On `execve` (59) and `execveat` (322) from a task whose `mm->exe_file` dentry name starts with `python`, scans up to 15 argument strings in `argv` and marks `flagged_tasks` when an argument is `--separate-git-dir` or starts with `--separate-git-dir=` |
| `lsm/bprm_check_security` | Clears the task's `flagged_tasks` entry and returns `-EPERM` when the target binary (`bprm->file`) is named `git`                                                                                                                                          |

Refusals are counted in the `refused` per-CPU array map.

The policy: [`cve-2026-78677-git-block.bpf.c`](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-78677), 149 lines of BPF C attached at `tp_btf/sys_enter` and `lsm/bprm_check_security`, licensed GPL-2.0 OR BSD-2-Clause.

## Side effects

- Any `git` command spawned by a `python*` process that passes `--separate-git-dir` in its first 15 arguments fails with `EPERM` (`PermissionError: [Errno 1] Operation not permitted`), matching GitPython 3.1.59's refusal of that option during clone.
- Normal `git clone`, `git init`, `git fetch` and other `git` operations from Python that do not pass `--separate-git-dir` continue to work.
- `git` commands run from shells or non-Python programs are untouched.

## Preemption model and cost

Each task sets and consumes its own `BPF_MAP_TYPE_TASK_STORAGE` entry synchronously during its own `execve` system call, and the refusal counter is updated in a per-CPU array with an atomic add, so the upatch is safe under every preemption model including preemptible RCU and `PREEMPT_RT`. On non-`execve` syscalls `tp_btf/sys_enter` checks only the syscall number and returns immediately; on `execve` by non-Python processes it checks only the caller's executable dentry name prefix; and `lsm/bprm_check_security` does a single task-storage lookup when no flag is set.

## Affected versions

GitPython:

| Package     | Affected    | Fixed in |
| ----------- | ----------- | -------- |
| `GitPython` | `<= 3.1.58` | `3.1.59` |

Affected kernels: not a kernel vulnerability; the upatch runs on x86_64 Linux kernels with BPF LSM, BTF and `BPF_MAP_TYPE_TASK_STORAGE`.

## How it was tested

On a loopback HTTP service running GitPython 3.1.58, the loaded upatch refused git clone executions carrying --separate-git-dir while leaving normal clones working.

- **Tested:** 25 Nov 2026
- **Target:** GitPython 3.1.58 clone HTTP service on loopback
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64

### Results

| State           | Clone with separate_git_dir blocked | Normal clone works |
| --------------- | ----------------------------------- | ------------------ |
| Before loading  | no                                  | yes                |
| Upatch loaded   | yes                                 | yes                |
| After unloading | no                                  | yes                |

## How to apply

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign:

```sh
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-78677
```

Publish and roll out:

```sh
shirudo bpm push build/packages/cve-2026-78677-1.0.0.bee oci://<registry>/<namespace>/cve-2026-78677 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-78677-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>
```

## Review

- Contributors: romanlab.
- Reviewers: none recorded yet.

## Sources and links

- [CVE-2026-78677 record (CVE API)](https://cveawg.mitre.org/api/cve/CVE-2026-78677)
- [GitHub Security Advisory GHSA-8mcc-hrx5-hvxc](https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-8mcc-hrx5-hvxc)
- [VulnCheck advisory for CVE-2026-78677](https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-separate-git-dir)
- [Fix commit b68afff45af0 (PR #2210)](https://github.com/gitpython-developers/GitPython/commit/b68afff45af0f49e79a3e2d2162018986b37ad5d)
- [GitPython 3.1.59 release](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.59)

### Links

- [CVE-2026-78677 on upatch.dev](https://upatch.dev/cve/CVE-2026-78677) (this page, as HTML)
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-78677)
- [CVE.org](https://www.cve.org/CVERecord?id=CVE-2026-78677)
- [CWE-22](https://cwe.mitre.org/data/definitions/22.html)
- Upatch source: [upatches/cve-2026-78677](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-78677)

### More references from NVD (1)

- [vulncheck.com](https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-separate-git-dir) (Third Party Advisory)
