sitecustomize.py is a Python module that the interpreter may import automatically during startup when normal site initialization is enabled. It lets administrators or environments apply custom settings, but its code can run before an application imports its own packages.
This startup behavior matters for security because a malicious or altered sitecustomize.py can execute in every Python process that loads it, potentially accessing secrets or changing runtime behavior. In attacks, it may be planted in an environment by a compromised package or deployment artifact; defenders should inspect installed files, verify package and image integrity, and investigate unexpected startup customization. Python options that disable site initialization can prevent this mechanism, but may also change expected environment behavior.


