All guides

S3 bucket security: the settings to check on every bucket

A new S3 bucket does not allow public access, encrypts new objects and has ACLs disabled. Seven settings show whether an existing bucket matches that.

A desk with two monitors showing code

Block Public Access

S3 Block Public Access has four settings. They override the policies and permissions that would allow public access:

  • BlockPublicAcls makes requests fail when they set a public ACL on a bucket or an object.
  • IgnorePublicAcls makes S3 ignore all public ACLs on a bucket and the objects in it.
  • BlockPublicPolicy makes S3 reject a bucket policy that allows public access.
  • RestrictPublicBuckets restricts a bucket that has a public policy to AWS service principals and authorized users in the bucket owner's account.

AWS recommends that you turn on all four for the account and also for each bucket. S3 applies the most restrictive combination of the two levels. For BlockPublicPolicy, AWS recommends the account level in particular: a user who can change a bucket policy could otherwise insert a policy that lets them disable the bucket's own setting.

Shell

aws s3control put-public-access-block \
  --account-id 111122223333 \
  --public-access-block-configuration \
  BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

With AWS Organizations, one organization-level policy applies all four settings together to the member accounts you select. The settings do not alter existing policies or ACLs. Remove a setting, and any bucket or object that has a public policy or ACL becomes publicly accessible again.

Default encryption

Every bucket has encryption configured by default. Since 5 January 2023, S3 encrypts all new object uploads with S3 managed keys (SSE-S3), at no additional cost. Objects that were in a bucket before default encryption was enabled are not changed.

Use SSE-KMS when you need more control over the keys, such as managing key rotation and access policy grants. An S3 Bucket Key reduces the AWS KMS request costs of SSE-KMS. S3 does not validate the KMS key ID that you set as the default, so verify it yourself.

Since April 2026, S3 also disables encryption with customer-provided keys (SSE-C) on all new general purpose buckets. AWS recommends keeping it disabled unless a workload requires it.

A bucket policy that requires TLS

AWS recommends allowing only encrypted connections over HTTPS (TLS), with the aws:SecureTransport condition in the bucket policy. This is the AWS example. It explicitly denies HTTP requests:

JSON

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RestrictToTLSRequestsOnly",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:s3:::my-app-data",
        "arn:aws:s3:::my-app-data/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }
  ]
}

ACLs and Object Ownership

Object Ownership has three settings. The default is Bucket owner enforced: ACLs are disabled, the bucket owner owns every object, and the bucket uses policies to define access control. The other two, Bucket owner preferred and Object writer, keep ACLs enabled.

With ACLs disabled, the bucket accepts only PUT requests that specify no ACL or a bucket owner full control ACL. Requests that contain other ACLs fail with a 400 error and the code AccessControlListNotSupported. Before you disable ACLs on a bucket that has them, AWS recommends reviewing the bucket policy so that it covers every way you intend to grant access from outside your account.

Versioning and logging

Versioning is disabled by default. Once it is enabled, an overwrite creates a new object version, and a delete inserts a delete marker, so you can restore the previous version. A bucket with versioning enabled can be suspended but can never return to the unversioned state. S3 charges for every version stored: three versions of an object are charged as three objects. Use S3 Lifecycle with versioning to control storage costs.

Shell

aws s3api put-bucket-versioning \
  --bucket my-app-data \
  --versioning-configuration Status=Enabled

Two logs record access:

  • CloudTrail logs bucket-level API calls, such as PutBucketPolicy, by default. It does not log requests made to objects unless you log S3 data events, and data events carry additional charges.
  • Server access logging provides detailed records of the requests made to a bucket. S3 delivers them to a general purpose bucket or to CloudWatch Logs. Delivery is best effort. AWS states that the logs are not intended as a complete account of every request.

A bucket that receives server access logs must use SSE-S3 as its default encryption.

IAM Access Analyzer for S3

IAM Access Analyzer for S3 reports the general purpose buckets that allow access to anyone on the internet or to other AWS accounts. Each finding names the route of the access: a bucket ACL, a bucket policy, a Multi-Region Access Point policy or an access point policy. It is available at no extra cost in the S3 console. It requires an account-level analyzer, created in IAM Access Analyzer, in each Region where you have buckets. Archive the findings for buckets that you intend to keep public or shared. Change the access on the rest.

Six commands for an audit

Shell

aws s3api get-public-access-block --bucket my-app-data
aws s3api get-bucket-encryption --bucket my-app-data
aws s3api get-bucket-policy --bucket my-app-data
aws s3api get-bucket-ownership-controls --bucket my-app-data
aws s3api get-bucket-versioning --bucket my-app-data
aws s3api get-bucket-logging --bucket my-app-data

Read the output in the same order. Check that all four public access settings are true. Check that the encryption names the algorithm and key you chose. Check that the policy carries the TLS statement. The last three commands return the ownership, versioning and logging settings. Run the set for each bucket.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides