CVE-2026-115791
CLI archive extraction can execute malicious shadowed stdlib modules (e.g., traceback.py).
- CVSS 5.3
- CWE-829
- Input Validation and Sanitization
- Local
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.
- CWE
- CWE-829
- CVSS base score
- 5.3
- Published
- 2026-11-10
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- gzip, tarfile, zipfile
- Fixed by upgrading
- Yes
Solution
Upgrade Python to 3.12.2 or later (the fix removing sys.path[0] in the gzip, tarfile, and zipfile CLIs is included from this version onward).
Vulnerable code sample
import sys
import tarfile
def extract_archive():
# VULNERABLE: current directory stays in sys.path, allowing shadowing of stdlib modules
archive = sys.argv[1] if len(sys.argv) > 1 else "archive.tar"
with tarfile.open(archive, "r:*") as tf:
tf.extractall()Patched code sample
import sys
import tarfile
def extract_archive():
# FIX: remove current directory from sys.path to prevent stdlib shadowing
if sys.path and sys.path[0] == '':
sys.path.pop(0)
archive = sys.argv[1] if len(sys.argv) > 1 else "archive.tar"
with tarfile.open(archive, "r:*") as tf:
tf.extractall()Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- gh-161705: Prevent shadowing stdlib in gzip/tarfile/zipfile CLI (python/cpython)
Lib/gzip.py · main,Lib/runpy.py,Lib/tarfile.py,Lib/zipfile/__init__.py · main
Cite this entry
@misc{vaitp:cve2026115791,
title = {{CLI archive extraction can execute malicious shadowed stdlib modules (e.g., traceback.py).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-115791},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-115791/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
