AAK-STARTUP-HOOK-PTH-001
Startup code in a site-packages .pth or .start file
| Field | Value |
|---|---|
| Severity | HIGH |
| Category | SUPPLY_CHAIN |
| Shipped | v0.6.28 |
| Scanner | agent_audit_kit/scanners/startup_hooks.py |
| OWASP MCP | MCP04:2025 (Software Supply Chain Attacks & Dependency Tampering) |
| OWASP Agentic | ASI04 (Agentic Supply Chain Vulnerabilities), ASI05 (Unexpected Code Execution) |
| Incident | litellm 1.107.0, 21 Oct 2026 (OSV MAL-2026-2144, LiteLLM's post) |
What it catches
When Python starts, its site module reads every *.pth file at the top of
each site-packages directory and runs each line that starts with import.
Nothing has to import the package that shipped the file: pip, pytest and an
MCP server started from that environment all run it first. litellm 1.107.0 put
cook.pth, containing import cook, at the top of site-packages, and cook.py
stole credentials at every interpreter start.
Python 3.15 adds <name>.start files (PEP 829): each line names a
pkg.module:callable that Python calls at start-up. The rule reports those too.
How a line is read
| Python | What runs |
|---|---|
| 3.9 to 3.11 | a line that starts with import or import<TAB>, as written |
| 3.12 to 3.14 | the same test, after a leading BOM is dropped and the file is split with str.splitlines() |
| 3.15 | the same test after the line is stripped, so an indented import runs too; plus every entry point in a .start file |
(Read from the site.py of CPython 3.9.25, 3.10.19, 3.11.14, 3.12.12, 3.13.11,
3.14.2 and 3.15.2.)
The rule reports the union: a line that runs under any of them. A line that only names a directory is not code and is not reported.
What is not reported
- Files AAK built in clean environments on 2026-10-28 and lists in
agent_audit_kit/data/startup_hook_allowlist.json: setuptools'distutils-precedence.pth, the_virtualenv.pththat virtualenv and uv write, and coverage'sa1_coverage.pth. A file matches only by its name and the sha256 of its normalised content together, never by name alone: a malicious.pthcan call itselfdistutils-precedence.pth. - A setuptools editable install's finder (
__editable__.<project>-<version>.pth) is named after its project, so only the placeholder AAK built is allowlisted. Your ownpip install -e .is reported; it runs your checkout's code at every start. Exclude its path with--ignore-pathsonce you have looked. - The module a reported line imports is not read.
Where it looks
Every directory named site-packages or dist-packages up to 12 levels below
the scan root, including inside .venv/, venv/, env/, .tox/ and
vendor/, which every other rule skips. An MCP server's own environment under
the project is read the same way. To read an image, unpack its root filesystem
and scan that directory: see Scan a container image's files.
How to fix
Open the file and the module it imports. If no package you installed on purpose
wrote it (a package's .dist-info/RECORD lists every file it installed), delete
the file, its module and any __pycache__ copy, rebuild the environment or
image from a pinned lockfile rather than repairing it in place, and rotate every
credential the environment could reach.
Registry reference
This section is generated from the rule registry (agent_audit_kit/rules/builtin.py) when the documentation is built, so it follows the scanner. The rest of the page is hand-written; where the two disagree, the registry is what runs.
- Severity
- HIGH
- Category
- Supply Chain (
supply-chain) - Scanner
agent_audit_kit/scanners/startup_hooks.py- Auto-fixable
- No.
- SARIF name
PythonStartupHookPth
What it detects
A .pth file at the top of a site-packages or dist-packages directory has a line that starts with import, or a PEP 829 .start file names an entry point. Python runs that line, or calls that entry point, at every interpreter start, before any script and without the package being imported, so pip, a test run and an MCP server started from that environment all run it. litellm 1.107.0 (21 Oct 2026, OSV MAL-2026-2144) shipped cook.pth containing import cook and stole credentials that way. setuptools, virtualenv, uv and coverage write such files too; the ones AAK built and read are allowlisted by name and content together.
How to fix (registry)
Open the file and the module it imports. If no package you installed on purpose wrote it (its dist-info RECORD lists the files a package installed), delete it, its module and any __pycache__ copy, rebuild the environment or image from a pinned, known-good lockfile, and rotate every credential the environment could reach. If it is a hook you trust, exclude its path with --ignore-paths.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-STARTUP-HOOK-PTH-001
Limitations
Reads the .pth and .start files at the top of each directory named site-packages or dist-packages up to 12 directories below the scan root, the root itself included, and looks inside .venv, venv, env, .tox and vendor to find them; it follows no symlinked directory and skips node_modules, .git and the other build and cache directories AAK skips, and a Claude Code worktree under .claude/worktrees/. A .pth line is reported when it starts with import or import<TAB> after optional whitespace: Python 3.15 strips the line first, while 3.9 to 3.14 test it as written, so an indented line runs only on 3.15 and later. Lines are split as str.splitlines() splits them and a leading BOM is dropped. A line that only names a directory is not reported, although Python puts that directory on sys.path. Every line of a .start file that is not blank or a comment is reported as an entry point. A file named in data/startup_hook_allowlist.json with the same normalised content is not reported: setuptools' distutils-precedence.pth, the _virtualenv.pth that virtualenv and uv write, coverage's a1_coverage.pth (7.13.0 to 7.17.0) and the finder of one placeholder editable install, so a setuptools editable install of any other project is reported. The module a reported line imports is not read. An image is read only as an unpacked root filesystem given as the scan path, never from a registry. A startup file that is a symlink is read where the image reads it: an absolute target is taken under the scan root, and a link that still leads outside the root is not read. A startup file over 1 MB is refused, which marks the scan incomplete, and a FIFO or a device in its place is skipped.
References
- OWASP MCP Top 10: MCP04:2025 (Software Supply Chain Attacks & Dependency Tampering)
- OWASP Agentic Top 10: ASI04 (Agentic Supply Chain Vulnerabilities), ASI05 (Unexpected Code Execution (RCE))
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-SUPPLY-05 (Dangerous Install Script)
- Incidents and advisories: BERRIAI-LITELLM-2026-10-21
- CSA AI Controls Matrix (AICM): STA-08, IVS-04