# 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.

- **Severity:** Medium 4.0 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 Aug 2023
- **Updated:** 3 Nov 2025
- **Also known as:** CLSA-2025-1759191117, DEBIAN-CVE-2023-41040, DLA-3589-1, GHSA-cwvm-v4w8-q58c, OESA-2023-1628, PYSEC-2023-165, RHSA-2024:0190, RHSA-2024:0215, UBUNTU-CVE-2023-41040, openSUSE-SU-2023:0259-1, openSUSE-SU-2023:0271-1

## 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 (Improper Limitation of a Pathname to a Restricted Directory)

## 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 | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `gitpython` | PyPI | All versions | 3.1.35 |
| `gitpython` | PyPI | All versions | 3.1.37 |
| `GitPython` | PyPI | All versions | 3.1.37 |
| `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: 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.

## 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](https://insights.sbomify.com/CVE-2023-40267/): GitPython vulnerable to remote code execution due to insufficient sanitization of input arguments (critical 9.8)
- [CVE-2026-78676](https://insights.sbomify.com/CVE-2026-78676/): GitPython before 3.1.59 Remote Code Execution via Config Injection (critical 9.3)
- [CVE-2026-67324](https://insights.sbomify.com/CVE-2026-67324/): GitPython 3.1.50 Authentication Bypass via Joined Short Options (critical 9.3)
- [CVE-2026-42215](https://insights.sbomify.com/CVE-2026-42215/): GitPython: Command injection via Git options bypass (high 8.8)
- [CVE-2026-87817](https://insights.sbomify.com/CVE-2026-87817/): GitPython before 3.1.60 Remote Code Execution via Git Directory Impersonation (high 8.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-41040 and fix it if it is affected.

What it is: 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.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-41040 exists.

Affected packages and fixed versions:
- gitpython (PyPI): affected all versions; fixed in 3.1.35
- gitpython (PyPI): affected all versions; fixed in 3.1.37
- GitPython (PyPI): affected all versions; fixed in 3.1.37

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-41040/ (Markdown: https://insights.sbomify.com/CVE-2023-41040/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-41040
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-41040
- OSV: https://osv.dev/vulnerability/CVE-2023-41040

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-41040/
Summaries are generated and may contain mistakes; the official description above is the record.
