Executive brief
CPython's import system fails to properly audit legacy *.pyc file reads, bypassing security monitoring that should trigger when code files are loaded. This allows code execution monitoring systems to miss when legacy compiled Python files are imported, reducing visibility into application runtime behavior.
Technical details
The SourcelessFileLoader class in CPython's importlib does not use io.open_code() when reading legacy *.pyc files, which is the documented mechanism for allowing sys.audit handlers to monitor code execution. This occurs in the base FileLoader class where the file reading takes place. The vulnerability affects the audit event chain and prevents security hooks from firing on *.pyc imports. The fix ensures SourcelessFileLoader properly uses io.open_code() for all code file reads. Patches are available in Python 3.11 and 3.13.
Affected products
- Python CPython 3.11 and earlier, 3.12, 3.13 prior to patch
Timeline
- 2026-03-04: disclosed
- 2026-03-04: patched: Patches applied to Python 3.11 and 3.13