CVE-2025-4138: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython
CVE-2025-4138 is a path traversal vulnerability in the Python tarfile module that allows the extraction filter to be bypassed, enabling symlink targets to point outside the intended extraction directory and permitting modification of some file metadata. This affects usage of TarFile.extractall() or TarFile.extract() when using the filter parameter set to "data" or "tar". The default filter value changed to "data" starting with Python 3.14, so code relying on this default is also affected. This vulnerability does not significantly impact source distribution installations, which already allow arbitrary code execution during build.
AI Analysis
Technical Summary
The vulnerability in CPython's tarfile module (CVE-2025-4138) involves improper limitation of pathnames (CWE-22) during extraction of tar archives. Specifically, when using the extraction filters "data" or "tar" with TarFile.extractall() or TarFile.extract(), the filter can be ignored, allowing symbolic link targets to escape the intended extraction directory. This can lead to modification of file metadata outside the target directory. The issue affects Python versions 3.10.0 through 3.14.0a1, with the default filter changing to "data" in Python 3.14, increasing the risk for code relying on default behavior. The vulnerability does not significantly affect source distribution installations due to their inherent arbitrary code execution risk during build.
Potential Impact
An attacker providing a crafted tar archive can cause extraction operations to write files or modify metadata outside the intended directory via symlink traversal, potentially leading to unauthorized file modifications. The CVSS score of 7.5 (high) reflects the network attack vector, low complexity, no privileges required, no user interaction, and high confidentiality impact. There is no indication of integrity or availability impact. No known exploits in the wild have been reported.
Mitigation Recommendations
No official patch or fix information is provided in the available data. Patch status is not yet confirmed — check the Python Software Foundation advisory for current remediation guidance. Users should avoid extracting untrusted tar archives with the affected filter parameters until a fix is available. For Python 3.14 or later, be aware that the default filter value changed to "data", which is affected. Exercise caution when installing source distributions with suspicious symbolic links, although this vulnerability does not significantly increase risk in that context.
CVE-2025-4138: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in Python Software Foundation CPython
Description
CVE-2025-4138 is a path traversal vulnerability in the Python tarfile module that allows the extraction filter to be bypassed, enabling symlink targets to point outside the intended extraction directory and permitting modification of some file metadata. This affects usage of TarFile.extractall() or TarFile.extract() when using the filter parameter set to "data" or "tar". The default filter value changed to "data" starting with Python 3.14, so code relying on this default is also affected. This vulnerability does not significantly impact source distribution installations, which already allow arbitrary code execution during build.
CVSS v3.1
Score 7.5high
Affected software
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in CPython's tarfile module (CVE-2025-4138) involves improper limitation of pathnames (CWE-22) during extraction of tar archives. Specifically, when using the extraction filters "data" or "tar" with TarFile.extractall() or TarFile.extract(), the filter can be ignored, allowing symbolic link targets to escape the intended extraction directory. This can lead to modification of file metadata outside the target directory. The issue affects Python versions 3.10.0 through 3.14.0a1, with the default filter changing to "data" in Python 3.14, increasing the risk for code relying on default behavior. The vulnerability does not significantly affect source distribution installations due to their inherent arbitrary code execution risk during build.
Potential Impact
An attacker providing a crafted tar archive can cause extraction operations to write files or modify metadata outside the intended directory via symlink traversal, potentially leading to unauthorized file modifications. The CVSS score of 7.5 (high) reflects the network attack vector, low complexity, no privileges required, no user interaction, and high confidentiality impact. There is no indication of integrity or availability impact. No known exploits in the wild have been reported.
Mitigation Recommendations
No official patch or fix information is provided in the available data. Patch status is not yet confirmed — check the Python Software Foundation advisory for current remediation guidance. Users should avoid extracting untrusted tar archives with the affected filter parameters until a fix is available. For Python 3.14 or later, be aware that the default filter value changed to "data", which is affected. Exercise caution when installing source distributions with suspicious symbolic links, although this vulnerability does not significantly increase risk in that context.
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: 06/03/2025, 13:28:58 UTC
Last enriched: 08/07/2026, 14:59:41 UTC
Last updated: 09/10/2026, 19:36:50 UTC
Views: 168
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.