title: Python Sitecustomize Module Written To Site-Packages
id: a5e5aa98-437c-4661-9877-14b0dd29ec5e
status: experimental
description: |
    Detects the creation of a sitecustomize.py file inside a site-packages or dist-packages directory.
    Python imports this module automatically at every interpreter start, before any application code,
    which makes it a convenient persistence and execution point for malicious packages (litellm 1.107.0 used it
    for its hourly remote code loader). Very few legitimate packages ship one.
references:
    - https://docs.python.org/3/library/site.html
    - https://attack.mitre.org/techniques/T1546/018/
    - https://www.stepsecurity.io/blog/litellm-1-107-0-compromised-pypi-backdoored-wheels-credential-stealer
author: Chabnco
date: 2026-10-25
tags:
    - attack.persistence
    - attack.t1546.018
logsource:
    product: linux
    category: file_event
detection:
    selection:
        TargetFilename|contains:
            - '/site-packages/'
            - '/dist-packages/'
        TargetFilename|endswith: '/sitecustomize.py'
    condition: selection
falsepositives:
    - APM and coverage tooling that bootstraps itself through sitecustomize (check the package that owns the file)
    - Distribution packages that place a sitecustomize.py in dist-packages
level: medium
