误将 S3 Bucket 设为 public-read 或关闭 Block Public Access,是云上数据泄露最常见根因。攻击者可通过 Bucket 枚举工具批量发现并下载敏感对象。
![]()
一、批量审计并加固桶策略
bash
# 列出所有账户下开启了公共访问的桶
aws s3api list-buckets --query "Buckets[].Name" --output text | \
while read b; do
status=$(aws s3api get-public-access-block --bucket "$b" --query "PublicAccessBlockConfiguration" 2>/dev/null || echo "NONE")
echo "$b -> $status"
done
# 强制开启 Block Public Access
aws s3api put-public-access-block --bucket my-bucket \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true