AWS Builder Center
Amazon S3 Security Beyond the Basics: Access, Exposure and Common Mistakes

Amazon S3 Security Beyond the Basics: Access, Exposure and Common Mistakes

Amazon S3 makes storing data in the cloud straightforward, but securing that data takes more than creating a bucket and enabling encryption. Learn how public access settings, bucket policies, IAM permissions, encryption, and versioning work together to protect your data in practical AWS projects.



Introduction: A bucket can work perfectly and still be insecure

Imagine you've built a small AWS project. Your application uploads reports to Amazon S3, and everything works as expected. Files upload successfully, your application can retrieve them, and the project is ready to demonstrate.
But there's one question you might not have considered: who else can access those files?
A working application doesn't automatically mean a secure application. A bucket can contain sensitive files, an overly permissive policy can expose data, or an accidental configuration change can make previously private resources accessible.
Amazon S3 provides several security controls, and most new general-purpose buckets start with important protections enabled. The challenge is understanding what those protections do, what they don't do, and how to check your configuration instead of simply assuming it's safe.
In this article, I'll walk through the practical security decisions I think every AWS learner should understand before using S3 in a real project.

1. Start with Block Public Access

One of the first things I would check when creating an S3 bucket is Block Public Access.
This feature helps prevent public access through bucket policies and access control lists (ACLs). S3 enables all four Block Public Access settings by default for new general-purpose buckets, and AWS recommends keeping them enabled unless a specific use case requires otherwise.
Why does this matter?
Suppose you're storing project reports, application logs, or uploaded documents. These files generally shouldn't be readable by anyone on the internet. If public access is accidentally allowed, a person who discovers an exposed resource may be able to read its contents without being an authorized user.
The four settings are:
  • BlockPublicAcls: Blocks attempts to apply public ACLs.
  • IgnorePublicAcls: Prevents public ACL permissions from being used to grant access.
  • BlockPublicPolicy: Blocks new bucket policies that grant public access.
  • RestrictPublicBuckets: Restricts certain public and cross-account access associated with public policies.
You can review these settings in the S3 console by opening your bucket and checking Permissions → Block public access.
One important detail: enabling Block Public Access doesn't replace reviewing existing policies. The settings prevent or restrict public access, but they don't necessarily remove the underlying policy or ACL that caused the exposure. Review the actual configuration as well.

2. Understand who is allowed to access your bucket

S3 permissions can be managed through different mechanisms, and understanding their responsibilities makes security decisions easier.
IAM identity-based policies grant permissions to users, groups, or roles. For example, an EC2 application might need permission to read files from a particular bucket.
S3 bucket policies are resource-based policies attached directly to a bucket. They can grant or restrict access based on the principal, requested action, resource, and applicable conditions.
Access control lists (ACLs) are an older access-management mechanism. Modern S3 use cases generally don't need them, and AWS recommends disabling ACLs unless you have a specific requirement for object-level access control.
Here's a practical example of a risky bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::project-documents/*"
}
]
}
The wildcard principal ( "Principal": "*" ) allows access by any principal covered by the policy, including anonymous internet users when the policy is publicly accessible and no other control blocks that access.
The policy grants read access to objects in  project-documents . It doesn't grant upload or deletion permission, but exposing confidential files for reading can still be a serious security problem.
For a private application bucket, this is usually not the access model you want.
Instead, grant access to the specific IAM role or AWS account that needs it, and keep public access blocked unless public access is an intentional requirement.

3. Give applications only the permissions they need

Let's connect S3 security to the IAM concepts from my previous article.
Imagine an application running on an EC2 instance that needs to read reports from a single S3 bucket. It doesn't need to upload files, delete objects, or access every bucket in the AWS account.
A sensible approach is to attach an IAM role to the EC2 instance and grant that role only the required S3 permissions.
For example, the following identity-based policy allows listing one bucket and reading its objects:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::project-documents"
},
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::project-documents/*"
}
]
}
Notice the two different resource formats.
  •  arn:aws:s3:::project-documents  identifies the bucket itself. It's used here for  s3:ListBucket .
  •  arn:aws:s3:::project-documents/*  identifies objects inside that bucket. It's used here for  s3:GetObject .
This distinction matters because bucket-level actions and object-level actions don't use the same resource ARN.
The policy doesn't grant  s3:PutObject  or  s3:DeleteObject , because this example application doesn't need to upload or delete files.
Attach the policy to the appropriate role, configure the EC2 instance to use that role, and let the application obtain temporary credentials through the AWS SDK or another supported AWS credential provider.
This is preferable to storing long-term access keys directly in application code.
A useful rule: Don't start by asking which permissions will make the error disappear. Start by identifying the exact operation the application must perform, then grant the minimum permissions needed for it.
Before using any example policy in a real environment, replace the example bucket name, review the application's actual requirements, and test the permissions in a non-production environment.

4. Encryption matters, but it isn't the whole security strategy

Amazon S3 supports encryption at rest, and new S3 uploads are automatically encrypted using server-side encryption with Amazon S3 managed keys (SSE-S3) by default.
For many projects, that default is a sensible starting point. Some environments may require AWS Key Management Service (AWS KMS) keys, additional key-management controls, or specific compliance configurations.
It's also important to protect data while it travels between your application and S3. Use HTTPS so requests are protected in transit.
A bucket policy can enforce secure transport by denying requests that don't use HTTPS. For example:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::project-documents",
"arn:aws:s3:::project-documents/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
}
This is an illustrative bucket-policy statement that denies S3 requests made without secure transport. Test policy changes carefully, especially when working with applications or services that access the bucket.
Encryption does not make an exposed bucket private. An authorized or unauthorized reader who can access an object may still receive its decrypted contents through S3. That's why encryption and access control need to work together.

5. Enable versioning when recovery matters

Security isn't only about preventing unauthorized access. It's also about recovering from mistakes and unwanted changes.
Imagine uploading a report and later overwriting it with the wrong file. Or imagine an application accidentally replacing an important object.
With S3 Versioning enabled, S3 can preserve multiple versions of an object, allowing you to recover an earlier version in supported scenarios.
Versioning is useful for project files, backups, logs, and other data where accidental overwrites or deletions could cause problems.
However, versioning isn't a complete backup strategy, and it doesn't prevent someone with sufficient permissions from changing or deleting data. It can also increase storage costs because older versions remain stored.
For particularly important data, consider additional controls such as restricted deletion permissions, lifecycle policies, replication where appropriate, and S3 Object Lock when your retention requirements justify it.
Choose the recovery controls that match the value of the data and the risks your application faces.

6. Common S3 security mistakes to avoid

Here are several mistakes worth checking in your own projects.
Mistake 1: Making a bucket public just to fix an access error
If an application receives  AccessDenied , investigate the identity, IAM policy, bucket policy, resource ARN, and any applicable organization-level or encryption-related restrictions. Making the bucket public may hide the original problem while creating a much bigger one.
Mistake 2: Using wildcards without understanding their impact
Permissions such as  "Action": "s3:*"  or a wildcard principal can grant far more access than intended. Use specific actions and trusted principals wherever possible.
Mistake 3: Assuming encryption means the data is safe
Encryption at rest protects stored data, but it doesn't replace access controls, secure transport, monitoring, or careful key management.
Mistake 4: Forgetting about old object versions
Versioning can help with recovery, but previous versions may continue to consume storage. Set appropriate retention and lifecycle rules, and understand how deletion works when versioning is enabled.
Mistake 5: Never reviewing the configuration after deployment
A bucket that was secure on day one can become exposed after a policy or settings change. Review permissions periodically and consider using AWS Config, AWS Security Hub, and AWS CloudTrail where appropriate for configuration checks, security findings, and activity auditing.

7. A practical S3 security checklist

For your next AWS lab, use this checklist before considering the storage configuration complete.
  • Keep S3 Block Public Access enabled unless public access is specifically required.
  • Review bucket policies for wildcard principals and unnecessarily broad actions.
  • Grant application access through an IAM role where appropriate.
  • Restrict permissions to the required actions, bucket, and objects.
  • Keep ACLs disabled unless your use case requires them.
  • Confirm encryption settings match your project's requirements.
  • Use HTTPS for requests to S3.
  • Consider versioning and recovery controls for important data.
  • Review logs and configuration changes when the project's risk justifies it.
  • Test access from both an authorized identity and an identity that should be denied.
For learning projects, you can also create a small test bucket with sample files and verify that your intended identity can read them while an unauthorized identity cannot. Avoid placing real personal or confidential data in experimental buckets.

Final thoughts

The biggest lesson I'm taking from learning AWS security is that a service being easy to configure doesn't mean its security can be left to defaults alone.
Amazon S3 gives us useful protections, but we still need to understand who can access the data, which actions are allowed, how the data is protected, and how we would recover if something went wrong.
For me, the best way to learn these concepts is to build small projects, inspect the policies behind them, and test what different identities can and cannot do.
One question I'd like to hear your thoughts on: When you're setting up an S3 bucket for a new project, which do you check first—public access settings, IAM permissions, or encryption? And why?

Further reading

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article