Vulnerability in the Python TarFile module allowing writing to any part of the filesystem

Five vulnerabilities have been identified in the standard Python tarfile module, which provides functions for reading and writing tar archives, one of which has been assigned a critical severity level. The vulnerabilities have been resolved in releases of Python 3.13.4 and 3.12.11. The most dangerous vulnerability (CVE-2025-4517) allows for writing files to any part of the filesystem when unpacking a specially crafted archive. In system scripts that use tarfile and are run with root permissions (for instance, in package management utilities and isolated containers), this vulnerability can be exploited to escalate privileges or escape the isolated container.

The vulnerability affects projects where the tarfile module is used to unpack untrusted tar archives, employing the TarFile.extractall() or TarFile.extract() functions with the 'filter=' parameter set to 'data' or 'tar'. It is caused by incorrect handling of the '..' sequence in symlink names. The issue affects versions of Python starting from 3.12. The 'filter='data'' mode is applied by default in the Python 3.14 branch currently under development (release scheduled for fall).

Other vulnerabilities in TarFile:

  • CVE-2025-4330 – the possibility of bypassing the data extraction filter, which may allow extracting a symlink pointing outside the base directory where unpacking occurs.
  • CVE-2025-4138 – the potential to create arbitrary symlinks outside of the base directory when unpacking archives with the 'filter='data'' parameter.
  • CVE-2024-12718 – the potential to modify metadata (such as modification time) of files outside the base directory when unpacking archives with the 'filter='data'' parameter or access rights (chmod) when unpacking archives with the 'filter='tar'' parameter.
  • CVE-2025-4435 – if the TarFile.errorlevel parameter is set to 0 during the unpacking of an archive, elements matching the specified filter criteria were unpacked instead of being ignored, contrary to the documentation.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster