Description
Objects served from an S3 website endpoint must be publicly readable. WebsiteConfiguration selects the index and error pages. The endpoint supports HTTP only.
Potential impact
A bucket-wide public-read policy can expose backups or configuration files stored with the site. Responses delivered directly over HTTP have no TLS protection in transit.
Remediation
When retiring a site, test its replacement before removing the website configuration and public policy and enabling Block Public Access. For a site that stays public, isolate published files and limit deployment permissions. For HTTPS with a private bucket, use a CloudFront S3 REST origin with origin access control (OAC). A website endpoint cannot use OAC.
Examples
Upload the referenced index.html and error.html for the website example. Account-level Block Public Access can reject its public policy.
Before
Resources:
Bucket2:
Type: AWS::S3::Bucket
Properties:
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: false
IgnorePublicAcls: true
RestrictPublicBuckets: false
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
WebsiteReadPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref Bucket2
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal: '*'
Action: s3:GetObject
Resource: !Sub '${Bucket2.Arn}/*'
The first template disables ACLs and uses a bucket policy to grant public reads of every object.
After
Resources:
Bucket2:
Type: AWS::S3::Bucket
Properties:
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
The second removes the website and public-read policy from the same bucket and enables all four block settings. After deployment, verify that an anonymous request cannot read an existing object.