CVE-2025-4138: Bypassing extraction filter to create symlinks to arbitrary targets outside extraction directory

Published Jun 3, 2025
·
Updated

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

11 affected componentsFixes available
pypi/tarfile>=3.12
pypi/tarfile>=3.14
IBM Cloud Pak System<=2.3.4.0
IBM Cloud Pak System<=2.3.4.1 2.3.4.1 ifix1
IBM Cloud Pak System<=2.3.5.0
IBM Cloud Pak System<=2.3.6.0
IBM OS Image for Red Hat Linux Systems<=4.0.4.0 4.0.5.0 4.0.6.0 4.0.7.0
IBM OS Image for Red Hat Linux Systems<=5.0.0.0 5.0.1.0
Microsoft cbl2 python3 3.9.19-14
Microsoft cbl2 python3 3.9.19-13
Microsoft azl3 python3 3.12.9-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. 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)
  2. 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

Jun 3, 2025
CVE Published
via MITRE·12:59 PM
Data Sourced
via MITRE·12:59 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·01:15 PM
DescriptionSeverityWeakness
Jun 12, 2025
Data Sourced
via Red Hat·09:04 AM
DescriptionSeverityAffected Software
Jul 11, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
SeverityAffected Software
Updated
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Jan 30, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

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.

2

How do I fix CVE-2025-4138?

You can fix CVE-2025-4138 by upgrading to a patched version of the Python tarfile module.

3

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.

4

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.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203