CVE-2026-115791

Prevent shadowing stdlib in gzip/tarfile/zipfile CLI during extraction

Published Nov 10, 2026 CVSS 4.0 · 5.3 Medium EPSS < 1% KEV · Not listed
Description
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.

Analysis

AI-generated

Technical impact

The vulnerability stems from the tarfile, zipfile, and gzip command‑line interfaces in CPython, which during decompression can create a Python file that shadows a standard library module such as traceback.py. When a subsequent error occurs while decompressing, Python executes the newly created file because the current directory is added to sys.path when the CLI runs. This flaw permits an attacker to craft an archive that, when extracted, causes Python to run arbitrary code under the user’s privileges when the CLI fails. The weakness corresponds to CWE‑829, improper restriction on the path or resource exposed to the user.

Affected Systems

Python Software Foundation: CPython. The issue is present in the tarfile, zipfile, and gzip command‑line tools that extract archives in the current working directory. No specific version range is published, so all CPython releases that provide these tools and have not yet applied the upstream fix are considered vulnerable until an updated release is obtained.

Risk and Exploitability

The CVSS score of 5.3 classifies the flaw as moderate severity, and the EPSS score of less than 1% suggests a low probability of exploitation in the wild. The vulnerability is not listed in the CISA KEV catalog. The likely attack vector is local or remote if an application uses the Python CLI to process user‑supplied archives. Exploitation requires an error during extraction, meaning the attacker must trigger a failure condition, but once triggered the malicious script runs with the Python interpreter’s permissions. The upstream patch removes sys.path[0] for these interfaces, preventing the shadowing mechanism.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade CPython to a version where the tarfile, zipfile, and gzip CLI tools have been patched to exclude sys.path[0] from the extraction; the latest release includes the fix.
  • Run the extraction CLI from a clean temporary directory that does not contain files named after standard library modules.
  • Alternatively, set the PYTHONPATH environment variable to an empty string before running the extraction command to prevent the current directory from appearing in sys.path.

Generated by OpenCVE AI on November 15, 2026 at 04:08 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
First Time appeared Python
Python cpython
Python Software Foundation
Python Software Foundation cpython
Vendors & Products Python
Python cpython
Python Software Foundation
Python Software Foundation cpython
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
Weaknesses CWE-829
Type Values Removed Values Added
Description 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.
Title Prevent shadowing stdlib in gzip/tarfile/zipfile CLI during extraction
References
Metrics cvssV4_0

{'score': 5.3, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N'}

Weaknesses
  • CWE-829

    Inclusion of Functionality from Untrusted Control Sphere

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Nov 11, 2026, 4:56 AM
Reserved
Oct 23, 2026, 2:12 PM
Status
Awaiting Analysis
Published
Nov 10, 2026, 5:17 PM
Modified
Nov 11, 2026, 5:19 AM