대규모 PyPI 공급망 공격, Python 시작 훅을 통해 클라우드 자격 증명 수집
Detection stack
- AIDR
- Alert
- ETL
- Query
요약
Hades 캠페인으로 알려진 네트워크 공격이 26개의 PyPI 패키지를 타격하여 클라우드 인증 정보를 탈취하기 위한 공급망 공격입니다. 이 공격은 Python .pth 파일을 남용하여 인터프리터 시작 시 악성 코드를 실행하고, Bun JavaScript 런타임을 이용하여 페이로드를 실행합니다. 이는 AWS, GCP, Azure, Kubernetes, GitHub와 연결된 비밀 정보를 수집하도록 설계되었습니다.
조사
Orca Security는 생물정보학 및 개발자 도구 생태계에 퍼져 있는 37개의 악성 휠 파일을 식별했습니다. 그들의 분석 결과, Bun을 다운로드하여 난독화된 JavaScript 페이로드를 실행하는 크로스 런타임 기법이 밝혀졌습니다. 이 캠페인은 Anthropic AI 서비스로 위장 트래픽을 생성하고 LLM 기반 보안 리뷰의 효과를 줄이기 위해 프롬프트 주입 기법을 사용합니다.
완화
조직은 즉시 영향을 받은 패키지를 제거하거나 안전한 버전으로 고정하고, 잠재적으로 노출된 모든 자격 정보를 교체해야 합니다. 여기에는 클라우드 액세스 토큰, GitHub 개인 액세스 토큰, SSH 키 및 Docker 레지스트리 자격 증명이 포함됩니다. 보안 팀은 또한 Linux, macOS, Windows 호스트에서 알려진 지속성 아티팩트를 찾아야 합니다.
대응
컴프로마이즈가 의심될 경우, 영향을 받은 시스템을 격리하여 extortion의 위험을 줄이기 위해 자격 증명을 변경하세요 gh-token-monitor 데몬을 통해. 감염된 패키지를 실행한 개발자 워크스테이션과 CI/CD 러너를 재구축하세요. 공격자의 이름 패턴과 일치하는 새로 생성된 리포지토리와 승인되지 않은 커밋이 있는지 GitHub 리포지토리를 검토하세요.
“graph TB
%% Class Definitions Section
classDef technique fill:#99ccff %% Blue for MITRE ATT&CK Techniques
classDef tool fill:#cccccc %% Grey for Tools and Software
classDef action fill:#ff99cc %% Pink for specific Actions or behaviors
classDef persistence fill:#ccffcc %% Green for Persistence mechanisms
%% Node Definitions
%% Initial Access and Execution Phase
tech_supply_chain[“Technique – T1195.001 Supply Chain Compromise: Compromise Software Dependencies and Development Tools
Malicious wheel files distributed via PyPI.”]
class tech_supply_chain technique
tech_user_exec[“Technique – T1204.005 User Execution: Malicious Library
Triggered during Python interpreter initialization via *-setup.pth files.”]
class tech_user_exec technique
tech_poison_pipeline[“Technique – T1677 Poisoned Pipeline Execution
Code executes automatically in developer and CI environments.”]
class tech_poison_pipeline technique
%% Payload and Execution Phase
tool_bun[“Tool – Name: Bun JavaScript Runtime
Downloaded to execute obfuscated payload.”]
class tool_bun tool
tech_ipc[“Technique – T1559.003 Inter-Process Communication: XPC Services
Used to run the obfuscated _index.js payload.”]
class tech_ipc technique
payload_js[“File – Name: _index.js
Obfuscated JavaScript payload.”]
class payload_js tool
%% Persistence Phase
tech_persistence[“Technique – Persistence
Maintaining access on the compromised system.”]
class tech_persistence technique
tech_launch_daemon[“Technique – T1543.004 Create or Modify System Process: Launch Daemon
Uses systemd services on Linux and LaunchAgents on macOS.”]
class tech_launch_daemon technique
svc_monitor[“Process/Service – Name: gh-token-monitor.service
Example persistence mechanism.”]
class svc_monitor persistence
%% Credential Access and Exfiltration Phase
tech_cred_access[“Technique – T1212 Exploitation for Credential Access
Scraping process memory to harvest AWS, GCP, Azure, and GitHub tokens.”]
class tech_cred_access technique
tech_archive[“Technique – T1560 Archive Collected Data
Compressing stolen secrets using gzip.”]
class tech_archive technique
tech_exfil[“Technique – T1567.001 Exfiltration Over Web Service: Exfiltration to Code Repository
Sending encrypted data to attacker-controlled GitHub repositories.”]
class tech_exfil technique
%% Connections
%% Supply chain leads to user execution
tech_supply_chain –>|leads_to| tech_user_exec
%% User execution leads to poisoned pipeline
tech_user_exec –>|triggers| tech_poison_pipeline
%% Poisoned pipeline triggers the payload execution
tech_poison_pipeline –>|executes| tool_bun
%% Tooling uses IPC to run the JS payload
tool_bun –>|utilizes| tech_ipc
tech_ipc –>|runs| payload_js
%% Payload leads to persistence
payload_js –>|establishes| tech_persistence
tech_persistence –>|implements| tech_launch_daemon
tech_launch_daemon –>|creates| svc_monitor
%% Persistence enables credential access
svc_monitor –>|enables| tech_cred_access
%% Credential access leads to archiving
tech_cred_access –>|results_in| tech_archive
%% Archiving leads to final exfiltration
tech_archive –>|prepares_data_for| tech_exfil
“
공격 흐름
탐지
LaunchAgents 또는 LaunchDaemons에 의한 의심스러운 Plist 파일 생성 (via file_event)
보기
의심스러운 NodeJS 자식 프로세스 [Linux] (via cmdline)
보기
Systemd 폴더에서 서비스 파일 생성 (via file_event)
보기
사이트별 구성 후크 파일이 생성되었을 가능성 (via file_event)
보기
임시 폴더에 Linux 스크립트가 생성됨 (via file_event)
보기
악성 Python 패키지 IOCs (via cmdline)
보기
Hades 캠페인에 의한 GCP 인증 토큰 스크랩 탐지 [Google Cloud Platform]
보기
Hades 캠페인 – Azure 인증 토큰 탈취 [Azure Activity Logs]
보기
PyPI 공급망 공격을 통한 AWS 클라우드 자격 증명 수집 [AWS Cloudtrail]
보기
시뮬레이션 실행
필수 조건: 데이터 수집 및 기준선 탐색 사전 점검 필수.
이유: 이 섹션은 탐지 규칙을 유발하기 위해 고안된 적대적 기술(TTP)의 정밀한 실행을 설명합니다. 명령어와 내러티브는 발견된 TTP를 직접적으로 반영하고 탐지 논리가 기대하는 정확한 원격 측정을 생성하는 것을 목적으로 해야 합니다. 추상적이거나 관련 없는 예시는 오진을 초래할 수 있습니다.
-
공격 내러티브 및 명령: 공격자는 Hades 캠페인이라는 악성 PyPI 패키지를 통해 개발자의 워크스테이션을 성공적으로 탈취했습니다. Python 시작 후크가 실행되었고, 로컬 메모리/캐시에서 Azure 인증 토큰을 성공적으로 스크랩했습니다. 이를 시뮬레이션하기 위해 탐지 이 활동이 Azure 감사 로그에 나타나도록, 설명 필드에 특정 문자열 “Azure authentication tokens”이 포함된 감사 로그 항목 생성을 시뮬레이트할 것이며, 이는 자동화 시스템이 그러한 탈취를 탐지할 때 보고할 수 있는 이벤트 원격 측정 데이터를 모방합니다.
-
회귀 테스트 스크립트: 실제 Azure 백엔드가 실질적 침해 없이 악성 설명 문자열을 생성하도록 강제할 수 없으므로, 우리는 로그의 존재 를 원격 측류 스트림에 시뮬레이션합니다 (BAS에서는 종종 워크스페이스에 합성 로그를 삽입하여 수행).
# 토큰 탈취 탐지를 시뮬레이션하기 위한 합성 로그 삽입 # 'Description' 필드가 대상 문자열로 채워지는 것을 시뮬레이션합니다. $LogEntry = @{ TimeGenerated = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ") OperationName = "TokenExfiltrationDetected" Result = "Success" Description = "Malware activity detected: Azure authentication tokens were exfiltrated from a local process." Identity = "malicious-python-hook@attacker.com" } Write-Host "Injecting synthetic telemetry to validate detection rule..." # 실제 BAS에서는 Log Analytics Data Collector API를 호출합니다 # 시뮬레이션 목적을 위해 생성된 로그 항목을 나타냅니다: $LogEntry | ConvertTo-Json -
정리 명령:
# API를 통해 합성 로그가 삽입된 경우 특정 상관 ID를 삭제합니다 # 이 시뮬레이션에서는 Azure 테넌트에 지속적 변경이 없습니다. Write-Host "Cleanup complete. No persistent adversary artifacts remain."