LiteLLM 1.107.0: twelve bytes in site-packages turned every Python process into a credential stealer
$ cat site-packages/cook.pth
import cook
That’s the whole file. Twelve bytes, trailing newline included. It shipped in all seven litellm==1.107.0 wheels pushed to PyPI on October 21 between 11:39 and 11:40 UTC, and it was all it took to launch a full credential stealer every time Python started on the box. Not on import litellm. On every interpreter start, including the one you get when you run pip to uninstall the thing.
If you haven’t met it, LiteLLM is the gateway that lets you talk to a hundred-odd model providers through one API. Socket puts it at roughly 23 million downloads a week; Wiz counts about 49,000 downloads of the bad version before it was quarantined. And a model gateway is, by design, where a company keeps every LLM API key it owns. The attacker knew that. One whole module of the malware goes after the LiteLLM proxy’s database.
How it happened
LiteLLM published its postmortem on October 24. It’s worth reading end to end, mostly because the story starts five months before release day.
On May 27, a config file holding the master key for the LiteLLM Agent Platform got pushed to a public repo. The team noticed, force-pushed over the commit and flagged the key for revocation. Nobody revoked it. On October 10, someone used it to log into the platform and walked away with a GitHub CLI OAuth token that had no scope restrictions and belonged to the GitHub org owner. Two days later a second harvesting workflow picked up more tokens. Three engineers’ accounts in total.
At 10:08 UTC on October 21, branch protection was switched off. The private release workflow was edited to build from Berri-AI/litellm, a lookalike repo (the real org is BerriAI, no hyphen) where the attacker had stacked ten commits on top of the legitimate tag. One stolen account kicked off the workflow, a second one approved the production step. Wheels hit PyPI at 11:39, Docker images at 11:46. At 11:53 the attacker deleted the workflow run records. At 12:06 an Upwind researcher reported it. PyPI quarantined the version around 13:20; Docker Hub was cleaned up by 14:20.

This isn’t LiteLLM’s first time. Back in March 2026, versions 1.82.7 and 1.82.8 were backdoored by TeamPCP after a compromised Trivy release leaked CI secrets. JFrog is careful to say nothing links the two campaigns so far. Still, one project, two compromises in seven months, two different ways in: that tells you how attractive the target is.
The bit of the postmortem that stuck with me isn’t the lookalike repo. It’s May 27. The key was spotted, history was rewritten, revocation was written down somewhere. And that somewhere stayed an open task for 136 days. We have all seen that ticket.
Why a .pth file is enough
None of this is a vulnerability. It’s documented behaviour of Python’s site module: at startup the interpreter walks its site-packages directories, reads every .pth file, appends the lines to sys.path and executes any line that starts with import. Then it imports sitecustomize if one exists. ATT&CK recently got a sub-technique for exactly this, T1546.018 (Python Startup Hooks), filed under persistence.
I wanted to see how far it goes, so I set up a throwaway venv on Python 3.14 with a one-line labhook.pth that imports a module, which just prints its PID and argv to stderr.

Three takeaways. First, -I doesn’t help. Isolated mode ignores PYTHON* environment variables and the user site directory, but it still reads the interpreter’s own site-packages. Only -S turns site off, and nobody runs production apps with -S.
Then there’s pip. The admin who reads the advisory reaches for pip uninstall litellm or pip install litellm==1.106.2. Both start a Python interpreter in the infected environment, so both run cook.pth before doing anything else. That’s why LiteLLM’s postmortem tells you to delete the three files and kill the daemon before reinstalling.
The third one is nastier. An environment where nothing ever imports LiteLLM (a deploy script, a CLI tool, a notebook) gets hit exactly the same way, as long as the package landed in the same site-packages. A global pip install on a build box poisons every Python tool that runs there.
What the payload does
StepSecurity and Socket both decoded the other two files, and their write-ups agree.
cook.py is a single line of 22,251 characters, zlib-compressed base64 that unpacks to 61 KB of Python. The stealer calls itself privcollect. It runs in a daemon thread, sets PRIVCOLLECT_ACTIVE=1 so it won’t fire twice in one process, and drops /tmp/.pc_once_72129118c59f5636c0bb so it only collects once per host. The shopping list: Chrome, Chromium, Edge and Firefox passwords and cookies, ~/.ssh/ and ~/.gnupg/, AWS, Azure and gcloud credentials, ~/.kube/config, Vault, Terraform, npm, PyPI and GitHub CLI tokens, shell and database client history, and the config of twenty-plus AI coding tools (Socket calls out ~/.claude/.credentials.json). It also reads /proc/<pid>/environ for every process it can reach, which sweeps up secrets handed to other services as environment variables. On the cloud side, Socket notes it validates AWS keys with sts:GetCallerIdentity and queries instance metadata services.
And if DATABASE_URL is set, it runs this:
SELECT "credential_name", "credential_values" FROM "LiteLLM_CredentialsTable" LIMIT 500;
SELECT "model_name", "litellm_params" FROM "LiteLLM_ProxyModelTable" LIMIT 500;
On a LiteLLM proxy, that’s every upstream provider key, gone. The bundle is encrypted (AES-256-CBC, key wrapped with RSA-4096) and POSTed over plain HTTP to http://www.litellm.dev/healthcheck, with an X-Token: XWiA8gZNa7NcX2XRoAEb header and a Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0... user agent. Internet Explorer 7 on Windows 10, coming out of a Linux container. JFrog dates the litellm.dev registration to somewhere between October 13 and 18.
sitecustomize.py (25,509 bytes) is stage two. It grabs a non-blocking lock on /tmp/remote_code_loader.lock, forks into a daemon parented to PID 1, and every 3,600 seconds reads a domain name from https://raw.githubusercontent.com/letters9813/pythonclient-test/main/domain.txt, fetches http://<domain>/codepy and runs it through exec(). A textbook dead drop resolver. When Socket checked at 13:01 UTC on the 21st, the file came back empty: the channel was wired up but nothing was staged yet (or anymore). On Windows there’s no os.fork(), so the daemon quietly fails. The stealer still runs.
Wiz saw what came next in victim environments. Between 16:20 and 17:01 UTC the same day, from 168.100.8[.]57 and 165.227.201[.]8: GetCallerIdentity, then bedrock:ListFoundationModels, then ListRoles, ListUsers, ListAccessKeys, ListAccounts, DescribeTrails. Under five hours from release to stolen keys in use. The Bedrock part looks like LLMjacking (reselling or burning through the victim’s paid model access), but the IAM enumeration says the attacker had bigger plans too.
About that hash
While replaying the lab, I wrote my own cook.pth with printf 'import cook\n' and hashed it out of habit.

7f191632e7320705d154b85204f1ae546b543acbd7e8861229b76f5042b92bdb. The exact hash StepSecurity published for the malicious file. Of course it is: twelve predictable bytes make a predictable hash. That’s fine for detection (nobody has a legitimate reason to own this file), but it’s a good reminder of what a hash in an IOC feed is worth. It pins content, not intent. The first variant that writes import cook2 makes it useless, whereas “a .pth that runs code just appeared in site-packages” still holds.
The same screenshot shows the flip side. A clean Debian box with setuptools already has .pth files containing an import line: distutils-precedence.pth, shipped by setuptools. Add _virtualenv.pth, the __editable__ files from development installs, a few observability agents, and you have real background noise. Alerting on “any executable .pth” would drown you. Diffing an inventory week over week, on the other hand, works nicely.
The rules
Three rules, from most to least specific. All three pass sigma check with zero errors or issues, and I converted each to Splunk and Kusto to make sure the logic came out the way I meant it.
The first one targets the exact 1.107.0 artefacts. It’s for a retro hunt from October 21 onward, and for leaving in place a few weeks in case a stale Docker image is still running somewhere.
title: LiteLLM 1.107.0 Supply Chain Payload Artefacts
id: 02e51bf6-5f1d-47a6-881a-f105c1bf71e1
status: experimental
description: |
Detects files written by the malicious litellm 1.107.0 wheels published to PyPI on 2026-10-21:
the cook.pth startup hook and its cook.py stealer in site-packages, and the marker and lock files
the stealer and the hourly remote code loader create in /tmp.
references:
- https://docs.litellm.ai/blog/security-incident-oct-21-2026
- https://www.stepsecurity.io/blog/litellm-1-107-0-compromised-pypi-backdoored-wheels-credential-stealer
- https://socket.dev/blog/litellm-compromise
author: Chabnco
date: 2026-10-25
tags:
- attack.initial-access
- attack.t1195.002
- attack.persistence
- attack.t1546.018
- detection.emerging-threats
logsource:
product: linux
category: file_event
detection:
selection_hook:
TargetFilename|endswith:
- '/site-packages/cook.pth'
- '/site-packages/cook.py'
- '/dist-packages/cook.pth'
- '/dist-packages/cook.py'
selection_tmp:
- TargetFilename: '/tmp/remote_code_loader.lock'
- TargetFilename|startswith: '/tmp/.pc_once_'
condition: 1 of selection_*
falsepositives:
- Unlikely
level: critical
It assumes you collect file creation events on Linux hosts (Sysmon for Linux, an EDR, or auditd with watches on the right directories). Containers are where this usually falls apart: plenty of teams have zero file telemetry inside containers. If that’s you, image scanning and the script further down have to do the job instead.
The second is the long-term rule, the one that should survive the next variant. It looks for a sitecustomize.py showing up in a site-packages directory, which is rare in practice.
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
I wouldn’t route this one straight to triage. As a medium in a weekly hunting run, with a path allowlist built over the first two or three weeks, it reads very cleanly. I deliberately didn’t write the same rule for .pth files: given the noise above, you need to know your fleet first.
The third one watches the network. Sending the loot over cleartext HTTP was a gift: a proxy sees the host, path, method and user agent.
title: LiteLLM 1.107.0 Stealer Exfiltration Or Loader Dead Drop
id: 1abf6cd8-3560-454a-b6c9-3c11e3d75f9f
status: experimental
description: |
Detects HTTP traffic from the litellm 1.107.0 payload: the credential stealer posts its encrypted archive
over plain HTTP to www.litellm.dev/healthcheck with an X-Token header and an Internet Explorer 7 user agent,
and the remote code loader reads its next domain from a file on raw.githubusercontent.com every hour.
references:
- https://www.stepsecurity.io/blog/litellm-1-107-0-compromised-pypi-backdoored-wheels-credential-stealer
- https://socket.dev/blog/litellm-compromise
- https://www.wiz.io/blog/litellm-compromised-steals-credentials
author: Chabnco
date: 2026-10-25
tags:
- attack.exfiltration
- attack.t1041
- attack.command-and-control
- attack.t1102.001
- detection.emerging-threats
logsource:
category: proxy
detection:
selection_host:
- cs-host: 'litellm.dev'
- cs-host|endswith: '.litellm.dev'
selection_deaddrop:
c-uri|contains: 'raw.githubusercontent.com/letters9813/'
selection_ua:
c-useragent|contains: 'MSIE 7.0; Windows NT 10.0'
cs-method: 'POST'
condition: 1 of selection_*
falsepositives:
- None expected, the domain was registered by the attacker a few days before the release
level: high
Two caveats. The raw.githubusercontent.com request goes over HTTPS, so without TLS inspection your proxy only sees the hostname and selection_deaddrop will never fire. And the user agent selection is the one worth keeping once the dust settles: a POST with an MSIE 7 user agent leaving a server is suspicious whatever the destination. My first draft had a bare cs-host|endswith: 'litellm.dev' until I realised it also matched notlitellm.dev. Hence the two lines.
Cloud side: where the keys turn up next
If an affected host had AWS credentials, assume they’re gone and watch for where they reappear. Bedrock calls, InvokeModel and Converse included, are CloudTrail management events, so they’re logged by default; so is GetCallerIdentity. This Sentinel query looks for an identity showing up from an IP it hasn’t used in the previous 30 days and chaining an identity check with Bedrock or IAM enumeration.
let lookback = 30d;
let window = 1d;
// identity + IP pairs seen before the analysis window
let known = AWSCloudTrail
| where TimeGenerated between (ago(lookback) .. ago(window))
| where isnotempty(UserIdentityArn)
| distinct UserIdentityArn, SourceIpAddress;
AWSCloudTrail
| where TimeGenerated > ago(window)
| where isnotempty(UserIdentityArn)
| join kind=leftanti known on UserIdentityArn, SourceIpAddress
| summarize FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated),
WhoAmI = countif(EventName == "GetCallerIdentity"),
Bedrock = countif(EventSource == "bedrock.amazonaws.com"),
IamEnum = countif(EventSource == "iam.amazonaws.com" and EventName startswith "List"),
Calls = make_set(strcat(EventSource, ":", EventName), 50),
UserAgents = make_set(UserAgent, 5)
by UserIdentityArn, SourceIpAddress
| where WhoAmI > 0 and (Bedrock > 0 or IamEnum > 0)
| order by FirstSeen asc
It passes Microsoft’s official KQL parser against the AWSCloudTrail schema. That proves it’s valid, not that it returns the right rows in your tenant: I haven’t run it against real data. I group by ARN rather than access key ID because an instance role’s temporary keys rotate every few hours, while the session ARN (which often embeds the instance ID) stays put. If you run GuardDuty, the InstanceCredentialExfiltration.OutsideAWS finding already covers part of this for EC2 instance credentials; the query earns its keep on long-lived keys lifted from ~/.aws/credentials or a container’s environment.
As for the model provider keys (Anthropic, OpenAI, Together and friends) pulled from the proxy database, there’s no CloudTrail for those. Only each provider’s usage dashboard will show the spike. Nobody watches that, and it’s the easiest part for the attacker to cash in.
Monday morning
| Question | Where to look |
|---|---|
| Did we install 1.107.0? | lockfiles and SBOMs, internal PyPI mirror logs, pip show litellm on hosts, any litellm-1.107.0.dist-info |
| Did an affected Docker image run? | digest sha256:1bbcb1443bc962e45f5aad53fe3d2c30600e0379715fb6c664cdd3ac126c339e in your registry and orchestrator history; mutable latest, main-latest, main-stable tags pulled on October 21 between 11:46 and 14:20 UTC |
| Did the payload run? | /tmp/.pc_once_*, /tmp/remote_code_loader.lock, an orphaned Python process parented to PID 1 |
| Did it exfiltrate? | proxy and DNS logs for litellm.dev, POSTs with an MSIE 7.0 user agent |
| Were the secrets used? | the CloudTrail query above, usage at each model provider, new GitHub or PyPI tokens used from unknown IPs |
On a confirmed host, order matters. Kill the daemon and delete cook.pth, cook.py and sitecustomize.py by hand first, without starting Python in that environment. Then rebuild (a clean image pinned to 1.106.2 or by digest) instead of patching in place. Only then rotate everything the machine could read: IAM roles, model provider keys, connection strings, Git tokens, SSH keys. On a LiteLLM proxy that means every upstream key, not just the server’s own.
The script behind the screenshot above is deliberately bare, no dependencies, so you can drop it on a host or into a docker run --entrypoint:
#!/usr/bin/env python3
"""List what runs at Python startup: .pth files with import lines, sitecustomize.py, 1.107.0 IOCs."""
import hashlib, os, sys
IOC_NAMES = {"cook.pth", "cook.py"}
SKIP = {"node_modules", ".git", "proc", "sys", "__pycache__"}
roots = sys.argv[1:] or ["/usr/lib", "/usr/local/lib", "/opt", "/home", "/root", "/app"]
def sha(path):
return hashlib.sha256(open(path, "rb").read()).hexdigest()[:16]
for root in roots:
for d, dirs, files in os.walk(root):
dirs[:] = [x for x in dirs if x not in SKIP]
if os.path.basename(d) not in ("site-packages", "dist-packages"):
continue
dirs[:] = [] # no need to walk into the packages themselves
for name in sorted(files):
path = os.path.join(d, name)
if name in IOC_NAMES:
print(f"IOC {path} sha256={sha(path)}…")
elif name == "sitecustomize.py":
print(f"SITECUST {path} sha256={sha(path)}…")
elif name.endswith(".pth"):
with open(path, errors="replace") as f:
# site only executes lines that start with "import"
code = [l.strip() for l in f if l.startswith(("import ", "import\t"))]
if code:
print(f"EXEC {path} sha256={sha(path)}… {code[0][:60]}")
Yes, it’s a Python script. Run it with python3 -S, or with an interpreter that isn’t the suspect environment’s, or you’ll trigger the hook while hunting for it.
What this says about the controls we think we have
JFrog makes a point that should bother every team that says it “reviews its dependencies’ code”: the 1.107.0 sdist (the source archive) doesn’t contain the three files. They only exist in the wheels, pulled into the build by a data = "cook" line under [tool.maturin] in the lookalike repo’s pyproject.toml. Reading the Git tag or the source tarball showed nothing. And the release went through the real pipeline, with the real publishing and signing machinery: everything that vouches for “built by the official pipeline” was telling the truth. The official pipeline had just built code from somewhere else.
I don’t think a SOC can prevent this. What it can do is answer “where does this package run, which version, since when” within an hour, and have file and network telemetry where the LLM gateways live. Those boxes hold more secrets than most domain controllers, and they’re rarely treated that way. The question I keep coming back to, and haven’t answered: how many of us have an inventory of the .pth files in our production images? Probably nobody. It takes ten minutes to build with the script above.
References
- LiteLLM, Contained: Oct 21, 2026 LiteLLM release v1.107.0 Compromised (postmortem, October 24, 2026)
- BerriAI, issue #47826
- StepSecurity, litellm 1.107.0 Compromised on PyPI: Backdoored Wheels Drop a Credential Stealer and an Hourly Remote Code Loader
- Socket, LiteLLM PyPI Package and Docker Images Compromised to Steal Cloud and AI Credentials
- Wiz, LiteLLM Compromised, Steals Credentials
- JFrog Security Research, LiteLLM Hijacked Again
- Datadog Security Labs, LiteLLM supply chain compromise: What you need to know
- Python, site module documentation
- MITRE ATT&CK, T1546.018 Python Startup Hooks
- AWS, Monitor Amazon Bedrock API calls using CloudTrail