/

CVE-2026-78677

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in GitPython Repository Clone

CVE-2026-78677

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary Directory Creation and Potential Code Execution

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

GitPython versions before 3.1.59 do not adequately restrict the --separate-git-dir clone option, allowing repository metadata to be placed outside the intended clone directory. If an attacker can control the separate_git_dir parameter and influence a process that performs a clone, they may create directories in unintended filesystem locations and potentially enable Git hook execution.

Affected context

The vulnerability occurs in applications that use GitPython's Repo.clone_from() or Repo.clone() APIs and expose, derive, or otherwise trust the separate_git_dir parameter. It is most relevant when the cloning process has filesystem permissions that reach locations outside the expected repository workspace and when subsequent Git operations can process metadata or hooks from the redirected directory.

Exploit preconditions

  • Attack surface: Application code that invokes GitPython repository-cloning APIs
  • Required access: Ability to influence the separate_git_dir value or an equivalent clone configuration
  • Trigger point: Repository cloning with the separate Git directory option
  • Filesystem condition: The running process must have permission to create or modify the selected path
  • Why exploitation is possible: The option is not sufficiently constrained by the unsafe clone-option filtering, allowing repository metadata to be redirected outside the intended destination

Why this happens

The underlying bug is incomplete validation and filtering of a filesystem-affecting Git clone option. GitPython fails to treat --separate-git-dir as an unsafe option requiring restriction, so attacker-influenced input can control where repository metadata is created. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because a user-controlled path can escape the application's intended filesystem boundary.

Potential impact

  • An attacker may create arbitrary directories where the process has write access.
  • Repository metadata may be placed outside the expected clone workspace.
  • Git hooks may execute if later Git operations trust and process the redirected metadata.
  • The affected application account or host may be compromised.
  • Other files or workflows may be impacted through filesystem and repository manipulation.

General mitigation guidance

Mitigation generally focuses on removing attacker control over filesystem destinations and enforcing explicit path boundaries.

Common defensive patterns include:

  • Rejecting or tightly constraining externally supplied separate Git directory paths.
  • Resolving paths and verifying that they remain beneath an approved workspace.
  • Using dedicated, minimally privileged accounts and isolated working directories for repository operations.
  • Disabling or neutralizing Git hook execution when hooks are not required.
  • Treating cloned repositories and their metadata as untrusted content.
  • Applying filesystem permissions, sandboxing, and read-only controls where practical.
  • Validating clone options against an explicit allowlist rather than passing arbitrary options through.

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis rules identifying calls to Repo.clone_from() or Repo.clone() with externally influenced separate_git_dir values.
  • Code review checks for path canonicalization, workspace-boundary validation, and unrestricted clone-option forwarding.
  • Repository and filesystem monitoring for unexpected .git directories or metadata created outside approved clone roots.
  • Runtime policy enforcement that restricts write access for Git-processing services and blocks unapproved hook execution.
  • Automated security review tools that flag user-controlled paths reaching filesystem and repository APIs.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-8mcc-hrx5-hvxc
vulncheck.comvulncheck.com/advisories/gitpython-before-path-traversal-via-separate-git-dir

Frequently asked

questions

It can be exploitable through a remote application interface when that interface allows an attacker to influence the repository clone parameters. The vulnerability is not inherently reachable over the network without an application exposing a suitable cloning operation.

The attacker generally needs control over, or influence on, the separate_git_dir value. The impact also depends on the filesystem permissions of the process performing the clone.

Do not accept arbitrary separate Git directory paths. Enforce canonical path validation against an approved workspace, allow only necessary clone options, and isolate repository operations with least privilege.

Treat all repository paths and clone options as untrusted input, monitor for metadata outside designated directories, restrict Git hook behavior, and use automated checks for path-boundary violations.

Find out what's already
exploitable in your codebase.