In the standard Python module tarfile, which provides functions for reading and writing tar archives, five vulnerabilities have been identified, one of which is assigned a critical severity level. The vulnerabilities have been fixed in releases Python 3.13.4 and 3.12.11. The most dangerous vulnerability (CVE-2025-4517) allows files to be written to any part of the file system when unpacking a specially crafted archive. In system scripts that use tarfile and are run with root privileges (for example, in package management tools and isolated containers), the vulnerability can be exploited for privilege escalation or to break out of the isolated container.
The vulnerability affects projects where the tarfile module is used to unpack untrusted tar archives, using the TarFile.extractall() or TarFile.extract() function with the 'filter=' parameter set to 'data' or 'tar'. The vulnerability is caused by improper handling of the '..' sequence in the link name. The issue affects Python versions starting from 3.12. The 'filter="data"' mode is applied by default in the Python 3.14 branch that is currently in development (release scheduled for fall).
Other vulnerabilities in TarFile:
- CVE-2025-4330 ā allows bypassing the extracted data filter, which may lead to extracting a symbolic link from the archive pointing outside the base directory into which unpacking is performed.
- CVE-2025-4138 ā permits the creation of arbitrary symbolic links outside the base directory when unpacking archives with the parameter 'filter="data"'.
- CVE-2024-12718 ā allows modification of metadata (such as modification time) of files outside the base directory when unpacking archives with the parameter 'filter="data"' or permissions (chmod) when unpacking archives with the parameter 'filter="tar"'.
- CVE-2025-4435 ā if the TarFile.errorlevel parameter is set to 0 during unpacking, the elements of the archive that meet the specified filter were unpacked, contrary to the documentation, instead of being ignored.
Avots: opennet.lv
