LiteLLM Hit by Second Supply Chain Attack: PyPI Package Ships Credential Stealer

LiteLLM, the open-source AI gateway library that developers use to route calls to hundreds of language model providers, has been compromised on PyPI for the second time this year. Version 1.107.0, published on October 21, contained a credential stealer and a remote code execution backdoor hidden inside its installation files [1].

The scale is hard to overstate. LiteLLM sees over 92 million downloads per month on PyPI alone [1]. It sits in the dependency tree of countless AI agents, chatbots, and internal tools. A compromised package at this scale is not a niche problem; it is a supply chain event that ripples through thousands of downstream projects.

How the Attack Worked

The attackers did not modify the LiteLLM source code on GitHub. Instead, they injected three malicious files into the build tree before the Python wheels were compiled [1]. The files land in site-packages when pip installs the package:

cook.pth is a 12-byte file containing a single line: import cook. Python executes .pth files automatically at interpreter startup. No import of LiteLLM is needed; merely having the package installed is enough to trigger the payload [1].

cook.py is a 22 KB obfuscated script that decompresses and executes an embedded blob using zlib and base64. The decoded payload is a credential stealer that harvests API keys, environment variables, cloud credentials, and other secrets from the infected machine [1].

sitecustomize.py is a second copy of the same stealer, designed to run only when a dead-drop mechanism is armed, providing redundancy in case the first copy is detected and removed [1].

The Docker images were also compromised. The floating tags latest, main-latest, and main-stable on both GHCR and Docker Hub pointed to infected images built from a lookalike repository Berri-AI/litellm (with a hyphen instead of a dot) [1]. Anyone pulling those tags between roughly 11:48 UTC on October 21 and the takedown was affected.

Not the First Time

This is the second LiteLLM supply chain compromise in 2026. Earlier this year, versions 1.82.7 and 1.82.8 were also found to be malicious, with the attack traced to a compromised Trivy dependency in their CI/CD security scanning workflow [2]. The LiteLLM maintainers rotated all maintainer credentials after that incident, yet the attackers found another path in.

According to the maintainers, the threat actor used stolen GitHub CLI OAuth tokens from three engineers' accounts to trigger and approve the malicious release through the project-releaser workflow [1]. As a temporary mitigation, all but one unaffected user have been removed from the GitHub organization. The team has not yet identified how the tokens were originally stolen.

A Week of Supply Chain Failures

The LiteLLM compromise is part of a brutal week for software supply chains. On the same day, Railway, a popular deployment platform, disclosed that an unauthorized third party may have accessed customer environment variables, including decrypted API keys and database credentials. Railway paused all deployments and urged every user to rotate their secrets [3].

Railway believes the attack is part of a series of incidents targeting platform companies with the aim of compromising AI inference providers. The pattern is clear: attackers are going after the infrastructure that AI applications depend on, knowing that a single breach can expose credentials for dozens of upstream services.

Earlier in the week, a critical PHP vulnerability forced governments across Europe to take websites offline [4], a compromised intermediate certificate authority was disclosed [5], and PingCap's TiDB was found to have leaked 10.6 TB of data [6]. The common thread is that the foundations of modern software, the package registries, CI/CD pipelines, and infrastructure platforms, are under sustained attack.

What You Should Do

If you use LiteLLM, the remediation is not optional:

Pin your version. Use litellm==1.106.2 or an earlier known-good release. Do not use floating tags or latest [1].

Rotate everything. If you installed version 1.107.0 or pulled the affected Docker tags, assume every secret on that machine is compromised. Rotate API keys, database credentials, cloud access keys, and any environment variables that were present [1].

Check for persistence. Look for cook.pth, cook.py, and sitecustomize.py in your Python site-packages directory. Their presence means the stealer ran [1].

Rebuild from clean. The safest path is to rebuild affected containers and virtual environments from scratch rather than trying to clean an infected system. The .pth mechanism means even security scanners can trigger the malware before they finish scanning [2].

The Bigger Picture

LiteLLM's troubles are a case study in why supply chain security is hard. The project is widely used, actively maintained, and has already been through one incident response. Yet a second attack succeeded within months. The attack vector shifted from a compromised CI dependency (Trivy) to stolen OAuth tokens, showing that attackers adapt faster than defenses.

For the broader ecosystem, the lesson is uncomfortable. Package registries like PyPI are a single point of failure for millions of projects. Trusted publishing, two-factor authentication, and automated malware scanning all help, but none of them stop an attacker who has already compromised a maintainer's credentials or CI pipeline.

The only robust defense is reducing blast radius: pin your dependencies, verify hashes, minimize the secrets available in any single environment, and treat every pip install as a potential compromise. The era of blind trust in package registries is over.