
Cloud Vulnerability DB
A community-led vulnerabilities database
CVE-2026-2297 is a security audit bypass vulnerability in CPython's SourcelessFileLoader import hook, which handles legacy *.pyc files. Due to an incorrect isinstance() check in the FileLoader base class, SourcelessFileLoader uses _io.FileIO instead of io.open_code() to read .pyc files, causing sys.audit event handlers to silently not fire. This affects CPython versions prior to 3.15.0 across all supported branches (3.10 through 3.14). It was disclosed on March 4, 2026, and carries a CVSS v3.1 base score of 3.3 (Low) and a CVSS v4.0 base score of 5.7 (Medium) (CPython Issue, Red Hat Advisory).
The root cause is an incomplete isinstance() check in FileLoader.get_data() within Lib/importlib/_bootstrap_external.py (CWE-778: Insufficient Logging; CWE-668: Exposure of Resource to Wrong Sphere). The check isinstance(self, (SourceLoader, ExtensionFileLoader)) omits SourcelessFileLoader, so when that subclass calls get_data(), it falls through to the else branch and opens the file with _io.FileIO rather than _io.open_code(). Because io.open_code() is the designated hook point for security auditing of imported code, any sys.audit handler registered for the open_code event is bypassed entirely. The fix is a one-line change adding SourcelessFileLoader to the isinstance() tuple (CPython Commit, CPython Issue).
An attacker with low-privilege local access who can place or modify .pyc files on the Python import path can load malicious precompiled bytecode without triggering any sys.audit event handlers configured to detect such activity. This effectively allows code execution that circumvents security monitoring and compliance controls relying on io.open_code() hooks. Confidentiality and availability are not directly impacted; the primary risk is an integrity bypass of audit/monitoring controls, which could facilitate stealthy persistence or defense evasion in environments that depend on Python's audit event system (CPython Issue, Red Hat Advisory).
sys.audit handlers hooked via io.open_code() for security monitoring of imported modules.sys.path where the attacker has write access, or where .pyc files can be placed ahead of legitimate source files..pyc file: Compile a malicious Python script into a .pyc bytecode file using py_compile or compileall, targeting a module name that will be imported by the application..pyc file in a directory earlier on sys.path than the legitimate module, or ensure no corresponding .py source file exists so SourcelessFileLoader is invoked.SourcelessFileLoader.get_data() uses _io.FileIO instead of io.open_code(), any registered sys.audit handler for open_code does not fire, and the malicious bytecode executes undetected (CPython Issue)..pyc files in import path directories without corresponding .py source files, especially in locations writable by non-privileged users; unexpected or recently modified .pyc files in application or system Python library directories.sys.audit open_code events in security audit logs when Python modules are imported — a gap in audit trails may indicate exploitation.The Python Software Foundation released fixes for all supported branches on March 4, 2026. The patch adds SourcelessFileLoader to the isinstance() check in FileLoader.get_data(), ensuring io.open_code() is used consistently. Patched commits are available for CPython main, 3.14, 3.13, 3.12, 3.11, and 3.10 branches. Downstream distributions including Red Hat, SUSE, Fedora, Debian, and Amazon Linux 2023 have issued updated packages. Organizations should upgrade to patched CPython releases as soon as available for their distribution. As a workaround, restrict write access to Python import path directories to prevent unauthorized placement of .pyc files, and avoid deployments that rely solely on sys.audit hooks for security enforcement (CPython PR, Red Hat Advisory).
The vulnerability was reported and fixed by Steve Dower (zooba) of the Python Security Response Team (PSRT), who noted that real-world impact is expected to be very low given the rarity of SourcelessFileLoader usage in practice. The fix was reviewed and merged the same day it was disclosed. Multiple Linux distributions (Red Hat, SUSE, Fedora, Debian, Amazon Linux) promptly issued security advisories and updated packages. Community discussion was minimal given the low severity and narrow exploitation conditions (CPython Issue, oss-sec).
Source: This report was generated using AI
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."