CVE-2025-4517

Arbitrary writes via tarfile realpath overflow

Published Jun 3, 2025 CVSS 3.1 · 9.4 Critical EPSS 1.6% KEV · Not listed
Description
Allows arbitrary filesystem writes outside the extraction directory during extraction with filter="data".


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

The vulnerability arises from a logic flaw in Python’s tarfile module that resolves extraction paths without properly sanitizing them, allowing attackers to craft archive entries that resolve to paths outside the intended extraction directory. When an archive is extracted with the filter parameter set to 'data' or 'tar' – which is also the default from Python 3.14 onward – the library expands paths using an insecure realpath algorithm. As a result, an adversary can extract files to any location within the process’s writable filesystem, enabling arbitrary overwrite or creation of files. This represents a CWE‑22 path traversal flaw and can be leveraged for modifications or persistence.

Affected Systems

The flaw is present in CPython, the standard Python interpreter, for versions that allow the use of tarfile with the filter parameter set to 'data' or 'tar'. Since Python 3.14 changed the default filter to 'data', this vulnerability affects all installations running Python 3.14 or later when the default extraction behavior is used. Earlier Python versions are affected only when applications explicitly pass filter='data' or filter='tar'. The vulnerability does not depend on any particular operating‑system runtime and is therefore relevant to any platform that runs CPython, including Red Hat Enterprise Linux families and other distributions.

Risk and Exploitability

The CVSS score of 9.4 indicates a severe impact if exploited. The EPSS score is below 1 %, suggesting a low present exploitation probability, and the issue is not listed in the CISA KEV catalog. Based on the description, the likely attack vector is an attacker supplying a malicious tar archive to a Python process that calls TarFile.extractall or TarFile.extract with a safe filter. In practice this could occur when a software component or user processes untrusted archives, for instance during package installation or data import. A locally running Python process, especially one with elevated privileges, could modify or create arbitrary files, potentially leading to privilege escalation or persistence.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade CPython to the most recent stable release that includes the fix (consult CPython changelog or release notes for the relevant commit).
  • If an upgrade is not possible, enforce a safer extraction filter by explicitly specifying filter="safe" or replacing the default filter behavior with a custom implementation that validates extracted paths.
  • Review code that processes untrusted tar archives and restrict or sandbox the extraction process, ensuring the process has minimal privileges; use a dedicated, unprivileged user for extraction when possible.

Generated by OpenCVE AI on April 22, 2026 at 12:10 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
EUVD EUVD EUVD-2025-16736 Allows arbitrary filesystem writes outside the extraction directory during extraction with filter="data". 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
Metrics epss

{'score': 0.00103}

epss

{'score': 0.0014}

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 arbitrary filesystem writes outside the extraction directory during extraction with filter="data". 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 arbitrary filesystem writes outside the extraction directory during extraction with filter="data". 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': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description Allows arbitrary filesystem writes outside the extraction directory during extraction with filter="data". 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 Arbitrary writes via tarfile realpath overflow
Weaknesses CWE-22
References
Metrics cvssV3_1

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

Weaknesses
  • CWE-22

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

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Aug 4, 2026, 2:26 PM
Reserved
May 9, 2025, 3:05 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:58 PM