CVE-2025-4138 Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory
Attackers can bypass extraction filters to create symlinks outside the target directory, potentially modifying files or bypassing security controls.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2025-4138?
CVE-2025-4138 is a high-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 the extraction filter to be ignored, allowing symlink targets to point outside the destination directory, and the modification of some file metadata.
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.
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-2025-4138?
3 open source packages ship an affected version, including libpython, python and python-min.
| Package | Affected | Fixed in |
|---|---|---|
libpython Bitnami | All versions | 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4 |
python Bitnami | All versions | 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4 |
python-min Bitnami | All versions | 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4 |
How do I fix CVE-2025-4138?
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-2025-4138 being exploited?
There is no known exploitation of CVE-2025-4138 in the wild and no public exploit code.
Public exploit code: 5 proofs of concept on GitHub.
Sources
Also known as ALPINE-CVE-2025-4138, AZL-62322, BELL-CVE-2025-4138, BIT-libpython-2025-4138, BIT-python-2025-4138, BIT-python-min-2025-4138 and 10 more.