CVE-2024-12718 Bypass extraction filter to modify file metadata outside extraction directory

Medium 5.3 Published Updated

Attackers can modify file metadata or permissions outside the extraction directory when using specific tarfile extraction filters.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-12718?

CVE-2024-12718 is a medium-severity path traversal vulnerability in CPython, published on 3 Jun 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Allows modifying some file metadata (e.g. last modified) with filter="data" or file permissions (chmod) with filter="tar" of files outside the extraction directory. You are affected by this vulnerability if using the tarfile module to extract untrusted tar archives using TarFile.extractall() or TarFile.extract() using the filter= parameter with a value of "data" or "tar". See the tarfile extraction filters documentation https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter  for more information. Only Python versions 3.12 or later are affected by these vulnerabilities, earlier versions don't include the extraction filter feature.

Note that for Python 3.14 or later the default value of filter= changed from "no filtering" to `"data", so if you are relying on this new default behavior then your usage is also affected.

Note that none of these vulnerabilities significantly affect the installation of source distributions which are tar archives as source distributions already allow arbitrary code execution during the build process. However when evaluating source distributions it's important to avoid installing source distributions with suspicious links.

Weakness: CWE-22

Which versions are affected by CVE-2024-12718?

3 open source packages ship an affected version, including libpython, python and python-min.

PackageAffectedFixed in
libpython BitnamiAll versions3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4
python BitnamiAll versions3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4
python-min BitnamiAll versions3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4

How do I fix CVE-2024-12718?

Upgrade libpython to a fixed version for your release line: 3.9.23, 3.10.18, 3.11.13 or 3.12.11.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2024-12718 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-12718 exists.

Sources

Also known as ALPINE-CVE-2024-12718, AZL-62258, BELL-CVE-2024-12718, BIT-libpython-2024-12718, BIT-python-2024-12718, BIT-python-min-2024-12718 and 10 more.

Is CVE-2024-12718 in your software?

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

Check your SBOMs for free