install-time hook
Code a package runs while it is being installed or built, before you ever import it.
A malicious package runs with your credentials the moment you install it.
In more detail
Installing a source distribution imports its declared build backend and calls hooks such as get_requires_for_build_wheel, running as you with your tokens. Attackers use this step to steal credentials before any import happens.
Example
The course's hook writes a file to disk to prove it; real attacks use this step to steal credentials.Related terms
- build backend — The library a Python project names to turn its source into installable files; the build frontend, such as pip, calls it.
- source distribution — A package file containing a project's source code and metadata, from which an installer can build and install it.
- wheel — The standard ready-to-install package file for Python, with a .whl extension, which pip can install without building anything.
Taught in
- Dependency Risk And Typosquatting — Application Security & Threat Modeling for Engineers