CVE-2023-41040 GitPython blind local file inclusion

Medium 4.0 Published Updated

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.

PackageAffectedFixed in
gitpython PyPIAll versions3.1.35
gitpython PyPIAll versions3.1.37
GitPython PyPIAll versions3.1.37
Linux distribution packages (8)
GitPython Red Hat:openstack:17.1::el8All versions0:3.1.14-2.el8ost
python3-GitPython Red Hat:openstack:17.1::el8All versions0:3.1.14-2.el8ost
GitPython Red Hat:openstack:17.1::el9All versions0:3.1.14-2.el9ost
python3-GitPython Red Hat:openstack:17.1::el9All versions0:3.1.14-2.el9ost
python-GitPython SUSE:Package Hub 15 SP4All versions3.1.12.1610074031.f653af66-bp154.2.3.1
python-GitPython SUSE:Package Hub 15 SP5All versions3.1.12.1610074031.f653af66-bp155.3.3.1
python-GitPython openSUSE:Leap 15.4All versions3.1.12.1610074031.f653af66-bp154.2.3.1
python-GitPython openSUSE:Leap 15.5All versions3.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.

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.

Is CVE-2023-41040 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free