CVE-2025-4138: Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory
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.
Security readout for executives and security teams
Plain-English summary
A malicious TAR archive can bypass Python’s intended extraction protections by creating symbolic links that point outside the chosen destination. This breaks the expected containment boundary and may expose sensitive files. Risk exists only where applications extract untrusted archives through the affected tarfile interfaces.
Executive priority
Treat this as urgent where public or otherwise untrusted TAR files are processed. Elsewhere, complete exposure inventory promptly and remediate within the normal high-severity window. The absence of confirmed exploitation lowers immediate incident-response urgency, but it does not reduce risk for exposed extraction services.
Technical view
CVE-2025-4138 affects CPython tarfile extraction using TarFile.extractall() or TarFile.extract() with filter="data" or filter="tar". Crafted symlink targets can escape the destination directory, and some file metadata can be modified. Python 3.14’s default "data" filter is also affected. The supplied CVSS 3.1 score is 7.5, emphasizing confidentiality impact.
Likely exposure
Exposure is concentrated in applications that extract untrusted TAR archives using the affected calls and filters. Python 3.14 users relying on the new default filter may also be exposed. Applications that do not process untrusted TAR archives through these paths are unlikely to be affected.
Exploitation context
The supplied record does not list this CVE in KEV and provides no evidence of active exploitation. Its CVSS vector describes network reachability, low complexity, no required privileges, and no user interaction, but practical exploitation still requires an application to extract an attacker-controlled archive through an affected path.
Researcher notes
The structured affected data names specific CPython versions but does not provide clear fixed-release boundaries; its default status is unaffected. Avoid generalizing entire release branches without consulting vendor guidance. Review the linked issue, patch, commits, and mitigation for branch-specific behavior. Source-distribution installation is not materially worsened because builds already permit arbitrary code execution.
Mitigation direction
Inventory applications using TarFile.extractall() or TarFile.extract() on untrusted archives.
Upgrade affected CPython runtimes to fixed releases identified by Python’s security guidance.
Until upgraded, avoid processing untrusted TAR archives through affected extraction paths.
Review the cited vendor mitigation before implementing temporary application-level controls.
Validation and detection
Record Python versions for every workload that extracts untrusted TAR archives.
Search application code for affected extraction calls, filters, and trust boundaries.
Confirm fixed-version applicability against the Python advisory because this bundle lacks precise fixed-release mapping.
Run non-destructive regression tests confirming extraction cannot create symlink targets outside the destination.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-22: File access and web shell behavior lookup
File traversal and upload weaknesses can lead teams to review file, web shell, execution, and collection telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references code or command execution, so execution technique review may help defensive triage. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-22 · source CWE mapping
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.