// Security Advisory Triage

Python tarfile, zipfile, gzip CLIs allow code execution via stdlib shadowing

Python security announcements · published 2026-11-13 19:46 UTC
ACTION NEEDED VERIFY_EXPOSURE SECURITY
WHAT CHANGEDCVE-2026-115791 discloses that when tarfile, zipfile or gzip command line interfaces decompress an archive, a malicious archive can place a Python script (especially traceback.py) in the current directory. If decompression of a subsequent file errors, Python executes the attacker's script instead of the stdlib module because sys.path[0] includes the current directory. The fix removes sys.path[0] from these three CLI tools. Severity: MEDIUM.
WHY IT MATTERSAny script or automation that uses `python -m tarfile`, `python -m zipfile`, or `python -m gzip` to extract untrusted archives can execute arbitrary code from the archive contents. The attack succeeds when any file after the malicious script triggers a decompression error, making exploitation straightforward.
WHAT TO DOCheck whether any automation, CI pipelines, or deployment scripts use `python -m tarfile`, `python -m zipfile`, or `python -m gzip` to extract archives. If so, verify exposure against the affected versions listed at https://www.cve.org/CVERecord?id=CVE-2026-115791 and apply the patched CPython release.
Model-reported confidence 85% (not measured accuracy) Primary source ↗ written by anthropic/claude-sonnet-4.5
Show the reasoning — raw diff, triage verdict, confidence
RAW DIFF
+## [Security-announce][CVE-2026-115791] Prevent shadowing stdlib in gzip/tarfile/zipfile CLI
+https://mail.python.org/archives/list/security-announce@python.org/message/ZKKA4Q7B35JEHSDIJNZ6TYKRDQJUHDAG/
+Tue, 10 Nov 2026 16:00:26 +0000
+
+There is a MEDIUM severity vulnerability affecting CPython.
+
+When tarfile or zipfile command line interface (CLI) is used to
+decompress an archive, a Python script shadowing the stdlib can be
+created. Then if an error occurs during decompressing the next file,
+the newly created Python script is executed. This is especially true
+if the created Python is called traceback.py. The problem is that
+Python adds the current directory to sys.path when python -m MODULE is
+run, and the archive is also decompressed in the current directory.
+
+The fix removes sys.path[0] in gzip, tarfile and zipfile command line
+interface to prevent shadowing standard library modules from extracted
+files.
+
+Please see the linked CVE ID for the latest information on affected versions:
+
+* https://www.cve.org/CVERecord?id=CVE-2026-115791
+* https://github.com/python/cpython/issues/161705
HOW IT WAS JUDGED
Triage signals below are model-reported assertions, preserved verbatim; they are not independent arithmetic verification.
triage verdictMATERIAL at 0.92, needed 0.5
triage reasoningCPython stdlib CLI vulnerability enabling arbitrary code execution during archive decompression. Python runtime is infrastructure-critical.
signalsaffects Python runtime (CPython) · affects CLI tools in standard library (tarfile, zipfile, gzip) · arbitrary code execution via sys.path shadowing · Python is in dependency tree of normal services · MEDIUM severity with clear exploitation path
suppression—
triage modelanthropic/claude-haiku-4.5 ($0.00000)
writer modelanthropic/claude-sonnet-4.5 ($0.00000)