Skip to main content

CVE-2025-4517: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython

Critical
VulnerabilityCVE-2025-4517cvecve-2025-4517cwe-22
Published: Tue Jun 03 2025 (06/03/2025, 12:58:50 UTC)
Source: CVE Database V5
Vendor/Project: Python Software Foundation
Product: CPython

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.

AI-Powered Analysis

AILast updated: 07/11/2025, 02:01:12 UTC

Technical Analysis

CVE-2025-4517 is a critical path traversal vulnerability (CWE-22) affecting the Python Software Foundation's CPython implementation, specifically within the tarfile module. This vulnerability allows an attacker to perform arbitrary filesystem writes outside the intended extraction directory when extracting tar archives using the TarFile.extractall() or TarFile.extract() methods with the filter parameter set to "data" or "tar". The issue arises because the pathname limitation intended to restrict file extraction to a safe directory is improperly enforced, enabling crafted tar archives to overwrite or create files anywhere on the filesystem accessible by the Python process. Notably, starting with Python 3.14, the default filter value changed from "no filtering" to "data", which means that even code relying on default behavior is now vulnerable. The vulnerability affects all CPython versions from 0 up to 3.14.0a1. Although source distributions (which are often tar archives) are less impacted due to their inherent risk of arbitrary code execution during build processes, this vulnerability poses a significant risk when extracting untrusted tar archives in any Python environment. The CVSS v3.1 score is 9.4 (critical), reflecting its network attack vector, no required privileges or user interaction, and high impact on confidentiality and integrity with some impact on availability. No known exploits are currently reported in the wild, but the ease of exploitation and severity warrant immediate attention. This vulnerability can lead to unauthorized file overwrites, potentially allowing attackers to implant malicious code, escalate privileges, or disrupt system operations.

Potential Impact

For European organizations, this vulnerability presents a severe risk, especially those relying on Python for automation, data processing, or software deployment that involves extracting tar archives from untrusted or external sources. Successful exploitation can lead to unauthorized modification or creation of critical files, resulting in data breaches, system compromise, or service disruption. Given Python's widespread use in enterprise environments, including financial services, healthcare, government, and technology sectors across Europe, the potential for lateral movement and persistent compromise is significant. Organizations using Python 3.14 or later are particularly at risk due to the default filter change increasing exposure. The vulnerability could be exploited in supply chain attacks, where malicious tar archives are introduced during software updates or third-party integrations. Additionally, critical infrastructure and cloud service providers in Europe that utilize Python-based tooling may face operational risks and regulatory consequences under GDPR if sensitive data is compromised.

Mitigation Recommendations

European organizations should immediately audit their Python environments to identify usage of the tarfile module with extractall() or extract() methods, especially where the filter parameter is set to "data" or "tar" or left to default in Python 3.14+. Mitigations include: 1) Avoid extracting tar archives from untrusted sources or implement strict validation and sanitization of archive contents before extraction. 2) Upgrade to a patched version of CPython once available; until then, consider downgrading to a safe version or disabling the use of the filter parameter. 3) Implement application-level controls to restrict filesystem write permissions for Python processes, using containerization or sandboxing to limit impact. 4) Monitor filesystem changes and audit logs for unexpected file writes outside designated directories. 5) Educate developers and DevOps teams about the risks of using tarfile extraction with untrusted data and enforce secure coding practices. 6) Use alternative extraction libraries or tools that properly enforce path restrictions if immediate patching is not feasible. 7) Review and harden CI/CD pipelines and software supply chains to prevent introduction of malicious tar archives.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
PSF
Date Reserved
2025-05-09T15:05:07.139Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 683eff8d182aa0cae27db844

Added to database: 6/3/2025, 1:58:37 PM

Last enriched: 7/11/2025, 2:01:12 AM

Last updated: 8/16/2025, 11:38:50 AM

Views: 27

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats