CVE-2025-4138

Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory

Published Jun 3, 2025 CVSS 3.1 · 7.5 High EPSS 1.5% KEV · Not listed
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.

Analysis

AI-generated

Technical impact

This flaw lets the tarfile module ignore the extraction filter, permitting attackers to craft tar archives that create symbolic links pointing to arbitrary locations outside the intended extraction directory. When TarFile.extractall() or TarFile.extract() is called with filter='data' or 'tar', the symlink creation is not constrained, and file metadata can be altered. The result is potential overwrite of critical files, enabling persistence or privilege escalation. The weakness is a Path Traversal flaw (CWE‑22).

Affected Systems

The vulnerability affects CPython – the official Python implementation – wherever the tarfile module can be invoked with the extraction filters 'data' or 'tar'. Python 3.14 and later are partially affected due to the change in the default filter value from 'no filtering' to 'data', so any use of tarfile to extract untrusted archives is exposed. Many Linux distributions, including Red Hat Enterprise Linux 8‑10, ship these Python versions, making them susceptible if they run applications that perform tar extraction.

Risk and Exploitability

The CVSS score of 7.5 signals a high severity for the potential to write across file boundaries, and the EPSS < 1 % indicates that exploitation is expected to be rare at present. The vulnerability is not listed in the CISA KEV catalog. Attackers can exploit the flaw by delivering malicious tar archives to a Python process that performs extraction with 'data' or 'tar' filters, either locally or over a network. The attack requires code execution during extraction; it does not grant arbitrary code execution by itself but can lead to integrity compromise or serve as a foothold for further escalation.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade CPython to the latest release that includes the tarfile filter fix.
  • If upgrading is not immediately possible, avoid using the 'data' or 'tar' extraction filters; instead, implement a custom filter that rejects symlinks that point outside the intended directory.
  • Only extract tar archives from trusted sources and validate the target paths before extraction, ensuring that no non‑relative or absolute paths or symlinks are allowed.

Generated by OpenCVE AI on April 22, 2026 at 11:29 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
EUVD EUVD EUVD-2025-16724 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.
Ubuntu USN Ubuntu USN USN-7583-1 Python vulnerabilities
History
Type Values Removed Values Added
CPEs cpe:/a:redhat:rhel_e4s:8.8
cpe:/a:redhat:rhel_eus_long_life:8.8
cpe:/a:redhat:rhel_tus:8.8
Type Values Removed Values Added
First Time appeared Redhat rhel Aus
Redhat rhel E4s
Redhat rhel Eus Long Life
Redhat rhel Tus
CPEs cpe:/a:redhat:rhel_aus:8.6
cpe:/a:redhat:rhel_e4s:8.6
cpe:/a:redhat:rhel_eus_long_life:8.6
cpe:/a:redhat:rhel_tus:8.6
Vendors & Products Redhat rhel Aus
Redhat rhel E4s
Redhat rhel Eus Long Life
Redhat rhel Tus
Type Values Removed Values Added
CPEs cpe:/a:redhat:enterprise_linux:9
cpe:/o:redhat:enterprise_linux:10.0
cpe:/o:redhat:enterprise_linux:8
cpe:/o:redhat:enterprise_linux:9
Type Values Removed Values Added
First Time appeared Redhat enterprise Linux
CPEs cpe:/a:redhat:enterprise_linux:8
Vendors & Products Redhat enterprise Linux
Type Values Removed Values Added
First Time appeared Redhat
Redhat rhel Eus
CPEs cpe:/a:redhat:rhel_eus:9.4
Vendors & Products Redhat
Redhat rhel Eus
Type Values Removed Values Added
References
Metrics threat_severity

None

threat_severity

Important

Type Values Removed Values Added
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. 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. 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.
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
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. 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.
Title Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory
Weaknesses CWE-22
References
Metrics cvssV3_1

{'score': 7.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N'}

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Jul 31, 2026, 2:03 PM
Reserved
Apr 30, 2025, 1:35 PM
Status
Deferred
Published
Jun 3, 2025, 1:15 PM
Modified
Jul 31, 2026, 2:16 PM
Severity
Important
Public date
Jun 3, 2025, 12:59 PM