CVE-2026-2297

SourcelessFileLoader does not use io.open_code()

Published Mar 4, 2026 CVSS 4.0 · 5.7 Medium EPSS < 1% KEV · Not listed
Description
The import hook in CPython that handles legacy *.pyc files (SourcelessFileLoader) is incorrectly handled in FileLoader (a base class) and so does not use io.open_code() to read the .pyc files. sys.audit handlers for this audit event therefore do not fire.

Analysis

AI-generated

Technical impact

The flaw lies in CPython’s import hook for legacy byte‑code files; it fails to invoke io.open_code(), preventing sys.audit handlers from firing for this import event. As a result, any code loaded from a *.pyc file can execute without generating the expected audit trail, allowing an attacker to run covert or malicious code without triggering detection mechanisms.

Affected Systems

Python Software Foundation’s CPython implementation is affected. No specific product versions are listed, so all releases that still use the legacy import hook for legacy .pyc files are potentially vulnerable and should be treated as impacted until a fix is released.

Risk and Exploitability

The CVSS score of 5.7 indicates a moderate severity, with an EPSS score of less than 1 % suggesting low historical exploitation probability. The vulnerability is not currently listed in CISA’s KEV catalog. The most likely attack vector is through the local execution of malicious .pyc files or a local attacker having the ability to place such files in a location that Python will import. Once a .pyc is imported, the missing audit event means the operation can proceed silently, facilitating covert execution of arbitrary code.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply a Python release that corrects the import hook to use io.open_code() and triggers audit events; upgrade when available.
  • Configure audit logging to record all module imports or enforce strict whitelisting of .pyc files in trusted directories.
  • Restrict placement of .pyc files to trusted, isolated directories and remove any untrusted .pyc files from the PYTHONPATH or import locations.

Generated by OpenCVE AI on April 15, 2026 at 20:03 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4583-1 python3.9 security update
Ubuntu USN Ubuntu USN USN-8509-1 Python vulnerabilities
History
Type Values Removed Values Added
Weaknesses CWE-668
Metrics ssvc

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

Type Values Removed Values Added
Weaknesses CWE-778
References
Metrics threat_severity

None

cvssV3_1

{'score': 3.3, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N'}

threat_severity

Low

Type Values Removed Values Added
First Time appeared Python
Python cpython
Vendors & Products Python
Python cpython
Type Values Removed Values Added
Description The import hook in CPython that handles legacy *.pyc files (SourcelessFileLoader) is incorrectly handled in FileLoader (a base class) and so does not use io.open_code() to read the .pyc files. sys.audit handlers for this audit event therefore do not fire.
Title SourcelessFileLoader does not use io.open_code()
References
Metrics cvssV4_0

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

Weaknesses
  • CWE-668

    Exposure of Resource to Wrong Sphere

  • CWE-778

    Insufficient Logging

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Aug 13, 2026, 12:28 AM
Reserved
Feb 10, 2026, 4:26 PM
Status
Awaiting Analysis
Published
Mar 4, 2026, 11:16 PM
Modified
Aug 13, 2026, 1:16 AM
Severity
Low
Public date
Mar 4, 2026, 10:10 PM