Review access restrictions for S3 public policies

Restrict access to S3 buckets with public policies and remove unnecessary public grants.

Description

RestrictPublicBuckets limits access to a bucket with a public policy to authorized principals in the bucket owner’s account and AWS service principals. It can block a named external account even when a separate statement in that policy grants it access.

Potential impact

An effective public policy may expose objects or allow changes and deletions, depending on the actions it grants.

Remediation

For a private bucket, set RestrictPublicBuckets: true in PublicAccessBlockConfiguration. Edit the policy to name only the principals, actions and resources you need, then test service and cross-account access. Check the ACL controls and any stricter account settings.

Examples

Before

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

Both templates block new public policies. The first leaves access through an existing public policy unrestricted by this bucket option.

After

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

The second enables all four options. Any existing public policy still needs review.

References