Python Path Configuration File Creation - Linux
Description
Detects creation of a Python path configuration file (.pth) in Python library folders, which can be maliciously abused for code execution and persistence. Modules referenced by these files are run at every Python startup (v3.5+), regardless of whether the module is imported by the calling script. Default paths are '\lib\site-packages\*.pth' (Windows) and '/lib/pythonX.Y/site-packages/*.pth' (Unix and macOS).
Query · sigma
selection:
TargetFilename|re: (?i)/lib/python3\.([5-9]|[0-9]{2})/site-packages/
TargetFilename|endswith: .pth
condition: selection
Known false positives
- Although .pth files are discouraged due to potential security implications, these are legitimate files by specification.