CVE-2026-78677
GitPython before 3.1.59 Path Traversal via separate-git-dir
Refuses git executions with --separate-git-dir to mitigate CVE-2026-78677 in GitPython.
High 8.7Vetted
EPSS 0.7%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.
At a glance
CVE-2026-78677 is a high (CVSS 8.7) vulnerability in GitPython, published 25 August 2026. A vetted upatch, cve-2026-78677-git-block, blocks it on running Linux machines with shirudo until GitPython is upgraded.
- Severity
- High 8.7 CVSS 4.0
- Chance of exploitation
- 0.7% in the next 30 days (EPSS, 24 Nov 2026)
- Known exploited
- No, not on CISA’s KEV list
- Weakness
- CWE-22
- Affected software
- GitPython (gitpython-developers)
- Upatch status
- Vetted, merged into the registry
- How to apply
- Build, sign and roll out with shirudo
Overview
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.
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.
Sources
More references from NVD (1)
Mitigation
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.
Side effects
- Any
gitcommand spawned by apython*process that passes--separate-git-dirin its first 15 arguments fails withEPERM(PermissionError: [Errno 1] Operation not permitted), matching GitPython 3.1.59's refusal of that option during clone. - Normal
git clone,git init,git fetchand othergitoperations from Python that do not pass--separate-git-dircontinue to work. gitcommands 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.
The policy
149 lines of BPF C, attached at tp_btf/sys_enter and lsm/bprm_check_security.
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
#define EPERM 1
#define NR_EXECVE 59
#define NR_EXECVEAT 322
#define MAX_ARGS 16
#define OPT_LEN 18
char _license[] SEC("license") = "Dual BSD/GPL";
struct exec_flag {
__u8 deny;
};
struct {
__uint(type, BPF_MAP_TYPE_TASK_STORAGE);
__uint(map_flags, BPF_F_NO_PREALLOC);
__type(key, int);
__type(value, struct exec_flag);
} flagged_tasks SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
__type(value, __u64);
} refused SEC(".maps");
static __always_inline void count_refusal(void)
{
__u32 key = 0;
__u64 *value = bpf_map_lookup_elem(&refused, &key);
if (value)
__sync_fetch_and_add(value, 1);
}
static __always_inline int earlier_verdict(int ret)
{
return ret >= -4095 && ret < 0 ? ret : -EPERM;
}
static __always_inline bool caller_is_python(struct task_struct *task)
{
const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
const unsigned char *name = BPF_CORE_READ(exe, d_name.name);
__u32 len = BPF_CORE_READ(exe, d_name.len);
char buf[6] = {};
if (!exe || len < 6 || !name)
return false;
if (bpf_probe_read_kernel(buf, 6, name))
return false;
return buf[0] == 'p' && buf[1] == 'y' && buf[2] == 't' &&
buf[3] == 'h' && buf[4] == 'o' && buf[5] == 'n';
}
static __always_inline bool is_git_file(const struct file *file)
{
const struct dentry *dentry = BPF_CORE_READ(file, f_path.dentry);
const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
__u32 len = BPF_CORE_READ(dentry, d_name.len);
char buf[4] = {};
if (!dentry || len != 3 || !name)
return false;
if (bpf_probe_read_kernel(buf, 3, name))
return false;
return buf[0] == 'g' && buf[1] == 'i' && buf[2] == 't';
}
static __always_inline bool arg_is_separate_git_dir(const char *argp)
{
const char opt[OPT_LEN + 1] = "--separate-git-dir";
char buf[24] = {};
if (bpf_probe_read_user_str(buf, sizeof(buf), argp) < OPT_LEN + 1)
return false;
for (__u32 i = 0; i < OPT_LEN; i++) {
if (buf[i] != opt[i])
return false;
}
return buf[OPT_LEN] == '\0' || buf[OPT_LEN] == '=';
}
static __always_inline bool argv_has_separate_git_dir(const char *const *argv)
{
const char *argp = NULL;
if (!argv)
return false;
for (__u32 i = 1; i < MAX_ARGS; i++) {
argp = NULL;
if (bpf_probe_read_user(&argp, sizeof(argp), &argv[i]))
break;
if (!argp)
break;
if (arg_is_separate_git_dir(argp))
return true;
}
return false;
}
SEC("tp_btf/sys_enter")
int BPF_PROG(cve_2026_78677_sys_enter, struct pt_regs *regs, long id)
{
struct task_struct *task;
const char *const *argv;
struct exec_flag *flag;
if (id != NR_EXECVE && id != NR_EXECVEAT)
return 0;
task = bpf_get_current_task_btf();
if (!caller_is_python(task))
return 0;
argv = (const char *const *)(id == NR_EXECVE ?
BPF_CORE_READ(regs, si) : BPF_CORE_READ(regs, dx));
if (!argv_has_separate_git_dir(argv))
return 0;
flag = bpf_task_storage_get(&flagged_tasks, task, NULL,
BPF_LOCAL_STORAGE_GET_F_CREATE);
if (flag)
flag->deny = 1;
return 0;
}
SEC("lsm/bprm_check_security")
int BPF_PROG(cve_2026_78677_bprm_check, struct linux_binprm *bprm, int ret)
{
struct task_struct *task = bpf_get_current_task_btf();
struct exec_flag *flag;
if (ret)
return earlier_verdict(ret);
flag = bpf_task_storage_get(&flagged_tasks, task, NULL, 0);
if (!flag)
return 0;
bpf_task_storage_delete(&flagged_tasks, task);
if (!is_git_file(bprm->file))
return 0;
count_refusal();
return -EPERM;
}
The package: name, license, the program and the CVE it fixes.
[package]
name = "cve-2026-78677"
description = "Refuses git executions with --separate-git-dir to mitigate CVE-2026-78677 in GitPython"
license = "GPL-2.0 OR BSD-2-Clause"
[[upatches]]
source = "cve-2026-78677-git-block.bpf.c"
[upatches.tree]
id = "cve-2026-78677-git-block"
fixes = ["CVE-2026-78677"]
Process
How this upatch was written, checked and reviewed, from the registry’s history.
- 25 Aug 2026CVECVE published
- 25 Nov 2026Pull requestPull request #65 openedAdd CVE-2026-78677: Refuses git executions with --separate-git-dir to mitigate CVE-2026-78677 inromanlab
- 25 Nov 2026CIUpdate upatch.devpassed
- 25 Nov 2026CICIpassed
- 25 Nov 2026MergeMerged #65romanlab
- 25 Nov 2026CIUpdate upatch.devcancelled
No human review is recorded on GitHub for this upatch yet.
Evidence
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
| State | Clone with separate_git_dir blocked | Normal clone works |
|---|---|---|
| Before loading | no | yes |
| Upatch loaded | yes | yes |
| After unloading | no | yes |
tools-test.log Output of tools/test --setup before, while and after the upatch was loaded.
tools/test --setup, 2026-11-25T13:53:49Z Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm cve-2026-78677 setup done GITPYTHON_URL=http://127.0.0.1:18677 before reached git clone with separate_git_dir created a separate git directory while normal clone succeeded loaded blocked git clone with --separate-git-dir was refused with EPERM while normal clone succeeded after reached git clone with separate_git_dir created a separate git directory while normal clone succeeded PASS: reached before, blocked while loaded, reached again after
Use it
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.
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-78677shirudo 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>