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 Python Execution from Windows Store App Path
Possible Trojanised Python Native Extension Load of gradient Module
Malicious AI CLI Anti-Attribution and Permission Bypass Flags
Suspicious Python HTTP Server Staging for Payload Delivery
Suspicious Python Base64 Encoded Command Execution (via process_creation)
Suspicious __init__.py Drop in Public Directory by Slow Pisces (via file_event)
Malicious Python Reverse Shell One-Liner Execution (via process_creation)
Suspicious Silver Fox Backdoor Execution via pythonw appclient Module (via process_creation)
Suspicious Malicious MCP Package devtools-assistant Execution (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.