Make sure S3 Buckets have 'Block public access (bucket settings)' configured to prevent unauthorized access.
Rule | Ensure that S3 Buckets are configured with 'Block public access (bucket settings)' |
Framework | cis_v130 |
Severity | ✔ High |
Ensure S3 Buckets are Configured with 'Block Public Access (bucket settings)' for CIS v1.3.0
Description
The Center for Internet Security (CIS) AWS Foundations Benchmark v1.3.0 recommends that your Amazon S3 buckets should have the 'Block public access' setting enabled to prevent any inadvertent public exposure of data. The 'Block public access' settings provide layers of protection to ensure that your S3 buckets and objects have the appropriate access controls.
Blocking public access at the bucket level can prevent the following:
Troubleshooting Steps
If it is not properly configured, you will need to enable block public access settings.
Remediation Steps
Using AWS Management Console
Using AWS CLI
To block public access for a specific bucket:
aws s3api put-public-access-block \ --bucket YOUR-BUCKET-NAME \ --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"
Replace
YOUR-BUCKET-NAME
with your bucket name.Using AWS CLI for All Buckets
If you want to apply this setting to all buckets in your account, you may use the following script:
for bucket in $(aws s3api list-buckets --query "Buckets[].Name" --output text) do aws s3api put-public-access-block \ --bucket $bucket \ --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true" done
Make sure to test any scripts in a non-production environment before deploying them to your production environment to avoid any unintended consequences.
By implementing these settings, you enhance the security posture of your S3 buckets, thereby aligning with the CIS AWS Foundations Benchmark v1.3.0 and protecting your data from unauthorized public access.