performing-cloud-forensics-investigation について
AWS、Azure、GCP のインシデントに対応するセキュリティチーム向けのクラウドフォレンジック調査スキルです。証拠保全、ログ収集、アクセス分析、ディスク調査、報告書作成の手順を扱います。
主な機能
- 01クラウド証拠の保全と範囲設定
- 02クラウド API ログの収集
- 03IAM とアクセスパターンの分析
- 04仮想マシンのディスク調査
- 05調査報告書の作成
活用シーン
- 01不正利用されたクラウド IAM 認証情報の調査
- 02侵害されたクラウド仮想マシンの分析
- 03クラウドサービスでの不正アクセス追跡
- 04インシデント対応に必要な証拠の保全
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill performing-cloud-forensics-investigationインストール後、Claude Code で/performing-cloud-forensics-investigationを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEreferences/api-reference.mdscripts/agent.py詳細
クラウドフォレンジック調査の実施
使用する場面
- AWS、Azure、GCP のクラウド環境でセキュリティ侵害を調査する場合
- クラウドインフラストラクチャから揮発性および不揮発性の証拠を収集する場合
- クラウドサービスの API ログを通じて不正アクセスの経路を追跡する場合
- クラウド上の証拠の保全が必要なインシデント対応を行う場合
- 侵害された仮想マシン、コンテナ、またはサーバーレス関数を分析する場合
前提条件
- 調査対象のクラウドアカウントへの管理者アクセス権
- 適切な権限で設定された AWS CLI、Azure CLI、または gcloud CLI
- クラウドネイティブなロギング(CloudTrail、Activity Log、Audit Log)に関する理解
- クラウド SDK をインストールしたフォレンジック用ワークステーション
- 対象のクラウドにおける IAM、ネットワーキング、コンピューティングサービスに関する知識
- クラウド環境における証拠保全手順
ワークフロー
ステップ 1:クラウド上の証拠を保全し、調査範囲を確定する
# === AWS Evidence Preservation ===
# Snapshot compromised EC2 instance volumes
INSTANCE_ID="i-0abc123def456789"
VOLUME_IDS=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID \
--query 'Reservations[].Instances[].BlockDeviceMappings[].Ebs.VolumeId' --output text)
for vol in $VOLUME_IDS; do
aws ec2 create-snapshot --volume-id $vol \
--description "Forensic snapshot - Case 2024-001 - $(date -u)" \
--tag-specifications "ResourceType=snapshot,Tags=[{Key=Case,Value=2024-001},{Key=Evidence,Value=true}]"
done
# Capture instance metadata
aws ec2 describe-instances --instance-ids $INSTANCE_ID \
> /cases/case-2024-001/cloud/instance_metadata.json
# Capture security group rules
aws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances \
--instance-ids $INSTANCE_ID --query 'Reservations[].Instances[].SecurityGroups[].GroupId' --output text) \
> /cases/case-2024-001/cloud/security_groups.json
# Capture network interfaces
aws ec2 describe-network-interfaces --filters "Name=attachment.instance-id,Values=$INSTANCE_ID" \
> /cases/case-2024-001/cloud/network_interfaces.json
# Isolate the instance (replace security group with forensic isolation SG)
aws ec2 modify-instance-attribute --instance-id $INSTANCE_ID \
--groups sg-forensic-isolation
# === Azure Evidence Preservation ===
# Snapshot a compromised VM disk
az snapshot create --resource-group forensics-rg \
--name "case-2024-001-osdisk-snapshot" \
--source "/subscriptions/SUB_ID/resourceGroups/RG/providers/Microsoft.Compute/disks/vm-osdisk"
# === GCP Evidence Preservation ===
gcloud compute disks snapshot compromised-disk \
--snapshot-names="case-2024-001-forensic" \
--zone=us-central1-a
ステップ 2:クラウド API とアクセスのログを収集する
# === AWS CloudTrail Logs ===
# Download CloudTrail events for the investigation period
aws cloudtrail lookup-events \
--start-time "2024-01-15T00:00:00Z" \
--end-time "2024-01-20T23:59:59Z" \
--max-results 1000 \
> /cases/case-2024-001/cloud/cloudtrail_events.json
# Filter for specific user activity
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=Username,AttributeValue=compromised-user \
--start-time "2024-01-15T00:00:00Z" \
> /cases/case-2024-001/cloud/user_activity.json
# Download S3 access logs
aws s3 sync s3://my-cloudtrail-bucket/AWSLogs/ /cases/case-2024-001/cloud/cloudtrail_s3/
# Query CloudTrail with Athena for large-scale analysis
aws athena start-query-execution \
--query-string "SELECT eventTime, eventName, userIdentity.arn, sourceIPAddress, errorCode
FROM cloudtrail_logs
WHERE eventTime BETWEEN '2024-01-15' AND '2024-01-20'
AND sourceIPAddress NOT IN ('10.0.0.0/8')
ORDER BY eventTime" \
--result-configuration OutputLocation=s3://forensics-bucket/athena-results/
# === AWS VPC Flow Logs ===
aws logs filter-log-events \
--log-group-name "vpc-flow-logs" \
--start-time $(date -d "2024-01-15" +%s000) \
--end-time $(date -d "2024-01-20" +%s000) \
--filter-pattern "ACCEPT" \
> /cases/case-2024-001/cloud/vpc_flow_logs.json
# === Azure Activity Log ===
az monitor activity-log list \
--start-time "2024-01-15T00:00:00Z" \
--end-time "2024-01-20T23:59:59Z" \
--output json > /cases/case-2024-001/cloud/azure_activity.json
# === GCP Audit Logs ===
gcloud logging read 'logName="projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity"
AND timestamp>="2024-01-15T00:00:00Z"
AND timestamp<="2024-01-20T23:59:59Z"' \
--format=json > /cases/case-2024-001/cloud/gcp_audit.json
ステップ 3:IAM とアクセスパターンを分析する
# Analyze compromised credentials usage
python3 << 'PYEOF'
import json
from collections import defaultdict
with open('/cases/case-2024-001/cloud/cloudtrail_events.json') as f:
data = json.load(f)
# Analyze by source IP
ip_events = defaultdict(list)
error_events = []
critical_actions = []
for event in data.get('Events', []):
ct = json.loads(event.get('CloudTrailEvent', '{}'))
source_ip = ct.get('sourceIPAddress', 'Unknown')
event_name = ct.get('eventName', 'Unknown')
user_arn = ct.get('userIdentity', {}).get('arn', 'Unknown')
error = ct.get('errorCode')
timestamp = ct.get('eventTime', '')
ip_events[source_ip].append(event_name)
if error:
error_events.append({'time': timestamp, 'action': event_name, 'error': error, 'ip': source_ip})
# Flag critical actions
critical = ['CreateUser', 'CreateAccessKey', 'AttachUserPolicy', 'CreateRole',
'PutBucketPolicy', 'StopLogging', 'DeleteTrail', 'CreateKeyPair',
'RunInstances', 'AuthorizeSecurityGroupIngress']
if event_name in critical:
critical_actions.append({'time': timestamp, 'action': event_name, 'user': user_arn, 'ip': source_ip})
print("=== SOURCE IP ANALYSIS ===")
for ip, events in sorted(ip_events.items(), key=lambda x: len(x[1]), reverse=True):
print(f" {ip}: {len(events)} events ({len(set(events))} unique actions)")
print(f"\n=== ACCESS ERRORS ({len(error_events)} total) ===")
for e in error_events[:10]:
print(f" [{e['time']}] {e['action']} -> {e['error']} from {e['ip']}")
print(f"\n=== CRITICAL ACTIONS ({len(critical_actions)} total) ===")
for a in critical_actions:
print(f" [{a['time']}] {a['action']} by {a['user']} from {a['ip']}")
PYEOF
ステップ 4:VM のディスクイメージを取得して分析する
# Create a forensic analysis instance from the snapshot
SNAPSHOT_ID="snap-0abc123def456789"
# Create volume from snapshot in isolated forensic VPC
FORENSIC_VOL=$(aws ec2 create-volume --snapshot-id $SNAPSHOT_ID \
--availability-zone us-east-1a \
--tag-specifications "ResourceType=volume,Tags=[{Key=Case,Value=2024-001}]" \
--query 'VolumeId' --output text)
# Attach to forensic analysis instance (read-only mount)
aws ec2 attach-volume --volume-id $FORENSIC_VOL \
--instance-id i-forensic-workstation \
--device /dev/xvdf
# On the forensic instance, mount read-only
sudo mount -o ro /dev/xvdf1 /mnt/evidence
# Perform standard disk forensics on the mounted volume
# Extract logs, analyze file system, check for persistence
ls /mnt/evidence/var/log/
cp -r /mnt/evidence/var/log/ /cases/case-2024-001/cloud/vm_logs/
cp -r /mnt/evidence/etc/crontab /cases/case-2024-001/cloud/persistence/
cp -r /mnt/evidence/home/*/.ssh/ /cases/case-2024-001/cloud/ssh_keys/
cp -r /mnt/evidence/home/*/.bash_history /cases/case-2024-001/cloud/bash_history/
ステップ 5:クラウドフォレンジックレポートを作成する
# Compile findings into structured report
python3 << 'PYEOF'
report = """
CLOUD FORENSICS INVESTIGATION REPORT
======================================
Case: 2024-001
Cloud Provider: AWS (Account: 123456789012)
Region: us-east-1
Investigation Period: 2024-01-15 to 2024-01-20
EVIDENCE PRESERVED:
- EC2 Instance Snapshot: snap-0abc123def456789 (i-0abc123def456789)
- CloudTrail Logs: 2024-01-15 to 2024-01-20
- VPC Flow Logs: 2024-01-15 to 2024-01-20
- Instance Metadata: captured and hashed
- Security Group Configuration: captured at time of isolation
FINDINGS:
1. Initial Access:
- Compromised IAM access key AKIA... used from IP 203.0.113.45
- First unauthorized API call: 2024-01-15 14:32:00 UTC
- IP geolocation: Foreign jurisdiction (not company IP range)
2. Persistence:
- New IAM user 'backup-admin' created with AdministratorAccess
- New access key pair generated for backup-admin
- SSH key added to EC2 instance authorized_keys
3. Lateral Movement:
- S3 bucket policies modified to allow public access
- Security group rules modified to allow SSH from 0.0.0.0/0
- 3 additional EC2 instances launched for crypto-mining
4. Data Exfiltration:
- S3 bucket 'company-confidential' accessed 234 times
- 12 GB of data downloaded via GetObject API calls
- Data transferred to external IP 185.x.x.x
5. Anti-Forensics:
- CloudTrail logging disabled at 2024-01-18 03:00 UTC
- CloudWatch log groups deleted
RECOMMENDATIONS:
- Rotate all IAM credentials immediately
- Enable MFA on all accounts
- Restore CloudTrail logging
- Review and restrict S3 bucket policies
- Implement GuardDuty for continuous monitoring
"""
with open('/cases/case-2024-001/cloud/cloud_forensics_report.txt', 'w') as f:
f.write(report)
print(report)
PYEOF
主要な概念
| 概念 | 説明 |
|---|---|
| クラウド API ロギング | すべての API 呼び出しを記録するサービスログ(CloudTrail、Activity Log、Audit Log) |
| ボリュームスナップショット | フォレンジック保全のために取得する、クラウドディスクボリュームの特定時点のコピー |
| VPC Flow Logs | 送信元、宛先、アクションを示すネットワークトラフィックのメタデータログ |
| IAM 認証情報の侵害 | アクセスキー、トークン、または引き受けたロールの不正使用 |
| インスタンスメタデータ | ネットワーク、ストレージ、セキュリティ設定などを含む EC2/VM の構成データ |
| 共有責任 | クラウドプロバイダーはインフラストラクチャを保護し、顧客はデータとアクセスを保護します |
| 証拠の揮発性 | クラウドリソースは終了される可能性があるため、証拠を速やかに保全する必要があります |
| 複数リージョンにまたがる痕跡 | 攻撃がリージョンをまたぐ場合があり、リージョン間でログを収集する必要があります |
ツールとシステム
| ツール | 用途 |
|---|---|
| AWS CLI | AWS サービスの操作とログ収集に使用するコマンドラインインターフェース |
| CloudTrail | 調査と監査のために AWS API 呼び出しを記録するサービス |
| Azure Monitor | Azure のロギングおよび診断プラットフォーム |
| GCP Cloud Logging | Google Cloud の監査およびアクセスのログ記録サービス |
| Athena | CloudTrail ログを大規模に分析するための AWS サーバーレス SQL クエリサービス |
| Prowler | オープンソースの AWS セキュリティ評価およびフォレンジック収集ツール |
| ScoutSuite | マルチクラウドのセキュリティ監査ツール |
| CADO Response | クラウドネイティブなデジタルフォレンジックおよびインシデント対応プラットフォーム |
よくあるシナリオ
シナリオ 1:IAM アクセスキーの侵害 CloudTrail で侵害されたキーを特定し、そのキーで行われたすべての API 呼び出しを追跡して、送信元 IP アドレスと実行されたアクションを特定します。永続化の仕組み(新しいユーザー、ロール、キー)がないか確認し、侵害された認証情報を無効化して、データアクセスの範囲を評価します。
シナリオ 2:EC2 インスタンスでのクリプトジャッキング CloudTrail で不正なインスタンスの起動を検出し、分析用にマイニングインスタンスのスナップショットを取得します。C2 通信を許可したセキュリティグループの変更を調査し、初期アクセス経路(盗まれたキー、SSRF)を特定して、発生したリソースコストを算出します。
シナリオ 3:S3 のデータ侵害 S3 アクセスログと CloudTrail を分析して、GetObject/PutBucketPolicy イベントを確認します。バケットポリシーを変更してパブリックアクセスを許可したユーザーを特定し、データ漏えいの範囲を判断します。不正な IP アドレスからのデータダウンロードがないか確認し、規制に基づく報告要件を評価します。
シナリオ 4:EKS/AKS/GKE でのコンテナエスケープ Kubernetes の監査ログとクラウドプロバイダーのログを収集し、権限昇格の試みがないか Pod の作成イベントを分析します。コンテナエスケープの証拠がないかノードレベルのログを調査し、クラウドメタデータサービス(169.254.169.254)への不正アクセスを確認して、クラウド API へのラテラルムーブメントを追跡します。
出力形式
Cloud Forensics Summary:
Cloud: AWS (us-east-1) Account: 123456789012
Investigation: 2024-01-15 to 2024-01-20
Incident Type: IAM Credential Compromise + Data Exfiltration
Evidence Collected:
EBS Snapshots: 3 volumes preserved
CloudTrail Events: 12,456 (1,234 from attacker IP)
VPC Flow Logs: 45,678 records
S3 Access Logs: 2,345 entries
Attack Timeline:
2024-01-15 14:32 - Compromised access key first used from 203.0.113.45
2024-01-15 14:45 - New IAM user created with admin privileges
2024-01-16 02:00 - S3 bucket policy modified (public access enabled)
2024-01-16 03:00 - 12 GB downloaded from company-confidential bucket
2024-01-18 03:00 - CloudTrail logging disabled
Impact Assessment:
Data Exposed: 12 GB from 3 S3 buckets
Resources Created: 3 EC2 instances (crypto mining)
Estimated Cost: $4,500 in unauthorized compute