CVE-2025-4138: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython
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.
AI Analysis
Technical Summary
CVE-2025-4138 is a high-severity path traversal vulnerability (CWE-22) affecting the Python Software Foundation's CPython implementation, specifically within the tarfile module used for extracting tar archives. The vulnerability arises when using the TarFile.extractall() or TarFile.extract() methods with the filter parameter set to "data" or "tar". This flaw allows an attacker to bypass the extraction filter, enabling symbolic link (symlink) targets within the tar archive to point outside the intended destination directory. Consequently, this can lead to unauthorized file extraction or modification outside the designated extraction path, potentially overwriting critical files or planting malicious files in arbitrary locations. Additionally, some file metadata can be altered during extraction, which may facilitate further exploitation or evasion. Notably, starting with Python 3.14, the default filter value changed from "no filtering" to "data", meaning that even users relying on default behavior in newer Python versions are affected. The vulnerability does not significantly impact the installation of source distributions packaged as tar archives, as these inherently allow arbitrary code execution during build processes. However, it remains critical to avoid installing source distributions containing suspicious symlinks. The CVSS v3.1 score is 7.5, reflecting a high severity with network attack vector, low attack complexity, no privileges or user interaction required, and a significant confidentiality impact but no integrity or availability impact. No known exploits are currently reported in the wild, and no patches are linked yet, indicating the need for vigilance and proactive mitigation.
Potential Impact
For European organizations, this vulnerability poses a significant risk, especially those relying on Python applications that process untrusted tar archives using the affected tarfile module methods. Exploitation could lead to unauthorized disclosure of sensitive data if files outside the extraction directory are exposed, or potential disruption by overwriting or planting malicious files in critical system locations. This is particularly concerning for sectors handling sensitive or regulated data such as finance, healthcare, and government agencies within Europe. The fact that no authentication or user interaction is required increases the risk of automated exploitation in supply chain attacks or malicious archive deliveries. Organizations using Python 3.14 or later are also at risk due to the changed default filter behavior, potentially increasing the attack surface. While the vulnerability does not directly allow code execution, the ability to manipulate filesystem contents and metadata can facilitate further attacks or persistence mechanisms. Given Europe's stringent data protection regulations like GDPR, any data leakage or unauthorized file modifications could lead to compliance violations and reputational damage.
Mitigation Recommendations
European organizations should immediately audit their Python environments to identify usage of the tarfile module's extractall() or extract() methods with the filter parameter set to "data" or "tar". Where feasible, avoid extracting untrusted tar archives or implement strict validation of archive contents before extraction. Employ sandboxing or containerization to isolate extraction processes, limiting filesystem access to designated directories. Monitor and restrict symbolic link creation and resolution during extraction. Upgrade to patched Python versions once available; until then, consider backporting fixes or applying manual checks to sanitize archive contents. Additionally, implement file integrity monitoring on critical directories to detect unauthorized changes. Educate developers and DevOps teams about the changed default filter behavior in Python 3.14 and review CI/CD pipelines that automatically process tar archives to prevent inadvertent exploitation. Finally, maintain vigilant monitoring for suspicious activity related to archive extraction and symlink manipulation.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Italy, Spain, Poland
CVE-2025-4138: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython
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.
AI-Powered Analysis
Technical Analysis
CVE-2025-4138 is a high-severity path traversal vulnerability (CWE-22) affecting the Python Software Foundation's CPython implementation, specifically within the tarfile module used for extracting tar archives. The vulnerability arises when using the TarFile.extractall() or TarFile.extract() methods with the filter parameter set to "data" or "tar". This flaw allows an attacker to bypass the extraction filter, enabling symbolic link (symlink) targets within the tar archive to point outside the intended destination directory. Consequently, this can lead to unauthorized file extraction or modification outside the designated extraction path, potentially overwriting critical files or planting malicious files in arbitrary locations. Additionally, some file metadata can be altered during extraction, which may facilitate further exploitation or evasion. Notably, starting with Python 3.14, the default filter value changed from "no filtering" to "data", meaning that even users relying on default behavior in newer Python versions are affected. The vulnerability does not significantly impact the installation of source distributions packaged as tar archives, as these inherently allow arbitrary code execution during build processes. However, it remains critical to avoid installing source distributions containing suspicious symlinks. The CVSS v3.1 score is 7.5, reflecting a high severity with network attack vector, low attack complexity, no privileges or user interaction required, and a significant confidentiality impact but no integrity or availability impact. No known exploits are currently reported in the wild, and no patches are linked yet, indicating the need for vigilance and proactive mitigation.
Potential Impact
For European organizations, this vulnerability poses a significant risk, especially those relying on Python applications that process untrusted tar archives using the affected tarfile module methods. Exploitation could lead to unauthorized disclosure of sensitive data if files outside the extraction directory are exposed, or potential disruption by overwriting or planting malicious files in critical system locations. This is particularly concerning for sectors handling sensitive or regulated data such as finance, healthcare, and government agencies within Europe. The fact that no authentication or user interaction is required increases the risk of automated exploitation in supply chain attacks or malicious archive deliveries. Organizations using Python 3.14 or later are also at risk due to the changed default filter behavior, potentially increasing the attack surface. While the vulnerability does not directly allow code execution, the ability to manipulate filesystem contents and metadata can facilitate further attacks or persistence mechanisms. Given Europe's stringent data protection regulations like GDPR, any data leakage or unauthorized file modifications could lead to compliance violations and reputational damage.
Mitigation Recommendations
European organizations should immediately audit their Python environments to identify usage of the tarfile module's extractall() or extract() methods with the filter parameter set to "data" or "tar". Where feasible, avoid extracting untrusted tar archives or implement strict validation of archive contents before extraction. Employ sandboxing or containerization to isolate extraction processes, limiting filesystem access to designated directories. Monitor and restrict symbolic link creation and resolution during extraction. Upgrade to patched Python versions once available; until then, consider backporting fixes or applying manual checks to sanitize archive contents. Additionally, implement file integrity monitoring on critical directories to detect unauthorized changes. Educate developers and DevOps teams about the changed default filter behavior in Python 3.14 and review CI/CD pipelines that automatically process tar archives to prevent inadvertent exploitation. Finally, maintain vigilant monitoring for suspicious activity related to archive extraction and symlink manipulation.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- PSF
- Date Reserved
- 2025-04-30T13:35:55.675Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 683ef89a182aa0cae27cb26f
Added to database: 6/3/2025, 1:28:58 PM
Last enriched: 7/11/2025, 3:02:31 AM
Last updated: 8/7/2025, 4:28:02 PM
Views: 32
Related Threats
CVE-2025-36088: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in IBM Storage TS4500 Library
MediumCVE-2025-43490: CWE-59 Improper Link Resolution Before File Access ('Link Following') in HP, Inc. HP Hotkey Support Software
MediumCVE-2025-9060: CWE-20 Improper Input Validation in MSoft MFlash
CriticalCVE-2025-8675: CWE-918 Server-Side Request Forgery (SSRF) in Drupal AI SEO Link Advisor
MediumCVE-2025-8362: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in Drupal GoogleTag Manager
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.