CVE-2024-12718: Bypass extraction filter to modify file metadata outside extraction directory

Published Jun 3, 2025
·
Updated

Allows modifying some file metadata (e.g. last modified) with filter="data" or file permissions (chmod) with filter="tar" of files outside the extraction directory. 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. Only Python versions 3.12 or later are affected by these vulnerabilities, earlier versions don't include the extraction filter feature.

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.

Other sources

Bypass extraction filter to modify file metadata outside extraction directory

Microsoft

Affected Software

5 affected componentsFixes available
pypi/tarfile>=3.12
pypi/tarfile>=3.14
Microsoft cbl2 python3 3.9.19-13<3.9.19-14
3.9.19-14
Microsoft cbl2 python3 3.9.19-14<3.9.19-14
3.9.19-14
Microsoft azl3 python3 3.12.9-1<3.12.9-2
3.12.9-2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.9.19-14
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.12.9-2
  3. Configuration

    When extracting untrusted tar archives with tarfile.TarFile.extractall() or tarfile.TarFile.extract(), do not use filter="data" or filter="tar". The vulnerability affects Python versions 3.12 and later when using tarfile extraction filters with those values and may allow modifying file metadata (including last-modified and chmod) outside the extraction directory.

    Python tarfile (TarFile.extractall / TarFile.extract) filter parameter = (do not use "data" or "tar" for untrusted archives)
  4. Compensating control

    Avoid installing/extracting source distributions (tar archives) that contain suspicious links when evaluating source distributions.

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
Data Sourced
via Red Hat·02:01 PM
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
DescriptionSeverity
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-2024-12718?

CVE-2024-12718 has been rated as a medium severity vulnerability due to its potential impact on file metadata and permissions.

2

How do I fix CVE-2024-12718?

To mitigate CVE-2024-12718, avoid extracting untrusted tar archives using the tarfile module in affected versions of Python.

3

Which versions of Python are affected by CVE-2024-12718?

CVE-2024-12718 affects Python versions starting from 3.12 up to but not explicitly limited to 3.14.

4

What are the consequences of CVE-2024-12718?

The consequences of CVE-2024-12718 include the ability to modify file metadata and permissions of files outside the designated extraction directory.

5

Is there a workaround for CVE-2024-12718?

As a workaround for CVE-2024-12718, ensure that only trusted tar archives are processed and consider using alternative methods to extract tar files.

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