macOS Python Site-Packages .pth File Creation

Alerts on new .pth files created under macOS Python site-packages, a mechanism that can execute code at Python startup.

FreeReviewedSigma · Medium · v5
Product
macos
Category
file_event
Author
Andreas Braathen (mnemonic.io) (SigmaHQ), DRL 1.1
Published
2024-04-25
Updated
2026-07-31

ATT&CK techniques

Execution
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Persistence

  5. Priv Esc

  6. Defense Evasion

  7. Cred Access

  8. Discovery

  9. Lateral Movement

  10. Collection

  11. C2

  12. Exfiltration

  13. Impact

What it detects

This rule flags creation of Python path configuration files (.pth) under the macOS Python site-packages directory. .pth files can execute code during Python startup, enabling persistence or execution without the target module being explicitly imported by the initiating script. It relies on file creation telemetry capturing the target filename and matching it to the expected site-packages path and .pth extension.

Related detections9 linkedT1059.006 — drag to rearrange
Suspicious Child Process Spawned by Python Interpreter via Process Creation
Suspicious Kimsuky Python Backdoor Staging in Winii Directory (via file_event)
SynkLoader Python Stager Execution from AppData via pythonw (via process_creation)
Malicious TeamPCP durabletask Payload python3 managed.pyz from tmp (via process_creation)
Suspicious Python Startup .pth File Creation for Interpreter Persistence
AteraAgent malicious installations
Suspicious Python Execution from WebDAV Share via PowerShell (via process_creation)
Malicious InvisibleFerret Python Loader Execution from Hidden .pyp Directory
StealC Loader Execution via Blender Spawning Script Interpreter (via process_creation)
macOS Python Site-Packages .pth File Creation
Pivot detection · T1059.006 · 9 related

Changelog

v5
  1. v5
    Candidate ingested via manual entry.2026-07-31
  2. v4
    Candidate ingested via manual entry.2026-07-31
  3. v3
    Candidate ingested via manual entry.2026-07-31
  4. v2
    Candidate ingested via manual entry.2026-07-31
  5. v1
    No changelog recorded for this version.2026-07-30

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.