Description
A wildcard read grant can include anonymous callers. s3:GetObject reads the current object and s3:GetObjectVersion reads a specified version. Other Get actions can reveal bucket settings or object information. Writing or deleting objects requires separate permissions.
Potential impact
Public reads can expose documents, logs or backups. The information disclosed depends on the action and resource the policy allows.
Remediation
- Remove unnecessary public grants. For private data, give read access only to the roles or services that need it. For public assets, limit reads to the intended objects.
- Use object ARNs for object actions and the bucket ARN for bucket actions. Check conditions, explicit denies, other policies and ACLs. Apply Block Public Access to private buckets and test both allowed and denied reads.
Examples
Set BucketName to an existing bucket. Account-level or bucket-level Block Public Access may reject the public policy. Keep those protections in place.
Before
Parameters:
BucketName:
Type: String
Resources:
SampleBucketPolicy3:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref BucketName
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action: s3:GetObject
Effect: Allow
Resource: !Sub 'arn:${AWS::Partition}:s3:::${BucketName}/*'
Principal: '*'
The wildcard principal receives s3:GetObject on all objects in the bucket.
After
Parameters:
BucketName:
Type: String
Resources:
SampleBucketPolicy3:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref BucketName
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- s3:GetObject
Effect: Deny
Resource: !Sub 'arn:${AWS::Partition}:s3:::${BucketName}/*'
Principal: '*'
The explicit deny also blocks authorized readers on those objects. If the application needs reads, remove the wildcard grant and grant access to its role.