Python's built-in tarfile module is commonly used to extract archives in applications, deployment tools, backup systems, and file-processing services. It also includes extraction filters designed to prevent malicious archive entries from writing files outside an intended directory.
But one of those protections had a gap.
On October 22, 2026, a security advisory disclosed CVE-2026-114583, a medium-severity vulnerability in CPython's tarfile.tar_filter. A specially crafted TAR archive could bypass the filter using link entries and cause files to be written outside the extraction directory.
The issue is particularly relevant to applications that accept TAR archives from users or external sources. <a href="https://mail.python.org/archives/list/security-announce@python.org/thread/43JOWPRAV5DI3VZ4FUEUAZOHCATXXOCK/">Python security announcement</a>
What Does Python's tarfile Filter Do?
The tarfile module allows Python applications to read and extract TAR archives. These archives can contain regular files, directories, symbolic links, hard links, and other filesystem information.
A basic extraction operation looks like this:
import tarfile
with tarfile.open("archive.tar.gz", "r:gz") as archive:
archive.extractall(path="extracted")
The problem is that an archive is not necessarily trustworthy just because it has a valid TAR format. Its entries can contain paths and links that behave differently from ordinary files.
To address this, Python introduced extraction filters in version 3.12. They let developers control which archive features are accepted during extraction.
Three built-in filters are available:
fully_trusted: Extracts archive entries without applying security restrictions.tar: Preserves most Unix-specific TAR features while blocking certain dangerous paths and entries.data: Provides stricter handling for archives intended to contain ordinary files and directories.
Python 3.14 also changed the default extraction filter to data. Earlier versions used behavior equivalent to fully_trusted by default. <a href="https://docs.python.org/3.14/library/tarfile.html#extraction-filters">Python tarfile documentation</a>
What Went Wrong in CVE-2026-114583?
The vulnerability was caused by how tarfile.tar_filter handled links that could replace the extraction destination itself.
Consider an application that extracts an uploaded archive into a dedicated directory:
/srv/uploads/extracted/
Normally, the application expects every extracted file to remain inside this directory.
However, a malicious TAR archive can contain a specially crafted symbolic or hard link entry. The important detail is that the link's own filename can be empty or resolve to the extraction directory itself.
If that entry is accepted, it can occupy the extraction destination with a link. Subsequent archive entries can then be redirected through that link to a different filesystem location.
As a result, files that were supposed to remain inside the extraction directory could be written somewhere else.
This is more subtle than a conventional ../ path traversal. The problem is not simply that a filename contains a path pointing outside the destination. The archive can manipulate the destination itself through a link entry.
The issue was reported in CPython on October 21, 2026, and the fix was merged on October 22. <a href="https://github.com/python/cpython/issues/160097">CPython issue #160097</a> · <a href="https://github.com/python/cpython/pull/160098">Fix in CPython pull request #160098</a>
Why Is This a Security Problem?
The immediate impact is writing files outside the directory the application intended to use.
The actual damage depends on the permissions of the process extracting the archive. A process running with limited permissions has a smaller potential impact than one running with access to sensitive application directories.
For example, imagine a backend service that accepts a TAR upload and extracts it automatically. If the extraction process runs with access to application configuration files, temporary directories, or other sensitive locations, an archive that escapes its intended destination can create a much bigger problem.
This does not automatically mean remote code execution. The vulnerability provides a path to unauthorized file writes, and further impact depends on where those writes land and what the affected system does with them.
How Did Python Fix the Vulnerability?
The fix makes tarfile.tar_filter() reject hard and symbolic link entries whose own path resolves to the extraction destination itself.
When such an entry is encountered, Python raises OutsideDestinationError rather than allowing the link to replace the destination.
This closes the gap that allowed later archive members to be redirected outside the extraction directory.
The change was implemented in CPython's tarfile module and included in security updates across maintained release branches. <a href="https://github.com/python/cpython/pull/160098">CPython security fix</a>
Which Python Versions Are Affected?
The upstream fixes are available in these Python releases:
| Python branch | Fixed release |
|---|---|
| Python 3.11 | 3.11.18 |
| Python 3.12 | 3.12.16 |
| Python 3.13 | 3.13.18 |
| Python 3.14 | 3.14.10 |
| Python 3.15 | 3.15.2 |
Earlier releases in these branches are affected when using the vulnerable tar_filter behavior.
Python's release team included the fix in its October 26, 2026 security release roundup. <a href="https://blog.python.org/2026/10/python-3152-31410-31318-31216-31118/">Python security release announcement</a>
Developers should check their deployed Python runtime rather than only the version installed on their local machine. Applications running inside Docker containers, virtual machines, and managed hosting environments may use different Python installations.
For distribution-managed Python packages, also check the operating system vendor's security advisory. A vendor can backport a fix without changing the upstream version number in the way you might expect.
How Should Developers Safely Extract TAR Archives?
Updating Python is the first step, but applications should also choose an appropriate extraction filter.
For archives containing ordinary user data, Python's data filter is generally the better choice:
import tarfile
import tempfile
with tempfile.TemporaryDirectory() as extract_dir:
with tarfile.open("uploaded.tar.gz", "r:*") as archive:
archive.extractall(
path=extract_dir,
filter="data"
)
# Validate and process extracted files here
The temporary directory provides isolation from existing application files and makes cleanup easier if extraction fails.
The data filter blocks several dangerous archive features, including links that point outside the destination and special device files. It is designed for data archives, not archives that need to preserve every Unix filesystem feature.
If your application genuinely needs Unix-specific archive behavior, tar may be more appropriate. In that case, run a patched Python release and validate the archive contents before using them.
There are a few additional precautions worth keeping in place:
- Avoid extracting untrusted archives directly into application directories or shared filesystem locations.
- Limit the number of files, individual file sizes, and total extracted size.
- Use filesystem quotas or operating-system resource limits to reduce denial-of-service risks.
- Reject symbolic links when the application does not need them.
- Run extraction with a dedicated account that has only the filesystem permissions it requires.
Remark: Even Python's data filter does not make archive extraction completely safe. It does not prevent every denial-of-service attack, and applications still need their own validation and resource limits. <a href="https://docs.python.org/3.14/library/tarfile.html#hints-for-further-verification">Python's extraction security guidance</a>
What Should You Do Now?
If your application accepts TAR archives, start by checking whether it explicitly uses filter="tar" or tarfile.tar_filter.
Upgrade the Python runtime to the appropriate fixed release, rebuild your deployment images, and make sure production services actually run the updated interpreter.
Also review any custom extraction logic. A safe-looking destination path is not enough if the archive itself can manipulate how later entries are resolved.
CVE-2026-114583 is a useful reminder that archive extraction is a security-sensitive operation. Even when a standard library provides built-in protections, developers should keep those protections updated and avoid treating them as a complete security boundary.
Sources



