# CVE-2023-41040: GitPython blind local file inclusion

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 4.0
- **CVSS:** 4.0 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: Low
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 1.08% (percentile 65, 2026-11-28)
- **CWE:** CWE-22
- **Aliases:** GHSA-cwvm-v4w8-q58c, PYSEC-2023-165
- **Published:** 2023-08-30T20:09:36.000Z
- **Modified:** 2026-06-17T06:20:14.253Z

## Who should check

- Projects that depend on PyPI package gitpython (\< 3.1.37)
- Anyone running gitpython-developers GitPython \< 3.1.37

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

## Affected and fixed versions

- PyPI `gitpython`: affected \< 3.1.37; fixed 3.1.37, 3.1.35 (osv)
- gitpython-developers GitPython: \< 3.1.37 (cvelist)

## Mitigation

- Upgrade gitpython to one of 3.1.37, 3.1.35 (or later in the same release line).

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2023-41040. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2023-41040.md
Affected: gitpython < 3.1.37
Fixed in: 3.1.37, 3.1.35

Steps:
1. Search this machine and project for gitpython (PyPI), gitpython-developers GitPython: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2023-41040 being exploited?

There is no confirmed exploitation: CVE-2023-41040 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 1.08% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2023-41040?

Medium: CVSS 4.0 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2023-41040?

gitpython \< 3.1.37.

### Is there a fix for CVE-2023-41040?

Yes. Fixed in 3.1.37, 3.1.35. Upgrade gitpython to one of 3.1.37, 3.1.35 (or later in the same release line).

### How do I check if I'm affected by CVE-2023-41040?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-cwvm-v4w8-q58c>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2023-41040>
- patch: <https://github.com/gitpython-developers/GitPython/pull/1672>
- patch: <https://github.com/gitpython-developers/GitPython/commit/74e55ee4544867e1bd976b7df5a45869ee397b0b>
- patch: <https://github.com/gitpython-developers/GitPython/commit/e98f57b81f792f0f5e18d33ee658ae395f9aa3c4>
- other: <https://github.com/gitpython-developers/GitPython/blob/1c8310d7cae144f74a671cbe17e51f63a830adbf/git/refs/symbolic.py#L174-L175>
- other: <https://github.com/gitpython-developers/GitPython/releases/tag/3.1.37>
- other: <https://github.com/pypa/advisory-database/tree/main/vulns/gitpython/PYSEC-2023-165.yaml>
- other: <https://lists.debian.org/debian-lts-announce/2023/09/msg00036.html>
- other: <https://lists.debian.org/debian-lts-announce/2024/10/msg00030.html>
- other: <https://github.com/gitpython-developers/GitPython>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2023-41040>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-cwvm-v4w8-q58c> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/PYSEC-2023-165> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2023-41040> · JSON: <https://flawdb.com/api/v1/entries/CVE-2023-41040>
