LiteLLM Trojanized via Stolen PyPI Token: The .pth Injection Technique Your Scanners Won't Catch
A Cascading Supply Chain Attack Hits the AI Ecosystem
The TeamPCP campaign — previously reported for compromising Trivy — has now cascaded into the Python AI ecosystem via a novel attack chain. The group compromised Aqua Security's Trivy CI/CD pipeline, used that access to steal LiteLLM's PyPI publishing token, and pushed trojanized packages (versions 1.82.7 and 1.82.8) to PyPI. A separate vector also hit Checkmarx's KICS scanner, with malware injected into its GitHub Action and VS Code extensions.
LiteLLM is an LLM proxy/router library used by thousands of organizations to route requests across OpenAI, Anthropic, and Google. The blast radius extends beyond direct users — transitive dependencies in frameworks like DSPy mean any project in your AI/ML pipeline could be affected.
The tools you adopted to accelerate AI development just became the tools that compromise you completely — and the technique used is invisible to every standard scanning tool in your pipeline.
The .pth Injection: Why Your Scanners Miss It
The attack's most significant innovation is the persistence mechanism. Rather than hiding malicious code in source files (which SAST and SCA tools inspect), the attacker planted a litellm_init.pth file in Python's site-packages directory. The .pth file format is a Python-specific feature that executes arbitrary code when the interpreter starts — no import required, no explicit invocation needed.
This means:
- Standard code review of LiteLLM's source won't find it
- SCA tools scanning dependency trees won't flag it
- Import-level monitoring never triggers because the payload fires before any import
- The payload runs in any Python process on the affected system, not just LiteLLM-specific code
The exfiltration scope is staggering: SSH keys, AWS/GCP/Azure credentials, Kubernetes configs, git credentials, all environment variables, shell history, crypto wallets, CI/CD secrets, SSL private keys, and database passwords. A conditional rm -rf / wiper activates if the system timezone is Asia/Tehran, suggesting geopolitical motivation beyond simple cybercrime.
Cross-Source Analysis: The Full TeamPCP Kill Chain
Six independent sources confirm the attack chain and provide complementary technical detail:
- Initial access: TeamPCP modified existing GitHub Actions version tags on Trivy (not new releases — tag overwrites that bypass version pinning to major/minor tags)
- Lateral expansion: Compromised Aqua Security's entire GitHub organization including private repos and Docker images
- KICS compromise: Malware inserted into Checkmarx KICS GitHub Action and two VS Code extensions
- Credential theft: LiteLLM's PyPI publishing token intercepted from the compromised CI/CD pipeline
- Package poisoning: Two LiteLLM versions pushed with
.pthcredential stealer - Counter-intelligence: AI-generated 'Thanks, that helped!' comments used to bury security warnings on LiteLLM's GitHub vulnerability reports
The AI-generated comment spam is a novel defense evasion technique — MITRE T1562.001 applied to open-source vulnerability disclosure. No automated filtering exists for this on GitHub.
Trivy Docker Hub Update
New detail since yesterday: Trivy versions 0.69.4, 0.69.5, 0.69.6, and the 'latest' tag on Docker Hub were malicious from March 19-23. Docker confirmed its own infrastructure and Hardened Images were not impacted, but any pipeline that pulled these versions should be treated as compromised.
What to do
Hunt for LiteLLM v1.82.7/v1.82.8 across all Python environments — production, staging, CI/CD, developer workstations, Jupyter notebooks, Docker images — using pip list, pip freeze, and container image scanning. Check transitive dependencies via pip show litellm on DSPy environments.
Scan all Python site-packages directories for rogue .pth files: find /usr/lib/python*/site-packages -name '*.pth'. Baseline legitimate .pth files from setuptools, pip, distutils. Any unrecognized .pth file is suspect.
If LiteLLM or compromised Trivy versions found: rotate ALL credentials accessible from affected systems — cloud IAM, SSH keys, K8s service account tokens, CI/CD secrets, database passwords, API keys. Review cloud audit logs for unauthorized access during the exposure window.
Enforce pip --require-hashes across all Python projects and deploy a private PyPI mirror with pre-admission scanning by end of sprint.
Add .pth file integrity monitoring to your SIEM. Alert on .pth file creation or modification in site-packages directories outside approved package management operations.