How to turn on S3 Block Public Access for an AWS account
This guide shows how to find S3 buckets that could be public, switch on all four Block Public Access settings for the whole account and confirm they are in force. It is written for AWS administrators who own S3 in a single account or in an AWS Organization.
Before you start
S3 Block Public Access overrides bucket policies and ACLs that would otherwise let anyone on the internet read your data. It has four settings: BlockPublicAcls, IgnorePublicAcls, BlockPublicPolicy and RestrictPublicBuckets. AWS recommends turning on all four for the account, and they apply to every Region.
- Permissions to look:
s3:ListAllMyBuckets,s3:GetAccountPublicAccessBlock,s3:GetBucketPublicAccessBlock,s3:GetBucketPolicyStatusands3:GetBucketWebsite. - Permission to change:
s3:PutAccountPublicAccessBlock. Your organisation may restrict it with a service control policy. - Tools: the AWS CLI configured for the account, and the Amazon S3 console.
- Organization policy: if your account is managed by an organization-level Block Public Access policy, you cannot change the account settings. Organization policies apply all four settings together and override the account. In that case ask the organization administrator.
- Know the risk: AWS says to verify that your applications work without public access first. A static website hosted directly from S3 is the classic example that needs public access.
Step by step
Steps 1 to 3 only read information. Steps 4 and 5 change your account and are marked CHANGE.
- Read the current account setting (read-only).
If the account has no configuration yet, the call returns aACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) aws s3control get-public-access-block --account-id "$ACCOUNT_ID"NoSuchPublicAccessBlockConfigurationerror. Otherwise it lists the four settings. If the account is under an organization policy, it returns the enforced policy. - List buckets that are public today (read-only). Run this per bucket; the policy status call answers whether the bucket policy makes it public:
A bucket without a bucket policy returns afor b in $(aws s3api list-buckets --query "Buckets[].Name" --output text); do echo "== $b" aws s3api get-bucket-policy-status --bucket "$b" --query "PolicyStatus.IsPublic" --output text 2>&1 aws s3api get-public-access-block --bucket "$b" 2>&1 doneNoSuchBucketPolicyerror, which is expected. This only covers bucket policies. To also catch public ACLs, use IAM Access Analyzer for S3, which lists buckets whose ACLs, bucket policies or access point policies grant public or cross-account access. - Find buckets that need public access on purpose (read-only). For every bucket flagged above, ask its owner why. To spot buckets that host a website:
Aaws s3api get-bucket-website --bucket example-bucket-nameNoSuchWebsiteConfigurationerror means the bucket is not hosting a website. Decide for each legitimate public bucket whether it can move behind another delivery method, or whether it will keep its own bucket-level settings. - CHANGE: turn on all four settings for the account.
Console: Amazon S3 > Account and organization settings > Block Public Access settings for this account > Edit, select all four, choose Save changes and type confirm. The setting reaches all Regions, but AWS says it may not take effect everywhere at the same moment. It does not edit existing policies or ACLs. It only overrides them while the setting stays on. To undo, runaws s3control put-public-access-block --account-id "$ACCOUNT_ID" \ --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueaws s3control delete-public-access-block --account-id "$ACCOUNT_ID", but remember that existing public policies and ACLs then become effective again. - CHANGE (optional): also turn them on per bucket. AWS recommends all four settings on each bucket too, so a bucket stays protected if the account setting is ever removed:
For many accounts, AWS Organizations offers an S3 policy that applies the setting centrally. Remember it is all four settings or none, and it overrides account-level changes.aws s3api put-public-access-block --bucket example-bucket-name \ --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
Check it worked
These commands only read.
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
aws s3control get-public-access-block --account-id "$ACCOUNT_ID"
aws s3api get-public-access-block --bucket example-bucket-name
The first command should show BlockPublicAcls, IgnorePublicAcls, BlockPublicPolicy and RestrictPublicBuckets all as true. In the console, the account page should show all four as On. Remember that the bucket policy status keeps describing the policy itself, so a bucket can still report a public policy while the account setting blocks it. Test the applications that use your buckets too, because a rejected request is the sign that something relied on public access.
Common mistakes
- Turning on
RestrictPublicBucketswithout checking cross-account access. If one statement in a bucket policy is public, the whole policy counts as public and access from other accounts stops, even for statements that name a specific account. - Assuming Block Public Access cleans up. It does not edit existing policies or ACLs, so removing the setting later makes them effective again.
- Breaking a static website hosted directly from a bucket.
- Overlooking policies that look narrow but count as public. AWS treats a condition on a very broad IP range as public, and a wildcard in a condition value does not make a policy non-public.
- Forgetting that the account setting is silently locked when an organization policy applies, and that the put and delete calls return Access Denied.
- Treating Block Public Access as the only control. AWS says to also review identity-based policies and resource policies such as KMS key policies for public grants.
- Configuring only buckets you know about and never the account, so new buckets are unprotected.
How ConfigCobra helps
ConfigCobra is read-only: it never changes your AWS. It reads your accounts through an assume-role connection, and its AWS coverage includes CIS Amazon Web Services Foundations v7.0.0 (70 controls), 306 controls across the four AWS benchmarks. The related checks below cover the S3 Block Public Access setting and neighbouring S3 and access settings.
The AWS inventory lists resources across the accounts in scope with their security properties. For a failing control, remediation impact analysis shows the affected resources and identities before you apply a fix, and each finding can come with copy-paste remediation steps. Scheduled scans with drift detection send an email when a control regresses.
Go further
- All guidesAdmin how-tos for Microsoft 365, Azure, Google Cloud and AWS
- Check libraryEvery CIS check, explained
- RemediationSee what a fix changes in your tenant before you apply it, then use the generated script
- Inventory & InsightsEvery user, app, device and resource in one inventory, with built-in risk views
See where your AWS stands
A read-only assessment against the CIS benchmarks, prioritised so you know what to fix first.