"Nobody will find a public S3 bucket." They will. Bucket names are often guessable, automated tools search for open buckets, and a single line in a bucket policy can make a whole bucket readable by anyone on the internet. Two features decide whether that happens: the bucket policy and S3 Block Public Access.
Bucket policies: who can do what
A bucket policy is a JSON resource-based policy attached to the bucket. Each statement answers four questions:
- Principal: who (an account, an IAM role, an AWS service).
- Action: what they can do, such as
s3:GetObjectors3:PutObject. - Resource: which bucket or objects, such as
arn:aws:s3:::my-bucket/reports/*. - Effect:
AlloworDeny, optionally with conditions (source VPC endpoint, organization ID, TLS only).
The usual IAM evaluation rules apply: an explicit Deny always wins over any Allow. Good uses of a bucket policy include denying requests that don't use HTTPS, allowing only your organization, or granting one CloudFront distribution read access.
The dangerous line
"Principal": "*" with "Effect": "Allow" and no limiting condition means anyone, signed in to AWS or not. S3 treats a policy as public unless it limits access to fixed values such as specific principals, an organization ID, a VPC or VPC endpoint, or a narrow IP range. Older buckets can also be made public through ACLs (access control lists).
Block Public Access: the safety net
S3 Block Public Access overrides policies and ACLs that would make data public. It has four independent settings:
- BlockPublicAcls: reject requests that add a public ACL.
- IgnorePublicAcls: ignore any public ACLs that already exist.
- BlockPublicPolicy: reject a bucket policy that would grant public access.
- RestrictPublicBuckets: if a public policy exists anyway, only AWS service principals and users in the bucket owner's account can use it.
You can set them on an access point, a bucket, an account, or across an AWS Organization (where all four are applied together). S3 applies the most restrictive combination, so a bucket can't switch off what its account or organization enforces. New buckets start with all four settings on, and ACLs are disabled by default.
A common mistake is turning Block Public Access off to host a website. AWS's recommended pattern is to keep the bucket private and serve it through CloudFront with origin access control. Another: thinking Block Public Access cleans up old policies. It doesn't change them; turn it off and a public policy works again.
Where AI fits
Training datasets often contain exactly what you must not leak: customer records, support chats, documents, internal code. A bucket opened "for a quick test" so a notebook or vendor can read it is a data breach waiting to happen. Keep Block Public Access on at the account or organization level, share data with specific roles or accounts instead, and use IAM Access Analyzer for S3, which flags buckets that allow access from the internet or from other AWS accounts and can block public access in one click. If an AI assistant writes your bucket policy, check it for a wildcard principal before you apply it.
Quick recap
- A bucket policy says who can do what, to which objects; an explicit Deny always wins.
"Principal": "*"with Allow and no condition means anyone on the internet.- Keep all four Block Public Access settings on, ideally at the account or organization level; new buckets start with them on.