Windows: .pth Python Path Configuration File Created in site-packages or venv

Detects creation of Windows Python .pth files in site-packages/venv directories, which can enable code execution or persistence via Python startup.

FreeReviewedSigma · Medium · v5
Product
windows
Category
file_event
Author
Andreas Braathen (mnemonic.io), Nasreddine Bencherchali (Nextron Systems) (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 identifies file creation events for Python path configuration files (.pth) placed under Python library directories such as lib\site-packages (including virtual environment locations). Attackers can abuse .pth files because referenced modules are executed automatically at Python startup, enabling code execution and persistence. The detection relies on Windows file event telemetry capturing the created file path and the creating process image name, with exclusions for specific known .pth files associated with common extensions.

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)
Windows: .pth Python Path Configuration File Created in site-packages or venv
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.