/

CVE-2026-44243

Severity:

HIGH RISK

(7.1)

Path Traversal / Directory Traversal in GitPython

CVE-2026-44243

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write/Overwrite/Delete Outside Intended Directory

Severity:

HIGH RISK

(7.1)

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 prior to 3.1.48 insufficiently validate reference paths when creating, renaming, or deleting Git references.

An attacker who can supply crafted reference names to an application using GitPython may cause files to be written, moved, or deleted outside the repository's .git directory, potentially impacting arbitrary paths on the host filesystem.

Affected context

This vulnerability affects applications that embed GitPython and accept user-controlled or partially untrusted input for reference-related operations (such as creating, renaming, or deleting branches, tags, or other refs).

The risk is highest when:

  • The application exposes Git reference manipulation via APIs, web forms, CLIs, or automation workflows.
  • Reference names are not strictly validated to a safe subset before being passed to GitPython.
  • The GitPython process runs with permissions that allow file operations outside the repository's .git directory.

Exploit preconditions

  • Attack surface: Any interface (web, CLI, API, automation) that uses GitPython to create, rename, or delete references based on attacker-influenced input.
  • Required access: Ability to supply or manipulate reference paths (e.g., branch/tag names, custom ref paths) passed to GitPython.
  • Trigger point: Invocation of GitPython APIs that perform reference creation, rename, or delete operations using the crafted reference path.
  • Why exploitation is possible: GitPython does not adequately normalize and restrict reference paths to stay within the repository's .git directory, allowing path traversal sequences or crafted paths that escape the intended directory and affect arbitrary files.

Why this happens

The root cause is insufficient validation and normalization of filesystem paths derived from logical Git references.

When reference names are mapped to paths within the .git directory, the implementation does not robustly prevent directory traversal (e.g., via ../ segments or equivalent constructs) or disallow unsafe characters and patterns.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where an application uses untrusted input to construct file paths without enforcing confinement to a specific directory root, enabling read/write/move/delete operations outside the expected scope.

Potential impact

  • Arbitrary file creation outside the repository's .git directory.
  • Overwrite of existing files on the host filesystem that the GitPython process can access.
  • Deletion or movement of arbitrary files, potentially impacting application availability.
  • Tampering with application configuration, logs, or data files, which could be used to escalate impact in combination with other weaknesses.
  • Interference with CI/CD pipelines or build environments that rely on GitPython, leading to corrupted artifacts or builds.

General mitigation guidance

Effective mitigation focuses on strictly constraining how reference names are accepted and translated into file paths, and on limiting the privileges of the GitPython runtime:

  • Treat all externally influenced reference names as untrusted and validate them against a strict, allowlisted pattern (for example, only alphanumeric, limited punctuation, and no path separators).
  • Normalize and confine reference paths to the repository's .git directory, rejecting any input that attempts to traverse directories, use absolute paths, or reference unexpected locations.
  • Introduce abstraction layers that never pass raw user input directly to GitPython reference APIs; instead, map user choices to server-side canonical ref identifiers.
  • Run services that use GitPython with least-privilege filesystem access, ensuring they cannot modify sensitive directories or files even if path validation fails.
  • Apply defense-in-depth by isolating Git operations (e.g., via containers, chroot, or restricted service accounts) so that any filesystem impact is contained.

How teams detect issues like this

Detection approaches can focus on reviewing both code and runtime behavior:

  • Static analysis and code review:
  • Search for calls into GitPython reference APIs (e.g., create, rename, delete) where arguments are derived from request parameters, environment variables, or other untrusted sources.
  • Flag string concatenation or interpolation used to build reference names or paths without centralized validation.
  • Enforce coding guidelines that require reference name normalization utilities and disallow direct use of raw user input in GitPython calls.
  • Policy and automated review:
  • Configure automated code scanning tools to detect directory traversal patterns and unsafe path constructions in modules that interact with GitPython.
  • Add pre-merge checks that prevent new code from bypassing existing validation helpers for reference manipulation.
  • Runtime and log-based detection:
  • Monitor logs for unexpected reference names containing path separators, .., or unusual characters.
  • Instrument GitPython usage or filesystem access auditing to detect writes or deletes outside of the expected repository directories.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/releases/tag/3.1.48
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-7545-fcxq-7j24

Frequently asked

questions

It can be remotely exploitable if an application exposes GitPython reference operations through a network-facing interface (such as an API or web UI) and passes user-controlled reference names directly to GitPython without sufficient validation.

An attacker must be able to influence or supply reference paths used by GitPython, such as branch or tag names in operations that create, rename, or delete references. They also need the GitPython process to have filesystem permissions over the target paths they wish to affect.

Centralize and strictly validate all reference names before they reach GitPython, using a tight allowlist of permitted characters and structures, and ensure all computed paths are confined to the repository's .git directory. Avoid passing raw, untrusted strings directly to reference-related APIs.

Adopt a defensive design for all file-path-related code: always treat external input as untrusted, normalize and resolve paths before use, confirm that resolved paths stay within an expected base directory, and enforce these rules via shared utilities, code review checklists, and automated static analysis.

Find out what's already
exploitable in your codebase.