/

CVE-2026-76222

Severity:

HIGH RISK

(8.2)

Path Traversal (CWE-22) in GitPython Submodule Clone

CVE-2026-76222

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary Filesystem Write and Repository Creation

Severity:

HIGH RISK

(8.2)

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

A path traversal vulnerability in GitPython allows malicious repository metadata to direct submodule initialization outside the intended clone directory. If an attacker can cause a vulnerable application to process a crafted repository, GitPython may create attacker-controlled Git repositories at arbitrary filesystem locations.

Affected context

The vulnerability occurs in applications that use GitPython versions before 3.1.58 to clone or initialize repositories containing submodules. It becomes risky when repository content, including .gitmodules data, is obtained from an untrusted source and the process has filesystem permissions beyond the intended working directory.

Exploit preconditions

  • Attack surface: Git repository cloning or submodule initialization through GitPython
  • Required access: Ability to provide or influence a repository processed by the application
  • Trigger point: Submodule name handling during repository initialization
  • Why exploitation is possible: Submodule names are not sufficiently validated before being used to construct filesystem paths, allowing traversal outside the expected clone directory

Why this happens

The underlying bug is insufficient canonicalization and boundary validation of filesystem paths derived from untrusted submodule names. GitPython processes repository metadata without reliably ensuring that the resulting submodule path remains beneath the intended clone directory. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.

Potential impact

  • Attacker-controlled Git repositories may be created outside the intended working directory
  • Sensitive files or directories may be overwritten if process permissions allow it
  • Application data or source code may be modified
  • Subsequent automation could execute or trust content from an unexpected filesystem location
  • Repository integrity and build or deployment workflows could be compromised

General mitigation guidance

Mitigation generally focuses on enforcing filesystem containment for every path derived from repository metadata.

Common defensive patterns include:

  • Resolving candidate paths and verifying that they remain beneath an approved clone directory
  • Rejecting absolute paths, traversal components, and ambiguous path representations
  • Treating .gitmodules and other repository metadata as untrusted input
  • Restricting the process to a dedicated, least-privilege workspace
  • Using isolated temporary directories and limiting filesystem write permissions
  • Applying security checks before creating directories or repositories
  • Keeping dependency versions within a supported range that includes path-validation fixes

How teams detect issues like this

Organizations can detect this class of issue through:

  • Static analysis rules for filesystem paths assembled from repository or archive metadata
  • Code review checks for missing canonicalization and containment validation
  • Tests using path inputs that resolve outside the designated workspace
  • Runtime monitoring for repository creation or directory writes outside approved clone roots
  • CI policy checks that flag vulnerable dependency ranges and untrusted repository-processing flows
  • Automated dependency and code review tools that identify unsafe path-handling patterns

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-hmq2-w58f-27jc
vulncheck.comvulncheck.com/advisories/gitpython-before-path-traversal-via-gitmodules-submodule-name

Frequently asked

questions

It can be exploitable through a remote or untrusted repository-processing workflow when an application accepts repositories supplied by users, services, or external integrations. It is not necessarily remotely exploitable in deployments that process only trusted repositories.

An attacker generally needs the ability to provide or influence a repository containing malicious submodule metadata. The resulting impact also depends on the filesystem permissions of the GitPython process.

Validate every derived path after normalization and require it to remain within a dedicated, approved clone directory before creating or writing anything.

Treat repository metadata as untrusted input, use least-privilege isolated workspaces, test path containment at security boundaries, and enforce dependency and static-analysis policies for path-handling code.

Find out what's already
exploitable in your codebase.