CVE-2025-4517: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython
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 Analysis
Technical Summary
CVE-2025-4517 is a critical security vulnerability classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal) affecting the Python Software Foundation's CPython implementation. The vulnerability arises in the tarfile module when extracting tar archives using the TarFile.extractall() or TarFile.extract() methods with the filter parameter set to "data" or "tar". This flaw allows attackers to craft malicious tar archives that, when extracted, can write files to arbitrary locations on the filesystem outside the intended extraction directory. This occurs because the pathname validation does not properly restrict traversal sequences such as "../", enabling directory traversal attacks. The vulnerability affects all Python versions from the initial release up to 3.14.0a1. Notably, Python 3.14 changes the default filter parameter to "data", which means that even code relying on default behavior is now vulnerable. The impact is severe because arbitrary file writes can lead to overwriting critical system files, configuration files, or placing malicious executables, potentially resulting in full system compromise. While source distributions (tar archives used for Python package source code) are less affected due to inherent risks during build processes, the vulnerability remains critical for any scenario where untrusted tar archives are extracted. The CVSS v3.1 base score is 9.4, reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impact on confidentiality and integrity with some impact on availability. No known exploits have been reported in the wild yet, but the vulnerability is publicly disclosed and should be treated as critical.
Potential Impact
The impact of CVE-2025-4517 is significant for organizations worldwide that use Python’s tarfile module to extract tar archives, especially when handling untrusted or user-supplied archives. Successful exploitation allows attackers to write arbitrary files anywhere on the filesystem, potentially overwriting system binaries, configuration files, or placing backdoors and malware. This can lead to full system compromise, data breaches, unauthorized access, and disruption of services. The vulnerability affects a wide range of Python applications, including web services, automation tools, CI/CD pipelines, and software distribution systems that rely on tarfile extraction. The change in default filter behavior in Python 3.14 increases the risk as even previously safe code may become vulnerable without modification. Organizations that process tar archives from external sources or run automated extraction workflows are at high risk. The vulnerability can be exploited remotely without authentication or user interaction, increasing the attack surface. Although no exploits are currently known in the wild, the critical severity and ease of exploitation make it a high-priority threat that could be leveraged in targeted attacks or widespread malware campaigns.
Mitigation Recommendations
To mitigate CVE-2025-4517, organizations should: 1) Immediately update to a patched Python version once available that addresses this vulnerability. Monitor official Python Security advisories for patches. 2) Until patches are applied, avoid extracting untrusted tar archives using the tarfile module with the filter parameter set to "data" or "tar". Prefer using safer extraction methods or explicitly validate archive contents before extraction. 3) Implement strict input validation and sanitization on tar archive filenames to detect and reject path traversal sequences such as "../". 4) Use sandboxing or containerization to isolate extraction processes, limiting filesystem access and minimizing potential damage from arbitrary writes. 5) Review and audit all code that uses tarfile.extractall() or extract() with filters, especially in automated pipelines and CI/CD environments. 6) Employ runtime monitoring and file integrity checking to detect unauthorized file modifications. 7) Educate developers and security teams about the change in default filter behavior in Python 3.14 to prevent inadvertent exposure. 8) Consider alternative archive formats or libraries with safer extraction defaults if immediate patching is not feasible. These steps go beyond generic advice by focusing on code review, input validation, isolation, and awareness of behavioral changes in Python versions.
Affected Countries
United States, Germany, United Kingdom, France, Japan, China, India, Canada, Australia, Netherlands, South Korea, Brazil, Russia, Israel, Singapore
CVE-2025-4517: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation 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
Machine-generated threat intelligence
Technical Analysis
CVE-2025-4517 is a critical security vulnerability classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal) affecting the Python Software Foundation's CPython implementation. The vulnerability arises in the tarfile module when extracting tar archives using the TarFile.extractall() or TarFile.extract() methods with the filter parameter set to "data" or "tar". This flaw allows attackers to craft malicious tar archives that, when extracted, can write files to arbitrary locations on the filesystem outside the intended extraction directory. This occurs because the pathname validation does not properly restrict traversal sequences such as "../", enabling directory traversal attacks. The vulnerability affects all Python versions from the initial release up to 3.14.0a1. Notably, Python 3.14 changes the default filter parameter to "data", which means that even code relying on default behavior is now vulnerable. The impact is severe because arbitrary file writes can lead to overwriting critical system files, configuration files, or placing malicious executables, potentially resulting in full system compromise. While source distributions (tar archives used for Python package source code) are less affected due to inherent risks during build processes, the vulnerability remains critical for any scenario where untrusted tar archives are extracted. The CVSS v3.1 base score is 9.4, reflecting network attack vector, low attack complexity, no privileges required, no user interaction, and high impact on confidentiality and integrity with some impact on availability. No known exploits have been reported in the wild yet, but the vulnerability is publicly disclosed and should be treated as critical.
Potential Impact
The impact of CVE-2025-4517 is significant for organizations worldwide that use Python’s tarfile module to extract tar archives, especially when handling untrusted or user-supplied archives. Successful exploitation allows attackers to write arbitrary files anywhere on the filesystem, potentially overwriting system binaries, configuration files, or placing backdoors and malware. This can lead to full system compromise, data breaches, unauthorized access, and disruption of services. The vulnerability affects a wide range of Python applications, including web services, automation tools, CI/CD pipelines, and software distribution systems that rely on tarfile extraction. The change in default filter behavior in Python 3.14 increases the risk as even previously safe code may become vulnerable without modification. Organizations that process tar archives from external sources or run automated extraction workflows are at high risk. The vulnerability can be exploited remotely without authentication or user interaction, increasing the attack surface. Although no exploits are currently known in the wild, the critical severity and ease of exploitation make it a high-priority threat that could be leveraged in targeted attacks or widespread malware campaigns.
Mitigation Recommendations
To mitigate CVE-2025-4517, organizations should: 1) Immediately update to a patched Python version once available that addresses this vulnerability. Monitor official Python Security advisories for patches. 2) Until patches are applied, avoid extracting untrusted tar archives using the tarfile module with the filter parameter set to "data" or "tar". Prefer using safer extraction methods or explicitly validate archive contents before extraction. 3) Implement strict input validation and sanitization on tar archive filenames to detect and reject path traversal sequences such as "../". 4) Use sandboxing or containerization to isolate extraction processes, limiting filesystem access and minimizing potential damage from arbitrary writes. 5) Review and audit all code that uses tarfile.extractall() or extract() with filters, especially in automated pipelines and CI/CD environments. 6) Employ runtime monitoring and file integrity checking to detect unauthorized file modifications. 7) Educate developers and security teams about the change in default filter behavior in Python 3.14 to prevent inadvertent exposure. 8) Consider alternative archive formats or libraries with safer extraction defaults if immediate patching is not feasible. These steps go beyond generic advice by focusing on code review, input validation, isolation, and awareness of behavioral changes in Python versions.
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: 2/26/2026, 9:56:18 PM
Last updated: 3/25/2026, 4:27:33 AM
Views: 81
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.