Review S3 public-policy blocking

Align S3 public-policy blocking with actual public-access requirements and other access controls.

Description

BlockPublicPolicy rejects a new or updated bucket policy that S3 classifies as public. Existing policies stay in place. New buckets enable Block Public Access by default, so check the deployed bucket and account settings if the template omits them.

Potential impact

A later policy change could expose objects if it grants public access and no other control blocks it.

Remediation

Enable all four Block Public Access options on private buckets and remove unnecessary public grants from policies and ACLs. If a service needs public access, review whether a private bucket can serve it first. Limit any public grant to the actions and objects it needs. Test required service and cross-account access.

Examples

Before

yaml
Resources:
  Bucket13:
    Type: AWS::S3::Bucket
    Properties:
      PublicAccessBlockConfiguration:
        BlockPublicAcls: false
        BlockPublicPolicy: false
        IgnorePublicAcls: false
        RestrictPublicBuckets: true

The first template still limits access through public policies with RestrictPublicBuckets. A stricter account setting can also reject new public policies.

After

yaml
Resources:
  Bucket13:
    Type: AWS::S3::Bucket
    Properties:
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: true
        IgnorePublicAcls: true
        RestrictPublicBuckets: true

The second template enables all four options. Neither template grants access by itself.

References