Public S3 Buckets: How to Find and Fix Them
How to find every public S3 bucket in your AWS account, fix it with Block Public Access, and serve files that should be public through CloudFront instead.
A public S3 bucket is one that a bucket policy, ACL or access point lets anyone on the internet read or list. To find one, run aws s3api get-bucket-policy-status on every bucket and check the ACLs; to fix it, turn on S3 Block Public Access and serve anything meant to be public through CloudFront.
Public buckets remain one of the most common ways cloud data leaks, and they rarely start as a decision. They start as a quick share, a demo or a static site, and stay open long after anyone remembers why. This guide covers how to find them, how to close them, and how to keep public files public without a public bucket.

AWS treats a bucket as public when its policy or ACLs grant access to everyone. The exact definition is broad on purpose: a policy is public unless every statement is restricted to fixed principals, IP ranges or VPCs. There are four places to look:

The one people miss is AuthenticatedUsers. It sounds like your users. It means anyone with any AWS account, which is the same as public.
No, and not for a while. AWS began applying two defaults to all new buckets in April 2023: S3 Block Public Access on, and ACLs disabled through the Bucket owner enforced setting. That applies to buckets created from the console, API, CLI, SDKs and CloudFormation.
The catch is the word new. Buckets created before April 2023 kept their settings. So did buckets where someone turned the defaults off to make a share work. If your account is older than that, assume you have at least one bucket worth checking.
Start at the account level. If account-wide Block Public Access is fully on, no bucket in the account can be public, whatever its policy says:
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
aws s3control get-public-access-block --account-id "$ACCOUNT"If any of the four settings is false, check every bucket. get-bucket-policy-status answers whether the policy makes it public; the ACL check catches the older grant system:
for b in $(aws s3api list-buckets --query 'Buckets[].Name' --output text); do
pol=$(aws s3api get-bucket-policy-status --bucket "$b" \
--query 'PolicyStatus.IsPublic' --output text 2>/dev/null || echo none)
acl=$(aws s3api get-bucket-acl --bucket "$b" \
--query "Grants[?Grantee.URI!=null].Grantee.URI" --output text)
echo "$b policy_public=$pol acl_groups=$acl"
doneAny bucket showing policy_public=True or an acl_groups value ending in AllUsers or AuthenticatedUsers is public. For a continuous view, IAM Access Analyzer for S3 lists buckets shared publicly or with other accounts, and Strac checks Block Public Access on every bucket daily as part of its AWS security checklist.
S3 Block Public Access is four independent switches, available at the account level and on each bucket. The most restrictive setting wins. Turning all four on is the default and the right answer for almost every bucket.
| Setting | What it does | Blocks |
|---|---|---|
| BlockPublicAcls | Rejects requests that add a public ACL | New public ACLs |
| IgnorePublicAcls | Ignores public ACLs that already exist | Existing public ACLs |
| BlockPublicPolicy | Rejects bucket policies that grant public access | New public policies |
| RestrictPublicBuckets | Limits buckets with public policies to AWS services and the owner account | Existing public policies |
The split matters when you fix a bucket. The two Block settings stop new public grants; the Ignore and Restrict settings neutralize grants already in place. You want both halves. AWS documents each setting in the Block Public Access guide.
ACLs are the original S3 permission system and they predate IAM. They grant read or write to a bucket or a single object, and they are easy to miss because they do not show in the bucket policy. AWS now recommends turning them off with Object Ownership set to Bucket owner enforced, so policies are the only thing that grants access:
aws s3api put-bucket-ownership-controls --bucket my-bucket \
--ownership-controls 'Rules=[{ObjectOwnership=BucketOwnerEnforced}]'Before you do, check whether anything writes objects with ACLs from another account, such as a log delivery service or a partner upload. Those writes start failing once ACLs are disabled unless the writer stops sending ACL headers.

First, ask whoever owns the bucket whether it is meant to be public. Then turn on all four settings for that bucket:
aws s3api put-public-access-block --bucket my-bucket \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueBlocking makes the bucket private immediately. Then remove the public statement from the policy, or delete the policy if that was its only statement with aws s3api delete-bucket-policy --bucket my-bucket, and disable ACLs as above. Cleaning up matters because the next person to relax Block Public Access would otherwise reopen the bucket in one click.
Fixing buckets one by one is a cleanup. Turning it on for the account is the control:
aws s3control put-public-access-block --account-id "$ACCOUNT" \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueIn AWS Organizations, add a service control policy that denies s3:PutAccountPublicAccessBlock to everyone except a break-glass role, so the setting cannot be quietly switched off in a member account. This is the single setting that removes the most S3 risk for the least effort.
Marketing images, downloads and static sites do need to be public. The bucket does not. Put CloudFront with Origin Access Control in front of a private bucket, and the files are public through your CDN while the bucket stays locked.

The bucket policy trusts only your distribution:
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "AllowCloudFrontOAC",
"Effect": "Allow",
"Principal": { "Service": "cloudfront.amazonaws.com" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-public-assets/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE"
}
}
}]
}This policy is not public under AWS's definition, because the condition pins it to one distribution, so it works with all four Block Public Access settings on. You also get HTTPS, caching and access logs for free.
Want every bucket checked for public access every day?
Almost every public bucket has a reasonable origin story. Knowing them helps you find the next one before a scanner does:
acl = "public-read" that nobody questioned.The fix for the last three is the same: a safe default in code, so the easy path is the private one. In Terraform, ship every bucket with its public access block and ownership controls:
resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.this.id
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true
}
resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id
rule { object_ownership = "BucketOwnerEnforced" }
}A daily check catches a public bucket within a day. For the buckets that matter most you may want minutes. CloudTrail records the API calls that open a bucket, so an EventBridge rule can alert on them as they happen:
{
"source": ["aws.s3"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventName": ["PutBucketPolicy", "PutBucketAcl", "DeletePublicAccessBlock",
"PutPublicAccessBlock"]
}
}Route the rule to an SNS topic or your chat tool, and review each event. Real-time alerts tell you something changed; a daily posture check tells you what the state is and keeps the record your auditor wants. Most teams want both.
Closing the bucket stops new access. It does not tell you what already left. Check S3 server access logs or CloudTrail data events for GetObject and ListBucket calls from outside your accounts during the window the bucket was open. Then look at what the bucket actually held.
That second question is a data security question, and it is where Strac's background as a data security company shows. Strac's data loss prevention product scans S3 for PII, PHI, card numbers and secrets, as covered in our guide to scanning sensitive data in S3 buckets. A public bucket full of build artifacts is a cleanup. A public bucket with customer records is an incident.
Auditors test public access under SOC 2 criterion CC6.6, boundary protection, and they test it across the whole audit period. Two things make that easy:
For the broader hardening list beyond public access, including encryption, versioning and logging, see our older guide on how to secure S3 buckets in AWS. For tools that run these checks across clouds, see the best CSPM tools.
| You see | It means | Do this |
|---|---|---|
| IsPublic: true | The bucket policy grants public access | Block, then fix the policy |
| AllUsers grant in the ACL | Anyone on the internet | IgnorePublicAcls, then disable ACLs |
| AuthenticatedUsers grant | Any AWS account in the world | Treat as public |
| Access Analyzer: public | Public via policy or access point | Review the finding source |
| Pre-signed URL in use | Time-limited access to one object | Fine; keep expiry short |
| CloudFront with OAC | Public through the CDN only | Fine; the bucket stays private |
Strac checks this, and 94 other AWS settings, every day across every account you connect, and gives the CLI command to fix each finding. It does the same for public Azure blob containers and Google Cloud buckets granted to allUsers. See how Strac's CSPM works, or read what CSPM is for the bigger picture.
Run aws s3api get-bucket-policy-status --bucket NAME and check IsPublic, then check the bucket ACL for AllUsers or AuthenticatedUsers grants. IAM Access Analyzer and the S3 console also flag buckets with public access.
No. Since April 2023 AWS turns on S3 Block Public Access and disables ACLs for every new bucket. Buckets created before that keep whatever settings they had, so older accounts are where public buckets usually hide.
A bucket policy is a JSON IAM-style policy on the bucket. ACLs are an older, per-bucket and per-object grant system. AWS recommends disabling ACLs with the Bucket owner enforced Object Ownership setting and controlling access with policies only.
Keep the bucket private and put CloudFront in front of it with Origin Access Control. The bucket policy only allows the CloudFront distribution to read, so files are public through your CDN but the bucket itself is not.
No. Pre-signed URLs are signed by an identity that already has access, so they keep working with Block Public Access on. They are the right way to share a single private object for a limited time.
.avif)
.avif)
.avif)
.avif)
.avif)


.gif)

