GMO Flatt Security Research
October 21, 2026

Software Supply Chain Attack on LiteLLM: Overview and Response Guidance

Posted on October 21, 2026  •  7 minutes  • 1482 words
Table of contents

Note) This post is a direct translation of this post .

On October 21, 2026, malicious code was injected into the PyPI package litellm.

This article goes into detail on this malicious package based on information we observed and analyzed on the analysis infrastructure behind Takumi Guard, focusing on its impact as well as the countermeasures to take.

TL;DR — Response Guidance

Introduction

This article aims to help readers understand the incident and respond to it; it is not intended to aid or encourage any unlawful activity. Payload behaviour is summarised only to the extent needed to understand the technique. Because we prioritised speed, parts of this article may be inaccurate.

Timeline (UTC)

Date/Time (UTC) Event
2026-10-13 06:43 Attacker GitHub account letters9813 created
2026-10-13 06:46 TLS certificate issued for C2 domain litellm[.]dev (Let’s Encrypt)
2026-10-18 04:17 domain.txt added to GitHub repository letters9813/pythonclient-test (C2 domain config)
2026-10-21 10:44 Legitimate litellm==1.106.2 published to PyPI
2026-10-21 11:39 Malicious litellm==1.107.0 published to PyPI (~1 hour after the legitimate release, 8 platform wheels + sdist)
2026-10-21 (time unknown) PyPI takes down litellm==1.107.0

How the Compromise Works

The v1.107.0 tag in litellm’s GitHub repository does not contain any malicious files. The malicious files exist only in the wheel published to PyPI, indicating that they were injected at some point after the wheel was built from source.

Stage 1 — Two Independent Auto-Execution Paths

Compared to the legitimate version 1.106.2, three files were added to the wheel’s litellm-1.107.0.data/purelib/ directory. This directory does not exist in the legitimate version at all. When pip install processes the wheel, files under purelib/ are placed directly in site-packages/. This attack abuses two independent Python auto-execution mechanisms simultaneously.

Path A: .pth → cook.py (Infostealer)

cook.pth contains a single line:

import cook

At startup, Python reads .pth files in site-packages/ and automatically executes any line beginning with import. This causes cook.py in the same directory to be loaded, which immediately runs the infostealer (privcollect).

Path B: Built-in sitecustomize Auto-Import → sitecustomize.py (Infostealer + Backdoor)

Python has a built-in mechanism that automatically imports a module named sitecustomize from site-packages/ at startup — entirely separate from the .pth mechanism above. The attacker exploited this by placing sitecustomize.py in site-packages/. This path runs the infostealer plus a persistent daemon and remote code loader.

Path Trigger File Payload
A import cook in cook.pth cook.py Infostealer only (fires unconditionally)
B Python’s built-in sitecustomize auto-import sitecustomize.py Infostealer + daemonisation + remote code loader

Both paths fire automatically on every Python startup with no explicit invocation. After pip install litellm==1.107.0, both execute whenever Python starts.

Stage 2 — Obfuscation and Unpacking

Both cook.py and sitecustomize.py contain an inline infostealer payload compressed with zlib + base64.

import zlib as _3659944d, base64 as _35100b45
exec(_3659944d.decompress(_35100b45.b64decode('eNrdfWt33...')))

Variable names are replaced with meaningless hexadecimal strings to hinder source-level analysis. Once unpacked, a ~1,200-line Python script (privcollect) emerges.

Stage 3 — privcollect (The Infostealer)

The unpacked code identifies itself as privcollect and runs 16 collection modules in sequence.

The malware checks for the PRIVCOLLECT_ACTIVE environment variable and exits immediately if it is set, preventing double execution. After the first successful run, it writes a marker file at /tmp/.pc_once_72129118c59f5636c0bb and skips full collection on subsequent runs.

Harvested Secrets

Category Targets
SSH private keys All files in ~/.ssh/
Browser passwords Chromium browsers (Chrome/Edge/Brave/Vivaldi/Opera) saved password decryption, cookies; Firefox logins.json + key4.db
Cloud credentials AWS (~/.aws/credentials, IMDS role credentials, ECS task credentials), GCP (ADC, credentials.db, Metadata API), Azure (profile, tokens, MSAL cache, IMDS)
Kubernetes / Docker ~/.kube/config, ServiceAccount tokens (/var/run/secrets/), ~/.docker/config.json, Docker secrets
Package managers .npmrc, .pypirc, pip.conf, .yarnrc.yml, Maven settings.xml, Gradle properties, .gem/credentials, .cargo/credentials.toml
CI/CD GitLab Runner config, Jenkins admin password/master key, Vault token, Terraform credentials
AI dev tools Claude (credentials, settings), Cursor (MCP, CLI), Kiro, Windsurf/Codeium, GitHub Copilot, VS Code, Gemini CLI, Codex CLI, Continue, Aider, Goose, OpenCode, Qwen, HuggingFace token, Amazon Q, Ollama
Environment variables All env vars from the current process + /proc/*/environ for all processes on Linux
LiteLLM DB Directly queries LiteLLM_CredentialsTable and LiteLLM_ProxyModelTable via DATABASE_URL
Git / Dev secrets .git-credentials, .gitconfig, .env files, private key files (.pem, .key, .pfx, .p12)
GPG / TLS GPG private keys, TLS private keys (/etc/ssl/private, Let’s Encrypt)
Shell history bash/zsh/fish/python/node REPL history, database CLI history
Network info Interfaces, routing tables, ARP tables, listening ports

Notably, this malware later uses stolen AWS credentials to call sts:GetCallerIdentity, verifying their validity and identifying the associated AWS account and ARN.

Additionally, mod_db_litellm queries LiteLLM’s own Prisma database directly, extracting provider API keys and model configurations.

The archive is sent via HTTP POST to http://www[.]litellm[.]dev/healthcheck (with X-Token and X-SHA256 headers). The encryption implementation cascades through openssl CLI → cryptography library → pure Python fallback, ensuring it works regardless of the target environment’s dependencies.

Stage 4 — Daemonisation and Remote Code Execution (sitecustomize.py)

In addition to the infostealer payload, sitecustomize.py includes a remote code loader and daemonisation logic. It spawns a background daemon using os.fork() + os.setsid().

def _daemonize():
    pid = os.fork()
    if pid > 0:
        return False
    os.setsid()
    devnull_fd = os.open(os.devnull, os.O_RDWR)
    os.dup2(devnull_fd, 0)
    os.dup2(devnull_fd, 1)
    os.dup2(devnull_fd, 2)

The daemon runs every 3600 seconds (1 hour) and:

  1. Fetches a domain name from https://raw.githubusercontent.com/letters9813/pythonclient-test/main/domain.txt
  2. Downloads code from http://{domain}/codepy
  3. Executes it via exec()

This gives the attacker a standing backdoor: by updating domain.txt in the GitHub repository, they can push arbitrary code to all infected hosts.

Response Guidance

Check Exposure

Package Version

pip show litellm | grep Version

If version 1.107.0 is shown, your environment is affected.

Marker File

ls -la /tmp/.pc_once_72129118c59f5636c0bb

If this file exists, the infostealer has already collected and exfiltrated data.

Network Logs

# Search proxy/DNS logs for C2 connections
grep -E "litellm\.dev" /var/log/proxy.log /var/log/dns-query.log 2>/dev/null

Remove

pip uninstall litellm
pip install litellm==1.106.2

Check for and remove residual malicious files in site-packages:

find $(python -c 'import site; print(site.getsitepackages()[0])') \
    -name 'cook.pth' -o -name 'cook.py' | grep -v litellm/

Stop the daemon process:

ls -la /tmp/remote_code_loader.lock
ps aux | grep -E 'cook|remote_code_loader' | grep -v grep
# Kill any matching processes, then remove marker and lock files
rm -f /tmp/.pc_once_72129118c59f5636c0bb /tmp/remote_code_loader.lock

Rotate Credentials

If affected, rotate all of the following:

Target How to rotate
SSH private keys Generate new key pairs; remove old public keys from all servers and services
AWS access keys Deactivate and reissue in the IAM console. For EC2/ECS, rotate instance role credentials as well
GCP service account keys Delete and regenerate keys in the GCP console. Re-authenticate ADC
Azure tokens Run az account clear && az login. Delete MSAL cache
Kubernetes config Regenerate cluster credentials. For ServiceAccount tokens, delete and recreate the Secret
Docker registry auth docker logout → docker login
npm / PyPI tokens Revoke and reissue tokens on each registry
GitHub CLI tokens Revoke and reissue Personal Access Tokens
Browser-stored passwords Change all saved passwords in affected browsers
AI tool credentials Re-authenticate Claude, Cursor, Copilot, Gemini CLI, Codex, etc.
GPG / TLS private keys Revoke keys and regenerate / reissue certificates
.env file secrets Rotate every secret listed in .env files individually
LiteLLM DB credentials Change the DATABASE_URL database password. Also rotate provider API keys stored in LiteLLM_CredentialsTable

Block Malicious Dependencies (Takumi Guard)

GMO Flatt Security provides Takumi Guard, a secure registry proxy with a PyPI endpoint . Takumi Guard sits between your tooling and the PyPI registry, blocking malicious packages. We inspect every new package and maintain a continuously updated blocklist. npm, RubyGems, Packagist, and Go Modules are also supported. Setup requires only changing your registry URL and is free.

pip config set global.index-url https://pypi.flatt.tech/simple/

If a package is not identified as malware at install time, Takumi Guard will still notify you retroactively once it is flagged (also free).

Register your email below to enable notifications.

https://flatt.tech/takumi/features/guard

Enterprise management features (batch setup across multiple machines, admin notifications) are available as a paid add-on.

Contact us for details.

IoCs

Hashes (SHA-256)

File SHA-256
cook.py 9dd0a3926f96a37eb86cf1ee2310d9be93139cc4ebef3ef9e2efe9531390be25
sitecustomize.py 34bef04fe88ac9d0aae0475630b1738681d15b94f233ac8aa46eacf5968305fa
cook.pth 7f191632e7320705d154b85204f1ae546b543acbd7e8861229b76f5042b92bdb

Network

Type Value Notes
URL http://www[.]litellm[.]dev/healthcheck Exfiltration C2
URL https://raw.githubusercontent.com/letters9813/pythonclient-test/main/domain.txt C2 domain config
IP 104[.]26[.]10[.]8 www[.]litellm[.]dev (Cloudflare)
IP 104[.]26[.]11[.]8 www[.]litellm[.]dev (Cloudflare)
IP 172[.]67[.]73[.]104 www[.]litellm[.]dev (Cloudflare)
GitHub account letters9813 Created 2026-10-13, email: letters9813@atomicmail[.]io

Affected Packages

Package Malicious Version Safe Version Notes
litellm 1.107.0 1.106.2 8 platform wheels + sdist published. All wheels contain the same malicious files. Taken down from PyPI