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
Other sources
Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
When using Python's tarfile module to extract untrusted tar archives with TarFile.extractall() or TarFile.extract(), do not set the tarfile extraction filter parameter to "data" or "tar"; use a safer extraction filter value so symlink targets cannot point outside the destination directory and file metadata is not modified via the bypass described.
Python tarfile (TarFile.extractall()/TarFile.extract()) filter parameter = not "data" and not "tar" (use filtering) - Configuration
If you rely on Python's tarfile extraction filter default behavior, note that for Python 3.14 or later the default value of filter changed from "no filtering" to "data". Update your usage to explicitly pass a non-vulnerable filter value rather than relying on the "data" default when extracting untrusted archives.
Python tarfile (TarFile.extractall()/TarFile.extract()) filter default behavior = Python 3.14+: default is "data"
Event History
Frequently Asked Questions
What is the severity of CVE-2025-4138?
CVE-2025-4138 has a high severity due to the potential for directory traversal and metadata modification.
How do I fix CVE-2025-4138?
You can fix CVE-2025-4138 by upgrading to a patched version of the Python tarfile module.
What effect does CVE-2025-4138 have on file handling?
CVE-2025-4138 allows untrusted tar archives to bypass extraction filters, posing a risk to unauthorized file access.
Which versions of Python are affected by CVE-2025-4138?
CVE-2025-4138 impacts Python versions from 3.12 and above, including 3.14 and potential future releases.
How can I identify if my application is vulnerable to CVE-2025-4138?
To identify if your application is vulnerable to CVE-2025-4138, check if it uses the tarfile module with untrusted tar archives and the relevant Python versions.