CVE-2026-2297
Rocky Linux vulnerability analysis and mitigation

Overview

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).

Technical details

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).

Impact

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).

Exploitation steps

  1. Identify target environment: Confirm the target system runs CPython < 3.15.0 and that the application or environment relies on sys.audit handlers hooked via io.open_code() for security monitoring of imported modules.
  2. Locate import paths: Identify directories on sys.path where the attacker has write access, or where .pyc files can be placed ahead of legitimate source files.
  3. Craft malicious .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.
  4. Remove or shadow source file: Place the malicious .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.
  5. Trigger import: Cause the target application to import the targeted module (e.g., via normal application execution or by triggering a code path that imports it).
  6. Bypass audit handlers: Because 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).

Indicators of compromise

  • File System: Presence of .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.
  • Logs: Absence of expected sys.audit open_code events in security audit logs when Python modules are imported — a gap in audit trails may indicate exploitation.
  • Process: Python processes importing modules from unusual or user-writable directories; unexpected behavior from Python applications that could indicate execution of unauthorized bytecode.

Mitigation and workarounds

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).

Community reactions

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).

Additional resources


SourceThis report was generated using AI

Related Rocky Linux vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-64600HIGH7.8
  • Linux Kernel logoLinux Kernel
  • kernel-debug
NoYesJul 23, 2026
CVE-2026-47063HIGH7.5
  • Amazon Corretto JDK logoAmazon Corretto JDK
  • java-17-openjdk-jmods
NoYesJul 21, 2026
CVE-2026-60147MEDIUM6.5
  • Amazon Corretto JDK logoAmazon Corretto JDK
  • java-1.8.0-openjdk-demo
NoYesJul 21, 2026
CVE-2026-47059LOW3.7
  • Amazon Corretto JDK logoAmazon Corretto JDK
  • java-11-amazon-corretto
NoYesJul 21, 2026
CVE-2026-14957NONEN/A
  • Rocky Linux logoRocky Linux
  • libreswan
NoYesJul 27, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management