RAWS playbook · Data and storage
S3 bucket exposed or data exfiltrated
The attacker opens a bucket to the internet, grants another account access, or reads objects in bulk. Some share data through presigned URLs, which work without further AWS sign-in until they expire. Block public access first and save the bucket policy as evidence.
Look here
| Log | Search for |
|---|---|
| CloudTrail management events | Changes to policies, access control lists (ACLs), Block Public Access and replication: PutBucketPolicy, DeleteBucketPolicy, PutBucketAcl, DeleteBucketPublicAccessBlock, PutBucketPublicAccessBlock, DeleteAccountPublicAccessBlock, PutAccountPublicAccessBlock, PutBucketReplication. The API calls PutPublicAccessBlock and DeletePublicAccessBlock appear under these names |
| CloudTrail data events | Bulk reads, counted per principal and source IP: GetObject, CopyObject, ListObjects. Anonymous reads, with Athena over the trail logs: WHERE eventsource = 's3.amazonaws.com' AND eventname = 'GetObject' AND useridentity.accountid = 'anonymous' |
| CloudTrail Lake, presigned URLs | Requests made with presigned URLs. The userIdentity shows whose credentials signed the URL: WHERE eventSource = 's3.amazonaws.com' AND element_at(additionalEventData, 'AuthenticationMethod') = 'QueryString' AND element_at(requestParameters, 'X-Amz-Expires') IS NOT NULL |
| S3 server access logs | Presigned requests: authtype = 'QueryString' and X-Amz-Expires= in the request URI |
| GuardDuty | Findings for public access changes and unusual reads: Policy:S3/BucketPublicAccessGranted, Policy:S3/BucketAnonymousAccessGranted, Policy:S3/BucketBlockPublicAccessDisabled, Policy:S3/AccountBlockPublicAccessDisabled, Exfiltration:S3/AnomalousBehavior, AttackSequence:S3/CompromisedData |
| IAM Access Analyzer | Buckets shared with public or unknown principals, shown as active external access findings |
Contain
| # | Item |
|---|---|
| 1 | Save the current bucket policy as evidence: aws s3api get-bucket-policy --bucket <bucket> > <case>-<bucket>-policy.json |
| 2 | Block public access on the bucket: aws s3api put-public-access-block --bucket <bucket> --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true" |
| 3 | Block public access for the whole account: aws s3control put-public-access-block --account-id <account> --public-access-block-configuration '{"BlockPublicAcls":true,"IgnorePublicAcls":true,"BlockPublicPolicy":true,"RestrictPublicBuckets":true}' |
| 4 | End live presigned URLs by deactivating the signing access key or revoking the signing role's sessions |
| 5 | Remove principals from other accounts in the bucket policy, then test access from an unauthenticated client |
Eradicate and recover
| # | Item |
|---|---|
| 1 | Restore the known-good bucket policy and ACLs, and remove replication rules to unknown destinations |
| 2 | Resolve each Access Analyzer finding as intended or remove the access behind it |
| 3 | List the objects read and by whom from data events. Give the list to the Legal advisor for notification deadlines |
| 4 | Where data events were off, record that object access cannot be ruled out |
| 5 | Turn on data events for the bucket before return to service |
Watch out
- A presigned URL made with IAM user keys stays valid up to 7 days. Revoking, deleting or deactivating the signing credential ends it.
- Without data events or server access logs, CloudTrail shows the policy change and no reads.