CVE-2023-41040
GitPython blind local file inclusion
Check your servers for CVE-2023-41040
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2023-41040 affects gitpython, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- none: the attacker does not need an account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity none, availability low: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 1.09%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 66.4% of all scored CVEs. Scores of 1 Dec 2026.
The assessment of CISA (SSVC, 1 Oct 2024):
- Exploitation
- poc: a proof of concept is public
- Automatable
- no: each attack takes manual steps
- Technical impact
- partial: limited control or limited data
Weakness
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| GitPython |
affected < 3.1.37
|
Is my server affected?
Find the installed version of gitpython and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.
Debian, Ubuntu
dpkg -l | grep -i gitpython
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2023-41040 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2023-41040RHEL, Rocky, Alma, Fedora
rpm -q gitpython
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2023-41040Alpine
apk list --installed | grep -i gitpythonWith Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2023-41040
trivy image --scanners vuln IMAGE | grep CVE-2023-41040
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Advisories
- https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-cwvm-v4w8-q58c github.com
Other references
- https://github.com/gitpython-developers/GitPython/pull/1672 github.com
- https://github.com/gitpython-developers/GitPython/commit/74e55ee4544867e1bd976b7df5a45869ee397b0b github.com
- https://github.com/gitpython-developers/GitPython/commit/e98f57b81f792f0f5e18d33ee658ae395f9aa3c4 github.com
- https://github.com/gitpython-developers/GitPython/blob/1c8310d7cae144f74a671cbe17e51f63a830adbf/git/refs/symbolic.py#L174-L175 github.com
- https://github.com/gitpython-developers/GitPython/releases/tag/3.1.37 github.com
- https://github.com/pypa/advisory-database/tree/main/vulns/gitpython/PYSEC-2023-165.yaml github.com
- https://lists.debian.org/debian-lts-announce/2023/09/msg00036.html lists.debian.org
- https://lists.debian.org/debian-lts-announce/2024/10/msg00030.html lists.debian.org
Source: the record CVE-2023-41040 of the CVE List (CVE Program), CVE Terms of Use; the CISA KEV catalog and the CISA ADP container; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse