Path Traversal Vulnerability in GitPython: Potential File Access Risk

python-git Updated 02 Oct 2025

Summary

30/08/2023
N/A
Yes i
Medium
6.5

CVE-2023-41040: GitPython is a python library used to interact with Git repositories. Affects python-git across 4 version ranges.

< 3.1.14-1+deb11u1 < 74e55ee4544867e1bd976b7df5a45869ee397b0b < b27a89f683cda85ebd78243c055e876282df89ee < e98f57b81f792f0f5e18d33ee658ae395f9aa3c4

Fixed in 3.1.14-1+deb11u1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

GitPython is a Python library that facilitates interaction with Git repositories, allowing users to perform Git operations programmatically. It is widely used in various applications for version control and automation tasks. The library's functionality includes reading and writing to Git repositories, managing branches, and handling commits. However, a recent vulnerability has been identified that could allow unauthorized file access, raising concerns about the security of applications utilizing this library.

Vulnerability Detail

The vulnerability, identified as CVE-2023-41040, arises from GitPython's handling of file paths when resolving Git references. Specifically, the library reads files from the .git directory, but it does not adequately validate user-provided file names. This oversight allows an attacker to manipulate the input to read files outside the intended directory. While this vulnerability does not directly expose file contents, it could potentially lead to a denial of service for the application. The affected code can be found in the symbolic.py file, where user input is concatenated with the base directory without proper checks.

How To Fix

Minimum fixed version

3.1.14-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-git

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can restrict user input for file names to prevent any potential exploitation. Implementing strict validation checks on file paths before processing them can mitigate the risk. For example, ensure that the input file name does not contain any path traversal characters (like '../') and is limited to expected values.

Conclusion

CVE-2023-41040 poses a significant risk to applications using the GitPython library due to its inadequate validation of user input for file paths. Users are strongly advised to update their installations to mitigate this vulnerability and ensure the security of their applications.

See every vulnerability recorded for python-git →

Share this vulnerability

FAQ

CVE-2023-41040 is a vulnerability in the GitPython library that allows attackers to potentially read files outside the intended .git directory due to insufficient input validation.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The primary impact is the potential for unauthorized file access, which could lead to a denial of service for applications using GitPython.

Yes, users should update to the latest version of GitPython that includes security fixes. For Debian systems, ensure you are using at least version 3.1.30-1+deb12u2.

The CVSS score for CVE-2023-41040 is 6.5, indicating a medium severity level.

Related vulnerabilities

Recent vulnerabilities recorded for python-git.

How To Fix

Minimum fixed version

3.1.14-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-git

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback