LiteLLM Python SDK PyPI Hijacking & Cascading Trust Failure
On March 24, 2026, the popular LiteLLM Python package was compromised on PyPI. Attackers harvested PyPI publishing secrets from LiteLLM's CI/CD runner via a previously backdoored dependency, uploading malicious versions containing a python startup hook payload.
- Date:
- Severity:
- critical
- Sources:
- 5
Executive Summary
On March 24, 2026, the popular Python library litellm (used to call 100+ LLM APIs using the OpenAI format) was compromised in a highly sophisticated, cascading software supply chain attack Snyk Advisory Database. Rather than targeting the maintainers’ workstations directly, the attackers executed a “cascading trust” attack Zscaler ThreatLabz. By leveraging their earlier compromise of the widely adopted container scanner Trivy inside LiteLLM’s GitHub Actions build pipeline, they scraped memory configurations to harvest LiteLLM’s long-lived PyPI publishing API token Datadog Security Research. Using the stolen credentials, they directly published two compromised versions to PyPI: 1.82.7 and 1.82.8 LiteLLM AI Official Advisory. The backdoored wheels contained a malicious .pth startup hook file designed to execute automatically on Python startup—even if litellm was never explicitly imported Datadog Security Research. The payload acted as a credential harvester, capturing environment variables, database keys, cloud IAM credentials, and AI provider tokens, exfiltrating the data to TeamPCP C2 servers. PyPI administrators intervened to delete the compromised versions. Defenders must immediately revoke exposed secrets and implement Trusted Publishing via OIDC to prevent credential hijacking.
Key Facts
threat_type: "Cascading CI/CD Compromise & Startup Hook Package Poisoning"
ecosystem: "pypi, python"
registry: "PyPI Registry"
affected_packages:
- "litellm"
malicious_versions:
- "1.82.7"
- "1.82.8"
fixed_versions:
- "1.83.0"
safe_versions:
- "1.82.6"
- "1.83.0"
exposure_window: "2026-03-24T12:00:00Z to 2026-03-24T15:30:00Z"
execution_trigger: "Python interpreter initialization in environments where the compromised package versions were installed"
primary_impact: "Host workstation and pipeline memory scraping, secret harvesting, and automated exfiltration"
known_iocs:
- "litellm_init.pth"
- "filev2.getsession[.]org"
- "api.masscan[.]cloud"
confidence: "high"
canonical_source: "https://www.litellm.ai"
Source Confidence & Evidence Mapping
- confirmed:
- Compromised package releases published on PyPI under
litellmwere versions 1.82.7 and 1.82.8. Source: LiteLLM AI Official Advisory - The PyPI API key was exfiltrated from the CI/CD pipeline due to a previously compromised execution of the Trivy scanner. Source: Snyk Advisory Database
- The payload utilized a
.pthfile (litellm_init.pth) to hijack Python’s site-packages initialization mechanics and auto-run on startup. Source: Datadog Security Research
- Compromised package releases published on PyPI under
- likely:
- The attack was executed by the threat syndicate TeamPCP as part of a wider multi-ecosystem campaign. Source: Zscaler ThreatLabz
- unclear:
- The exact volume of downstream development and production environments that fetched the malicious wheels during the three-hour window. Source: LiteLLM AI Official Advisory
Timeline
- 2026-03-19T08:00:00Z TeamPCP compromises Trivy scanner tags in GitHub Actions. Source: Snyk Advisory Database
- 2026-03-24T10:30:00Z LiteLLM’s GitHub Actions build pipeline executes a compromised Trivy runner, exfiltrating the repository’s PyPI publishing token to TeamPCP servers. Source: Zscaler ThreatLabz
- 2026-03-24T12:00:00Z Attackers exploit the stolen token to directly publish
1.82.7and1.82.8to PyPI. Source: LiteLLM AI Official Advisory - 2026-03-24T12:40:00Z Security researchers at Datadog and Snyk flag anomalous
.pthinsertions inside the newly released package wheels. Source: Datadog Security Research - 2026-03-24T15:30:00Z PyPI administrators remove the malicious versions and ban the compromised API key. Source: LiteLLM AI Official Advisory
What Happened
On March 24, 2026, the developers of litellm were alerted by security researchers that Snyk had flagged a major structural anomaly in the package’s latest minor updates on PyPI LiteLLM AI Official Advisory. Analysts discovered that although the main code in the repository remained unaltered, the published packages contained a newly introduced file named litellm_init.pth inside the wheel archive Datadog Security Research. Retrospective build analysis showed that a previous automated build workflow executed a compromised container scanner (Trivy), which silently harvested the repository’s long-lived PyPI token and exfiltrated it Snyk Advisory Database. Using this out-of-band token, the threat group TeamPCP directly uploaded backdoored releases, bypassing peer review and repository pull request gates entirely Zscaler ThreatLabz.
Technical Analysis
Initial Access
Initial access was achieved via a cascading trust failure Zscaler ThreatLabz. The attackers first hijacked mutable version tags in an upstream dependency—the Trivy container scanner Action—which LiteLLM’s release pipeline imported for automated security compliance scans Snyk Advisory Database. When the workflow executed, the poisoned Trivy runner scraped memory directories to extract the repository secrets (including the PyPI publish token) and shipped it to the C2 nameserver Datadog Security Research.
Package or Artifact Manipulation
The repository BerriAI/litellm was not breached. The attackers packaged the compromised release locally. They injected a malicious payload file litellm_init.py and a startup directive litellm_init.pth into the site-packages root directory, updating the version metadata to 1.82.7 and 1.82.8 before pushing the wheels to PyPI using the exfiltrated key LiteLLM AI Official Advisory.
Execution Trigger
The execution trigger exploited Python’s path configuration (.pth) file processing Datadog Security Research. Upon interpreter startup, Python automatically processes all .pth files in the site-packages directory. By formatting the file to import the malicious initialization module, the payload ran automatically whenever Python started up:
import sys; import litellm_init # Triggers setup automatically on Python startup
This allowed the malware to run without requiring the user to explicitly call import litellm in their code Datadog Security Research.
Payload Behavior
The payload enumerates system environments, harvesting cloud IAM access keys, SSH keys, database credentials, and GitHub PATs. The malware was designed to establish persistent footholds on developer machines and attempt lateral movement inside compromised Kubernetes clusters using stolen configuration files Zscaler ThreatLabz.
Exfiltration / C2
Telemetry data was compressed, encoded in Base64, and shipped to TeamPCP-controlled endpoints:
filev2.getsession[.]orgapi.masscan[.]cloud
Propagation
Stolen cloud and GitHub credentials were automatically analyzed by TeamPCP’s backend server to identify further vulnerable repositories, creating a cascading propagation effect StepSecurity Incident Registry.
Obfuscation or Evasion
The use of the .pth startup hook was a highly effective evasion technique, as traditional static scanners that only parse import trees inside project source files failed to detect that the backdoored dependency was actively running in the background Datadog Security Research.
Affected Assets and Blast Radius
affected_assets:
ecosystems:
- "pypi"
packages:
- "litellm"
versions:
- "1.82.7"
- "1.82.8"
repositories:
- "BerriAI/litellm"
container_images: []
CI_CD_systems:
- "GitHub Actions pipelines"
developer_tools:
- "Developer workstations"
- "Python execution runtimes"
credentials_at_risk:
- PyPI publishing tokens
- AWS IAM credentials
- GCP service account keys
- Azure principal keys
- SSH private keys
Indicators of Compromise
Domains
filev2.getsession[.]org(source:https://www.litellm.ai, confidence:high)api.masscan[.]cloud(source:https://www.litellm.ai, confidence:high)
File Identifiers
litellm_init.pthlitellm_init.py
Package Versions
litellm@1.82.7litellm@1.82.8
Detection and Hunting
Hunt Queries
hunt_queries:
dependency_lockfiles:
- "litellm==1.82.7"
- "litellm==1.82.8"
network:
- "filev2.getsession.org"
- "api.masscan.cloud"
endpoint_checks:
- "Search python site-packages folders for unauthorized .pth hook files containing execution statements"
Remediation Workflow
- Immediate:
- Force uninstall the affected versions (
1.82.7,1.82.8) and clean installation past version1.83.0LiteLLM AI Official Advisory. - Rotate all environment variables, SSH credentials, database tokens, and cloud keys exposed to systems running those versions Zscaler ThreatLabz.
- Force uninstall the affected versions (
- Short-term:
- Purge internal local caching proxies and virtual environments.
- Long-term:
- Invalidate all API-key publishing tokens, migrating to Trusted Publishing (OIDC) to link PyPI uploads strictly to verified, short-lived OIDC tokens generated directly by the GitHub Actions build runner Datadog Security Research.
Defensive Lessons
- prevent: Stop using mutable version tags for security check dependencies inside pipelines, pinning commit SHAs instead.
- detect: Build CI/CD runtime constraints to prevent runners from having access to long-lived, high-privilege publishing secrets.
- respond: Standardize secret rotation architectures to ensure high-priority credentials can be cycled within minutes of a compromise alert.
Open Questions
- Did any corporate serverless endpoints execute the compromised package during the three-hour window?
- Are there other open-source Python packages executing legacy build tasks with long-lived PyPI tokens exposed?
Sources
- LiteLLM Official Security Postmortem - Role: DIRECT_SOURCE - Impact: Advisory notification, version boundaries, and remediation guidelines.
- Datadog Security Research on .pth Backdoors - Role: PRIMARY_RESEARCH - Impact: Detailed technical analysis of Python
.pthstartup hook hijacking mechanics. - Zscaler ThreatLabz Trivy-LiteLLM Cascade - Role: PRIMARY_RESEARCH - Impact: Correlation of the cascading trust attack between Trivy and LiteLLM.
Machine-Readable Event Profile (Format B)
[
{
"event_id": "litellm-pypi-hijacking",
"event_name": "LiteLLM Python SDK PyPI Hijacking & Cascading Trust Failure",
"parent_campaign_id": "teampcp-supply-chain-campaign-2025-2026",
"is_campaign_level": false,
"confidence": "high",
"confidence_reason": "Backed by verified official LiteLLM advisories, in-depth Datadog technical postmortems, and Snyk telemetry logs.",
"attack_types": [
"malicious package",
"CI/CD compromise",
"credential theft",
"token exfiltration",
"cascading-trust"
],
"direct_sources": [
{
"name": "LiteLLM Official Security Postmortem",
"url": "https://www.litellm.ai"
}
],
"correlated_sources": [
{
"name": "Datadog Security Research on .pth Backdoors",
"url": "https://www.datadoghq.com",
"role": "PRIMARY_RESEARCH",
"contribution": "technical mechanics of .pth startup hook execution"
},
{
"name": "Zscaler ThreatLabz Trivy-LiteLLM Cascade",
"url": "https://www.zscaler.com",
"role": "PRIMARY_RESEARCH",
"contribution": "analysis of the cascading attack chain between Trivy and LiteLLM"
}
],
"affected_assets": {
"ecosystems": ["pypi"],
"packages": ["litellm"],
"versions": ["1.82.7", "1.82.8"],
"repositories": ["BerriAI/litellm"],
"vendors": ["BerriAI"],
"CI_CD_systems": ["GitHub Actions pipelines"],
"container_images": [],
"developer_tools": ["Developer workstations", "Python execution runtimes"]
},
"timeline": {
"first_seen": "2026-03-24T12:00:00Z",
"malicious_publish_time": "2026-03-24T12:00:00Z",
"discovery_time": "2026-03-24T12:40:00Z",
"removal_time": "2026-03-24T15:30:00Z",
"disclosure_time": "2026-03-24T12:40:00Z",
"fixed_version_time": "2026-03-24T15:30:00Z"
},
"matching_signals": {
"package_names": ["litellm"],
"affected_versions": ["1.82.7", "1.82.8"],
"identifiers": {
"cve": "N/A",
"ghsa": "N/A",
"osv": "N/A"
},
"shared_claims": "Credential stealer executing via .pth startup hook",
"shared_root_cause": "Exfiltrated PyPI API token via backdoored CI/CD container scanner Action",
"shared_affected_parties": "Downstream developers importing LiteLLM Python package"
},
"iocs": {
"domains": ["filev2.getsession.org", "api.masscan.cloud"],
"ips": [],
"urls": [],
"hashes": [],
"scripts": ["litellm_init.pth", "litellm_init.py"]
},
"recommended_actions": {
"store_as_new_event": true,
"attach_as_observations": [
"https://www.datadoghq.com",
"https://www.zscaler.com"
],
"promote_to_writeup": true,
"needs_ioc_enrichment": false,
"needs_registry_metadata": false,
"needs_more_research": false
}
}
]