Python PTH File Creation During Package Installation
The following analytic detects the creation of a Python path configuration (`.pth`) file in conjunction with a package installation process. Path configuration files placed under `site-packages` or `dist-packages`…
Description
The following analytic detects the creation of a Python path configuration (`.pth`) file in conjunction with a package installation process. Path configuration files placed under `site-packages` or `dist-packages` are executed with every subsequent invocation of Python, allowing adversaries to achieve persistence on the victim endpoint regardless of build method or distribution type. This technique was used by the threat actor group TeamPCP during the supply chain compromise of the `litellm` package. If confirmed malicious, this could result in arbitrary code execution every time Python is invoked on the compromised host.
Detection logic
Detection requirements
- Platform
- IaaSLinuxmacOSOffice SuiteSaaSWindows
The rule states no platform. This is derived from the 2 ATT&CK techniques it maps to.
- Log source category
- sysmon_eventid_1_and_sysmon_eventid_11
Known benign triggers
- Legitimate packages, such as those managing namespace packages or editable installs, may create `.pth` files as part of normal installation. Investigate the file contents and parent process to determine legitimacy.
MITRE ATT&CK mappings
0 exclusive techniques.This is coverage no other published rule has; it is not this rule's total technique count.
References
| Reference | Cited by |
|---|---|
| blog.talosintelligence.com/the-serpents-tongue-luring-the-python-out-of-its-den/ | 4 |
From the source
- At source
- Open at source
- Upstream identifier
- bf581b86-39cd-48b7-9312-d9affb48a8bc
- Tagged by the source as
- Compromised Windows HostMalicious Python Package InstallationWindows Persistence TechniquesEndpointendpointSplunk CloudSplunk EnterpriseSplunk Enterprise Securityendpoint
Licence
- Published under
- Apache License 2.0Read the licence
- Attribution
- Required
- Obtained under
- Apache-2.0Read the origin licence
Authorship
- Written by
- Published
- Aug 26, 2026
- Version
- 1