【嚴重警示】LiteLLM 供應鏈攻擊事件完整分析:TeamPCP 如何透過受污染的 CI/CD 工具竊取 50 萬帳戶憑證
事件概述
2026 年 3 月 24 日,AI 開發社群爆發重大資安事件。流行的 Python AI 套件 LiteLLM 在 PyPI 上遭到植入惡意程式,攻擊者為駭客組織 TeamPCP。這是一次精心策劃的軟體供應鏈攻擊(Supply Chain Attack),影響範圍遍及全球超過 20,000 個專案。
關鍵數字:
- 暴露時間窗口:約 3-5 小時
- 潛在受影響帳戶:約 500,000 個
- 受影響套件數量:20,000+ 個 GitHub repo
- 下游依賴套件:DSPy、CrewAI、browser-use、nanobot-ai、MLflow 等
---
攻擊鏈分析:三階段供應鏈滲透
第一階段:入侵 CI/CD 安全掃描器
攻擊起點並非 LiteLLM 本身,而是其 CI/CD 管道使用的安全掃描工具 Trivy。
時間線:
- 2026-02-28:TeamPCP 透過
pull_request_target漏洞初步入侵 Trivy CI/CD - 2026-03-19:Trivy v0.69.4 GitHub Action 的 76/77 個版本 tag 被改寫為惡意版本(CVE-2026-33634, CVSS 9.4)
- 2026-03-23:Checkmarx KICS GitHub Action 被入侵;攻擊者預先註冊假冒域名
models.litellm.cloud
關鍵漏洞: LiteLLM 的 CI/CD 在安裝 Trivy 時未鎖定版本,導致惡意 Trivy 竊取了
PYPI_PUBLISH_PASSWORD 等 GitHub Actions 機密。第二階段:惡意套件上傳
| 版本 | 上傳時間 (UTC) | 感染方式 |
|---|---|---|
| 1.82.7 | 10:39 | 在 proxy_server.py 第 128-139 行注入 base64 雙重編碼惡意程式 |
| 1.82.8 | 10:52 | 追加 litellm_init.pth (34,628 bytes),利用 Python .pth 機制在每次 Python 啟動時自動執行 |
第三階段:惡意程式執行
Loader (.pth 或 proxy_server.py)
↓ base64 解碼
Orchestrator (含 RSA-4096 公鑰)
↓ 啟動
Credential Stealer → 加密 → POST 到 models.litellm.cloud
↓ 同時
C2 Backdoor (sysmon.py) → 每 50 分鐘輪詢 checkmarx.zone
↓ 若有 Kubernetes
Kubernetes 橫向移動 → 在 kube-system 部署特權 Pod
為何被發現?
.pth 機制造成指數級 fork bomb,耗盡受害者記憶體而崩潰。若無此 bug,木馬可能潛伏數週不被發現。---
技術細節:.pth 機制的危險性
Python 的
.pth 文件可被用來執行任意程式碼:python
# 惡意 .pth 文件
import base64; exec(base64.b64decode('...惡意程式碼...'))
這意味著即使專案沒有直接使用 LiteLLM,只要安裝了受感染版本,每次執行 Python 都會觸發木馬。
---
攻擊者目的:大規模憑證竊取
| 類別 | 目標 |
|---|---|
| SSH 金鑰 | id_rsa, id_ed25519, authorized_keys |
| 雲端憑證 | AWS IAM, GCP credentials, Azure ~/.azure/ |
| Kubernetes | Service account tokens, kubeconfig, kube-system secrets |
| 環境變數 | 所有 .env 文件(遞迴搜尋 6 層目錄) |
| 加密貨幣錢包 | Bitcoin wallet.dat, Ethereum keystores, Solana 等 10+ 種 |
資料以 AES-256-CBC 加密後打包為
tpcp.tar.gz POST 至 models.litellm.cloud(攻擊前一天才註冊的假冒域名)。---
受影響版本
| 版本 | 狀態 |
|---|---|
| 1.82.7 | 惡意版本 |
| 1.82.8 | 惡意版本(更危險) |
| 1.82.6 | 最後安全版本 |
間接受影響套件: DSPy、CrewAI、browser-use、nanobot-ai、MLflow、各種 MCP plugins 等。
---
如何檢查是否受影響
bash
# Step 1: 確認版本
pip show litellm
# 若顯示 1.82.7 或 1.82.8 -> 已受感染
# Step 2: 搜尋惡意 .pth 文件
find / -name "litellm_init.pth" 2>/dev/null
# Step 3: 檢查後門文件
ls ~/.config/sysmon/sysmon.py 2>/dev/null
ls /tmp/pglog /tmp/.pg_state 2>/dev/null
# Step 4: Kubernetes 環境
kubectl get pods -n kube-system | grep node-setup
IoC 域名:
models.litellm.cloud(非官方,資料滲出端點)checkmarx.zone(C2 伺服器)
---
立即處置步驟
bash
# 移除惡意套件
pip uninstall litellm && pip cache purge
# 清除後門
rm -f ~/.config/sysmon/sysmon.py
rm -f ~/.config/systemd/user/sysmon.service
rm -f /tmp/pglog /tmp/.pg_state
# 安裝安全版本
pip install "litellm==1.82.6"
必須立即輪換的憑證: SSH keys、AWS/GCP/Azure IAM、所有 API keys(OpenAI, Anthropic 等)、資料庫密碼、GitHub PATs、Kubernetes service account tokens。
---
長期防護建議
| 措施 | 說明 |
|---|---|
| 鎖定依賴版本 | requirements.txt 使用精確版本號,避免 >= 或 ^= |
| 使用 lock file | poetry.lock 或 pip-tools 生成的 requirements.txt |
| 掃描 .pth 文件 | 定期檢查 site-packages 中的 .pth 文件 |
| 使用 SCA 工具 | Snyk、Sonatype Nexus、Endor Labs 等 |
| CI/CD 工具鎖版 | 所有 CI/CD 工具(包括安全掃描器)都需鎖定精確版本 |
---
專家見解
Kaspersky: 將此事件列為「現代史上最大且最危險的供應鏈攻擊之一」。
ARMO (Ben Hirschberg, CTO): 「LiteLLM 是 AI 基礎設施中憑證密度最高的目標——它本身就設計用來持有 100+ LLM 提供商的 API keys」。
Helixar AI: 「沒有任何安全工具在事發當下偵測到此攻擊,是惡意程式的 bug 救了所有人。」
Andrej Karpathy: 評論此事件為「software horror」。
---
官方回應
- 移除受感染的 PyPI 套件(v1.82.7, v1.82.8)
- 輪換所有維護者憑證
- 委託 Google Mandiant 安全團隊協助鑑識分析
---
References
- LiteLLM 官方公告:https://docs.litellm.ai/blog/security-update-march-2026
- GitHub Issue #24518:https://github.com/BerriAI/litellm/issues/24518
- BleepingComputer:https://www.bleepingcomputer.com/news/security/popular-litellm-pypi-package-compromised-in-teampcp-supply-chain-attack/
- Snyk 分析:https://snyk.io/articles/poisoned-security-scanner-backdooring-litellm/
- Kaspersky:https://www.kaspersky.com/blog/critical-supply-chain-attack-trivy-litellm-checkmarx-teampcp/55510/
- SafeDep 深度分析:https://safedep.io/malicious-litellm-1-82-8-analysis
- Sonatype:https://www.sonatype.com/blog/compromised-litellm-pypi-package-delivers-multi-stage-credential-stealer