Backdoored LiteLLM 1.107.0 Ran Every Time Python Started. Here's How to Check Without Setting It Off
For about two hours on 21 October (UTC), LiteLLM 1.107.0 on PyPI and its Docker latest tags carried a credential stealer and a backdoor that ran on every Python start. Here's who's affected, how to check from the shell without triggering it, and what to rotate.
If you run LiteLLM, the open-source gateway that sits between your apps and AI providers like OpenAI and Anthropic, check your installs and containers now. On 21 October, version 1.107.0 was published to PyPI and to the official Docker images with a credential stealer and a backdoor built in. It was up for about two hours before it was pulled. LiteLLM's incident report says "All previous versions are safe", and the last clean release is 1.106.2.
In short: if you installed litellm without a pinned version, or pulled the latest, main-latest, main-stable or v1.107.0 image, between 10:39 pm on 21 October and 1:20 am on 22 October AEDT, treat that machine or container as compromised. Don't run pip or Python on it to check, because that runs the malware again. Check from the shell, rebuild on 1.106.2, and rotate every secret the machine could reach.
The bad wheels went up at 11:39 UTC on 21 October (10:39 pm AEDT). PyPI had removed them by 13:23 UTC (12:23 am AEDT on 22 October), and the last of the Docker Hub tags were cleaned up at 14:20 UTC (1:20 am AEDT). The Register puts LiteLLM at about 23 million downloads a week, so even a short window matters.
Jump to: What happened · What the malware does · Am I affected? · Check from the shell first · Docker checks · If you were hit · Why .pth files are so nasty · My take
What happened
LiteLLM's own report is unusually detailed, and it's a story about stolen tokens rather than a clever exploit. The attacker held GitHub CLI login tokens for three LiteLLM developers, one of them an owner of the GitHub organisation. With that owner's token they turned off branch protection on LiteLLM's private release workflow and changed it so it could build from a different repository. They then pointed it at a lookalike, Berri-AI/litellm (the real one is BerriAI/litellm), and used a second developer's token to pass the production approval step. LiteLLM's own pipeline then "signed and published the poisoned artifacts". A third developer's token was used to delete the workflow records afterwards.
The timeline, from LiteLLM's report (UTC on 21 October, AEDT in brackets):
| UTC | AEDT | What happened |
|---|---|---|
| 10:08 | 9:08 pm, 21 Oct | A privileged developer's credential overrode branch protection on the release workflow |
| 10:46 | 9:46 pm | A staging run built from the lookalike Berri-AI/litellm repository |
| 11:11 | 10:11 pm | A second developer's credential passed the production approval gate |
| 11:39–11:40 | 10:39–10:40 pm | Seven malicious litellm==1.107.0 wheels uploaded to PyPI |
| 11:46 | 10:46 pm | Malicious Docker images published |
| 11:53 | 10:53 pm | A third developer's credential deleted the workflow records |
| 13:23 | 12:23 am, 22 Oct | PyPI had removed 1.107.0 |
| 13:51 | 12:51 am | The GHCR tags were found to be unavailable |
| 14:20 | 1:20 am | All Docker Hub tags removed or pointed back at clean images |
Two details stand out. Release permissions had been widened "temporarily" on the Monday so two engineers could publish bugfix backports. And LiteLLM believes the tokens came from the logs of its own internal LiteLLM deployment, which was exposed to the public internet and had "an unexpected, innocuously named user account" on it.
LiteLLM also says it has "observed specific situations in which Claude Code will embed a user's GitHub CLI OAuth token into a response body", which is how the tokens would have ended up in the gateway's logs. That's LiteLLM's claim. I haven't found anything from Anthropic confirming or disputing it. LiteLLM also hasn't confirmed how the attacker got into the internal deployment in the first place. It currently suspects "a recently patched vulnerability".
The malicious files aren't in the v1.107.0 tag on GitHub. They were added at build time with one extra line, data = "cook", in the [tool.maturin] section of pyproject.toml, which tells the build tool to copy a cook/ folder into the wheel (SafeDep, Aikido, GitHub issue #47826). This is LiteLLM's second compromise this year. The OSV entry for the March incident (versions 1.82.7 and 1.82.8), MAL-2026-2144 (also PYSEC-2026-2), was updated at 22:01 UTC on 21 October (9:01 am AEDT on 22 October) to cover 1.107.0. There's no CVE or GitHub security advisory, because this is planted malware rather than a bug in LiteLLM's code.
What the malware does
Every 1.107.0 wheel, on Linux, macOS and Windows, installs three extra files at the top level of site-packages:
cook.pth, 12 bytes containingimport cook. Python runs lines like this from.pthfiles every time it starts, so this runscook.pyin every Python process on the machine, including ones that never import LiteLLM. That means your own scripts,pipand your editor's language server.cook.py, a credential stealer that calls itself "privcollect". It has 16 modules and goes after SSH keys and shell history, AWS, GCP and Azure credentials and cloud instance metadata, kubeconfig and Docker configs, GitHub CLI tokens,.git-credentials,.npmrc,.pypirc,rclone.confand.netrc, key files under your home folder, GitLab runner, Jenkins, Vault and Terraform secrets, saved browser passwords and history, the config and tokens of AI coding tools, and the environment variables of every other process it can read through/proc/<pid>/environ. IfDATABASE_URLis set, it also dumps the LiteLLM proxy'sLiteLLM_CredentialsTableandLiteLLM_ProxyModelTabletables, which hold every AI provider key the gateway stores. It encrypts the lot and posts it towww.litellm[.]dev/healthcheck, a lookalike domain that has nothing to do with the real project (which useslitellm.ai).sitecustomize.py, a backdoor. Python also loads this on every start. It forks off a background process that holds a lock on/tmp/remote_code_loader.lock, then every hour reads a server address from a file in a GitHub repository (letters9813/pythonclient-test) and downloads and runs whatever Python that server returns from/codepy.
The good news on the backdoor is that GitHub has taken that repository down, so it has nowhere to get instructions from now. The researchers who first reported the incident, from Upwind, say in issue #47826 that the address file had been empty since 20 October, and Wiz says it "was never populated beyond initial test values". So as far as anyone can tell, no second-stage code was ever sent. SafeDep is more careful and says hosts that ran the backdoor before the takedown could have received second-stage code. It couldn't recover the server address, so nobody can rule that out completely.
The stealer is a different story. It doesn't need the backdoor at all, and Wiz has seen the stolen credentials being used. Between 16:20 and 17:01 UTC on 21 October (3:20 to 4:01 am AEDT on 22 October), it saw the attacker test AWS instance role credentials taken from compromised CI runners and Kubernetes nodes, then call Bedrock's model-listing APIs. Wiz says that's consistent with "LLMjacking", where attackers use your cloud account to run AI models on your bill. In a few environments the attacker also listed IAM roles, users and access keys.
On Windows, the backdoor can't fork and fails, but the stealer still runs (Wiz, issue #47826).
Am I affected?
Going by LiteLLM's report, you're in scope if any of these are true:
- pip, uv or Poetry: you installed or upgraded
litellmwithout a pinned version, or pinned1.107.0, between 11:39 and 13:23 UTC on 21 October (10:39 pm on 21 October to 12:23 am on 22 October AEDT). That includes CI jobs, notebooks and tools that pull LiteLLM in as a dependency. Several other projects have already pushed fixes to exclude 1.107.0 from their own dependencies, so check even if you never installed LiteLLM directly. - Docker: you pulled or started
v1.107.0,latest,main-latestormain-stablebetween 11:46 and 14:20 UTC on 21 October (10:46 pm to 1:20 am AEDT). That covers Docker Hub (litellm/litellm) and GHCR (ghcr.io/berriai/litellm,litellm-databaseandlitellm-non_root). If you run Watchtower or anything else that auto-updates images, check it first.
Remember that once installed, the malware runs whenever any Python starts on that machine or in that container. So the whole host or container is in scope, not just the LiteLLM app.
If you're only on LiteLLM's private enterprise registry, LiteLLM says you weren't affected. SafeDep says 1.106.2, 1.107.0rc1 and 1.107.0rc2 are clean, and so are the companion packages 1.107.0 pins, litellm-proxy-extras 0.4.110 and litellm-enterprise 0.1.78. As an extra check, I unzipped the 1.106.2 Linux x86_64 wheel from PyPI, without installing it, and it doesn't contain any of the three files.
Check from the shell first
LiteLLM's report gives one rule above everything else: don't start with pip install. "Any Python start in the affected environment runs cook.pth and sitecustomize.py again, and that includes running pip." The report suggests pip show litellm, but on a suspect machine that starts Python too, so I'd use the shell commands below instead. They only read files and process lists, and none of them start Python.
1. Did you ever ask for 1.107.0? Run this in your project folders. It searches requirements files and lockfiles:
grep -rn 'litellm' --include='requirements*.txt' --include='*.lock' --include='pyproject.toml' --include='Pipfile*' . 2>/dev/null | grep '1\.107\.0'
grep -rn -A1 'name = "litellm"' --include='uv.lock' --include='poetry.lock' . 2>/dev/null
Any 1.107.0 means you need to look at that environment. An unpinned litellm plus an install or upgrade during the window counts too.
2. Find the files. This searches the whole disk for the planted files and any 1.107.0 install. Because it searches /var/lib/docker too, a hit there means a 1.107.0 image is on the machine:
sudo find / \( -path /proc -o -path /sys -o -path /dev \) -prune -o \( -path '*-packages/cook.pth' -o -path '*-packages/cook.py' -o -path '*-packages/sitecustomize.py' -o -name 'litellm-1.107.0.dist-info' \) -print 2>/dev/null
A cook.pth or cook.py anywhere is a strong sign of infection. A sitecustomize.py inside site-packages is suspicious, so check its hash:
sha256sum /path/to/site-packages/{cook.pth,cook.py,sitecustomize.py} 2>/dev/null
These are the Linux and macOS hashes, as published by SafeDep, Wiz, Aikido and the OSV entry:
| File | SHA-256 (Linux and macOS) |
|---|---|
cook.pth |
7f191632e7320705d154b85204f1ae546b543acbd7e8861229b76f5042b92bdb |
cook.py |
9dd0a3926f96a37eb86cf1ee2310d9be93139cc4ebef3ef9e2efe9531390be25 |
sitecustomize.py |
34bef04fe88ac9d0aae0475630b1738681d15b94f233ac8aa46eacf5968305fa |
The Windows copies have different hashes because of line endings. SafeDep and Wiz list those too.
Don't panic over every sitecustomize.py. Debian and Ubuntu ship legitimate ones at /etc/python3.X/sitecustomize.py and /usr/lib/python3.X/sitecustomize.py, which is why the command above only matches paths ending in -packages/. As LiteLLM puts it, finding these files "confirms exposure, but not finding one does not prove the environment is clean".
3. Look for the marker files:
ls -la /tmp/.pc_once_* /tmp/remote_code_loader.lock 2>/dev/null || echo "no marker files found"
If /tmp/.pc_once_72129118c59f5636c0bb exists, the stealer has already sent your data. It writes that file only after a successful upload. If /tmp/remote_code_loader.lock exists, the backdoor ran or is still running. Not finding them proves nothing, because a reboot, a /tmp cleanup or a recreated container removes them.
4. Is the backdoor still running?
ps -eo pid,ppid,sid,user,lstart,args | awk 'NR==1 || ($2==1 && /python/)'
sudo grep -als 'PRIVCOLLECT_ACTIVE=1' /proc/[0-9]*/environ || echo "no process has PRIVCOLLECT_ACTIVE"
sudo fuser -v /tmp/remote_code_loader.lock 2>/dev/null
The first line lists Python processes whose parent is PID 1. That matches how the backdoor detaches itself, but plenty of normal systemd services look the same, so check each one with sudo ls -l /proc/<PID>/cwd. A working directory of / and a start time inside the window is suspicious. The second line finds any process with the PRIVCOLLECT_ACTIVE=1 variable the stealer sets. The third shows which process holds the backdoor's lock file.
5. Check your DNS logs. If you run Pi-hole, AdGuard Home or similar, search the query log for www.litellm.dev. A lookup from any machine means the stealer probably ran there. It's worth adding the domain to your blocklist either way.
Docker checks
Run these with sudo, or as a user in the docker group. Without access to the Docker socket, each command prints a "permission denied" error and grep finds nothing, which looks exactly like a clean result. Run sudo docker info first to make sure you can actually reach Docker. I've confirmed the first three commands behave as expected on a Debian server with Docker 26.1.
sudo docker images --digests --format '{{.Repository}}:{{.Tag}} {{.Digest}} {{.ID}}' | grep -i litellm
sudo docker images --digests | grep -E '1bbcb1443bc9|c00f9d92c427|7b00e91cd2fe' && echo "COMPROMISED IMAGE PRESENT"
sudo docker ps -a --format '{{.ID}} {{.Image}} {{.CreatedAt}} {{.Names}}' | grep -i litellm
sudo docker diff <container> | grep -E 'pc_once|remote_code_loader|cook\.p|sitecustomize'
The bad image index digests from LiteLLM's report are sha256:1bbcb1443bc962e45f5aad53fe3d2c30600e0379715fb6c664cdd3ac126c339e (Docker Hub and ghcr.io/berriai/litellm), plus ghcr.io/berriai/litellm-database starting sha256:c00f9d92c427… and ghcr.io/berriai/litellm-non_root starting sha256:7b00e91cd2fe…. LiteLLM only published the last two in shortened form. Wiz lists the full per-platform digests if you need them.
If you've pulled again since, the old image can hang around untagged as <none>, so check those too. Containers created during the window are suspect. docker diff also works on stopped containers, which I've confirmed, and an added /tmp/.pc_once_... file confirms the theft ran inside that container. If Compose has already recreated the container, that evidence is gone.
When you redeploy, pin by digest rather than by tag. I checked at about 10 pm AEDT on 22 October that v1.106.2 and the latest, main-latest and main-stable tags now all point to the same index digest on both Docker Hub and GHCR:
image: ghcr.io/berriai/litellm:v1.106.2@sha256:7294b90f868c5c38c99b83021c7ba46f9b439e95f8e32964c925c7d2563a03f7
One more thing for Docker users: a user-filed issue reports that the 1.106.x images still trust the emSign ECC Root CA - G3 certificate, which was pulled from browser trust stores this week after a separate incident. I checked the clean ghcr.io/berriai/litellm:v1.106.2 image (the digest pinned above) on 22 October. Its system bundle, /etc/ssl/certs/ca-certificates.crt, has no emSign certificate in it. But the Python certifi bundle the app actually uses, /app/.venv/lib/python3.13/site-packages/certifi/cacert.pem, does contain emSign ECC Root CA - G3. So the operating system doesn't trust that root, but Python code that goes through certifi, such as requests or httpx, does.
To see which bundle your own Python uses and whether that root is in it, run this. It starts Python, so only do it in a clean environment, never on a machine or in a container that may have had 1.107.0:
python3 -c "import certifi; print(certifi.where())"
grep -c 'emSign ECC Root CA - G3' "$(python3 -c 'import certifi; print(certifi.where())')"A count above 0 means the root is still in that bundle. I've covered that root in a separate post.
If you were hit: clean up and rotate
This is the order LiteLLM's report gives:
- From the shell, without starting Python, delete
cook.pth,cook.pyandsitecustomize.py, plus any matching__pycache__/cook*.pycandsitecustomize*.pyc, from every affectedsite-packages. - Kill the detached Python process holding
/tmp/remote_code_loader.lock(step 4 above). - Rebuild virtual environments and images from scratch, pinned to
litellm==1.106.2. Reinstalling in place is the weaker option. - If 1.107.0 was ever installed on a machine with internet access, assume the theft worked, and rotate everything it could reach:
- every AI provider key stored in the LiteLLM proxy, plus its master key and virtual keys
- the
DATABASE_URLpassword - every secret in the environment of any process on the host
- SSH keys, AWS, GCP and Azure credentials and instance roles, kubeconfig,
~/.docker/config.json, your GitHub CLI token (gh auth logout, then log in again),.git-credentials,.npmrc,.pypirc,rclone.confand.netrc - tokens for AI coding tools and Hugging Face
- CI secrets such as GitLab runner, Jenkins, Vault and Terraform credentials
- GPG keys and TLS private keys
- saved browser passwords, if it was a desktop
- On AWS, check CloudTrail for
GetCallerIdentitycalls from the instance role around install time, then for that role's credentials being used from outside your own infrastructure. Given what Wiz saw, also look for Bedrock calls you didn't make.
My own addition, not from the sources: while you rotate, set spending limits or alerts on your AI provider and cloud accounts, so stolen keys can't run up a big bill before you've replaced them.
Why .pth files are so nasty
If you've never come across .pth files, this little demo shows why this attack works so well. It's harmless and self-contained, and only touches a throwaway virtual environment in /tmp:
python3 -m venv /tmp/pthdemo
echo 'import sys; print("[.pth] I ran before your code, in", sys.prefix)' > "$(ls -d /tmp/pthdemo/lib/python3*/site-packages)/zz_demo.pth"
/tmp/pthdemo/bin/python -c 'print("hello from your script")'
/tmp/pthdemo/bin/python -I -c 'print("hello with -I")'
/tmp/pthdemo/bin/python -S -c 'print("hello with -S")'
rm -rf /tmp/pthdemo
I ran it on Debian 13 with Python 3.13. On a normal start, the .pth line prints before the script does. It printed twice for me, because the virtual environment's lib64 folder is a link to lib, so Python reads the same folder twice. Isolated mode (-I) still ran it. Only -S, which skips the site module completely, stopped it. So there's no simple "safe mode" flag that makes a poisoned environment safe to use. Leave Python alone on a suspect machine and work from the shell.
My take
This one hits close to home for anyone self-hosting an AI gateway. LiteLLM didn't lose this because of a weak password or an unpatched server on the release side. An internal gateway was reachable from the internet, it logged request and response bodies, and those logs ended up holding tokens that could publish releases. Your own gateway's logs and database are just as valuable to an attacker.
If you run LiteLLM or anything like it, keep the admin UI and API off the open internet (a VPN or Tailscale is fine), turn off request and response body logging or make sure it's redacted, and pin your versions and image digests so that a bad release can't reach you automatically. It's the same lesson as my GitLab patch post and PHP2Shell: know exactly what's running on your server and where it came from.
DampSnag
Get new posts by email
Guides and patch notes for self-hosters and Minecraft server admins. No spam, unsubscribe any time.