Python Site Hooks Creation During Package Installation
The following analytic detects the creation of a Python site hook file (`sitecustomize.py` or `usercustomize.py`) within a `site-packages`/`dist-packages` directory in conjunction with a package installation process.…
Description
The following analytic detects the creation of a Python site hook file (`sitecustomize.py` or `usercustomize.py`) within a `site-packages`/`dist-packages` directory in conjunction with a package installation process. Python's `site` module loads these hooks from directories on `sys.path` before Python is executed. If an adversary manipulates or plants one of these files, they can hijack the Python environment and execute their payload with every Python invocation, achieving persistence on the victim endpoint. The VIPERTUNNEL backdoor was reported to abuse site hooks in order to import and trigger DLL execution. 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
- Some legitimate tooling and environment managers create or modify `sitecustomize.py`/`usercustomize.py` as part of normal setup. 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
- efaf40f5-779f-4b48-a941-b7d1a7c931ed
- 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