Security News

Tarfile: The 15 Years Old Critical Python Vulnerability Affects More Than 350,000 Projects

A critical security vulnerability has been identified in Python's Tarfile module that has not been updated for 15 years.

Brandefense logo Updated 3 Min Read
tarfile python vulnerability

A critical security vulnerability has been identified in Python that has not been updated for 15 years, leaving more than 350,000 open source projects vulnerable to attacks.

The vulnerability tracked as CVE-2007-4559 exists in the “Tarfile” module of Python, which is widely used in frameworks created by Netflix, AWS, Intel, Facebook, Google, and applications used for machine learning, automation, and docker containerization available via file. The tarfile module makes it possible to read and write tar archives, including gzip, bz2 and lzma compressed files. A successful exploit allows threat actors to execute arbitrary code on the vulnerable system or take control of a target system.

There is no update or mitigation suggestion to fix the said vulnerability. Therefore, thousands of Python projects are still vulnerable to vulnerability. In this context, it is recommended that the updates that are likely to be published regarding the vulnerability should be followed regularly and implemented immediately if published.

What exactly is the bug?

The NVD entry for CVE-2007-4559 describes a directory traversal flaw in the extract and extractall functions of the tarfile module. A user-assisted remote attacker can overwrite arbitrary files by putting .. sequences in the file names inside a TAR archive. NVD was first published on 28 August 2007 and now scores the issue 9.8 (critical) under CVSS 3.1. File names are the trigger in newer Python flaws too: in the Pillow file name flaw (CVE-2026-112900), a crafted image name adds Ghostscript options.

Who brought it back into the news?

Researchers at Trellix found the issue again while they were looking into an unrelated vulnerability. Techzine reported that the bug was first raised with the Python project in 2007 and was left alone because it seemed to be of low importance. The same report says the bug affects about 350,000 open-source projects, and that Trellix has patched nearly 62,000 of them.

What does Python’s documentation say now?

The alert above says no fix was available when it was written. Since then, Python has added a safer way to extract archives.

The Python tarfile documentation warns: “Never extract archives from untrusted sources without prior inspection.” Python 3.12 added a filter argument for extract() and extractall(). The values include 'data', which blocks most dangerous archive features. Python 3.14 made 'data' the default. The documentation adds that no filter stops every unsafe behavior, so untrusted archives still need extra checks.

What should developers do?

  • Search your code for tarfile, extract() and extractall().
  • Pass filter='data' on Python versions that support it.
  • Extract untrusted archives into a new temporary folder with limits on disk, memory and file count.
  • Check that each archive member stays inside the target folder before you write it.
Share