there is a number of things to look for when you want to understand if a bucket is public or not and why.
# get account level settings
aws s3control get-public-access-block --account-id <your account id>
# get bucket level settings
aws s3api get-public-access-block --bucket <your bucket name>
- [skip if
RestrictPublicBuckets was true] you need to figure out policy status. If policy is public then it is probably the reason you see bucket marked as public.
aws s3api get-bucket-policy-status --bucket <your bucket name>
- [skip if
IgnorePublicAcls was true] check for public bucket ACL (read or write with grantee set to everyone or authenticated users). Note that if IgnorePublicAcls is true you won't see public ACL so if you decide to disable public access block for some reason you might want to check if ACL is public or not.
aws s3api get-bucket-acl --bucket <your bucket name>
Now you should be able to figure out what makes bucket public if you see it marked as public in console. However until you block public ACL using bucket or account public access block you still might have individual objects in your bucket publicly accessible as they could be shared using object level ACL and it can be challenging checking every single object in your bucket.
Another thing which could be hard to check is access points, you can make bucket public through one of attached access points policy, so even if your bucket policy is public you might want to check whether or not your bucket has attached access points and check policy status for each of them
# list access points attached to the bucket, note that you need to specify bucket region
aws s3control list-access-points --bucket <your bucket name> --account-id <your account id> --region <your bucket region>
# retrieve access point policy status
aws s3control get-access-point-policy-status --region <your bucket region> --account-id <your account id> --name <access point name>
The best way to ensure security of your bucket is to enable public access block settings for both policy and ACL.