CVE-2023-41040 GitPython blind local file inclusion
An attacker can trigger a denial of service in GitPython by exploiting a path traversal vulnerability that allows reading files outside the .git directory.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2023-41040?
CVE-2023-41040 is a medium-severity path traversal vulnerability in gitpython-developers GitPython, published on 30 Aug 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
GitPython is a python library used to interact with Git repositories. In order to resolve some git references, GitPython reads files from the `.git` directory, in some places the name of the file being read is provided by the user, GitPython doesn't check if this file is located outside the `.git` directory. This allows an attacker to make GitPython read any file from the system. This vulnerability is present in https://github.com/gitpython-developers/GitPython/blob/1c8310d7cae144f74a671cbe17e51f63a830adbf/git/refs/symbolic.py#L174-L175. That code joins the base directory with a user given string without checking if the final path is located outside the base directory. This vulnerability cannot be used to read the contents of files but could in theory be used to trigger a denial of service for the program. This issue has been addressed in version 3.1.37.
Weakness: CWE-22
Which versions are affected by CVE-2023-41040?
3 open source packages ship an affected version, including gitpython and GitPython. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
gitpython PyPI | All versions | 3.1.35 |
gitpython PyPI | All versions | 3.1.37 |
GitPython PyPI | All versions | 3.1.37 |
Linux distribution packages (8)
GitPython Red Hat:openstack:17.1::el8 | All versions | 0:3.1.14-2.el8ost |
python3-GitPython Red Hat:openstack:17.1::el8 | All versions | 0:3.1.14-2.el8ost |
GitPython Red Hat:openstack:17.1::el9 | All versions | 0:3.1.14-2.el9ost |
python3-GitPython Red Hat:openstack:17.1::el9 | All versions | 0:3.1.14-2.el9ost |
python-GitPython SUSE:Package Hub 15 SP4 | All versions | 3.1.12.1610074031.f653af66-bp154.2.3.1 |
python-GitPython SUSE:Package Hub 15 SP5 | All versions | 3.1.12.1610074031.f653af66-bp155.3.3.1 |
python-GitPython openSUSE:Leap 15.4 | All versions | 3.1.12.1610074031.f653af66-bp154.2.3.1 |
python-GitPython openSUSE:Leap 15.5 | All versions | 3.1.12.1610074031.f653af66-bp155.3.3.1 |
Products include Gitpython Project Gitpython.
How do I fix CVE-2023-41040?
Upgrade gitpython to a fixed version for your release line: 3.1.35 or 3.1.37.
Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.
Is CVE-2023-41040 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-41040 exists.
Other vulnerabilities in gitpython-developers GitPython
- CVE-2023-40267 GitPython vulnerable to remote code execution due to insufficient sanitization of input arguments
- CVE-2026-78676 GitPython before 3.1.59 Remote Code Execution via Config Injection
- CVE-2026-67324 GitPython 3.1.50 Authentication Bypass via Joined Short Options
- CVE-2026-42215 GitPython: Command injection via Git options bypass
- CVE-2026-87817 GitPython before 3.1.60 Remote Code Execution via Git Directory Impersonation
Sources
Also known as CLSA-2025-1759191117, DEBIAN-CVE-2023-41040, DLA-3589-1, GHSA-cwvm-v4w8-q58c, OESA-2023-1628, PYSEC-2023-165 and 5 more.