How to Find All Publicly Accessible S3 Buckets in Your AWS Account
Publicly accessible S3 buckets are a leading cause of cloud data breaches, exposing millions of sensitive records annually. This guide shows how to use CloudQuery to identify at-risk buckets and enhance your AWS security posture. Finding and blocking public S3 access is also required by CIS AWS Foundations Benchmark control 2.1.5 - so the queries here double as compliance evidence.
By the end of this post, you will:
- Learn how to sync your AWS S3 data with CloudQuery.
- Understand the risks associated with public S3 buckets.
- Run queries to identify publicly accessible buckets using CloudQuery.
What is CloudQuery?
CloudQuery streamlines cloud asset management by enabling you to query and analyze your cloud data across all regions and cloud providers. Beyond listing publicly accessible S3 buckets, it helps you inventory your cloud assets, monitor compliance, optimize cloud costs, and improve overall governance with a centralized, queryable view of your cloud environment.

How to sync your AWS Cloud Data with CloudQuery
Here is a step-by-step guide on how to configure the AWS Source integration and use the collected data.
Analyzing your Data
With CloudQuery, you can run queries about your synced data directly in the integrated SQL Editor.

Find All S3 Buckets with Public Policies
Public policies (e.g., Principal: "*") expose buckets to anyone. Use this query to identify such configurations:
Find S3 Buckets with Public Grants
Grants to AllUsers or AuthenticatedUsers allow broad access to bucket contents:
Find S3 Buckets with Disabled Public Access Blocks
Public access blocks prevent accidental exposure. This query finds buckets with these protections disabled:
How to Find All Publicly Accessible S3 Buckets in Your AWS Account
Use this single query to detect all publicly accessible S3 buckets:
Beyond Public Access: Other Key S3 Security Queries
Buckets Without Encryption Enabled
Ensuring that your S3 buckets have encryption enabled is critical for protecting sensitive data at rest. Without encryption, data stored in your buckets is more vulnerable to unauthorized access. Use the following query to identify any S3 buckets that lack encryption configurations:
List Buckets with No Object Lock Configurations
Object Lock prevents deletion or modification of objects, which is critical for compliance and data retention. This query checks for buckets without this feature enabled.
List Buckets with Expired or No Lifecycle Rules
Lifecycle rules are essential for cost optimization by archiving or deleting old objects. This query finds buckets without lifecycle rules or with expired configurations.
Wrap Up
In this blog post, you learned how to identify publicly accessible S3 buckets in your AWS account using CloudQuery. You discovered how to sync your AWS data into CloudQuery, run targeted queries to uncover potential security risks and consolidate everything into a comprehensive solution. With this data, you can take proactive steps to protect sensitive data and strengthen your cloud security posture.
CloudQuery isn’t just about securing S3 buckets. It’s the most customizable cloud governance solution that allows you to pull cloud data from any cloud provider. From smarter audits to better asset inventories, CloudQuery makes it easy for your team to take control of your cloud environments. Prefer to run it yourself? Follow the AWS to PostgreSQL quickstart to sync your AWS data into a local database and start querying immediately. Contact us to start using CloudQuery today.
Have questions or need help? Join our growing CloudQuery Developer Community, where you can connect with fellow developers, share insights, and access a wealth of knowledge. Whether you’re exploring new use cases or solving tricky challenges, the community is here to support you.
Finally, let us know how your team is tackling cloud security! Share your thoughts and use cases with us on LinkedIn, X, or in our Community Forum.
FAQs
Why is it important to check for publicly accessible S3 buckets?
Publicly accessible S3 buckets pose a significant security risk, as they can expose sensitive data to unauthorized users. Identifying and securing these buckets helps prevent data breaches, compliance violations, and other costly incidents.
What’s the difference between bucket policies, grants, and public access blocks?
- Bucket Policies: Define permissions at the bucket level, specifying who can access the bucket and what actions they can take.
- Grants: Set permissions for specific users or groups, often at the object level.
- Public Access Blocks: Provide a high-level control to restrict or block public access to buckets, overriding other permissions.
How can I ensure all my S3 buckets are encrypted?
Run a query to identify buckets without encryption configurations, like the one in this blog post. Then, encryption for those buckets can be enabled using AWS Management Console, AWS CLI, or Infrastructure-as-Code tools.
What should I do if I find a publicly accessible S3 bucket?
- Review the bucket’s permissions to understand why it’s accessible.
- Update bucket policies to restrict access.
- Enable public access blocks to enforce restrictions at a higher level.
- Notify your team and monitor logs for potential unauthorized access.
Try CloudQuery yourself
Self-hosted, open source, and free to start. Or schedule a demo to see the managed version.

