More Info:
AWS S3 buckets should not be publicly accessible for WRITE actions via S3 access control lists (ACLs), in order to protect your S3 data from unauthorized users.Risk Level
CriticalAddress
SecurityCompliance Standards
- APRA CPS 234 (Australia)
- AWS Startup Security Baseline
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- HIPAA
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- Reserve Bank of India (RBI) Cyber Security Framework
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions to remediate the misconfiguration in AWS:
- Log in to the AWS Management Console.
- Navigate to the S3 service.
- Click on the name of the bucket that you want to remediate.
- Click on the “Permissions” tab.
- Under the “Block public access (bucket settings)” section, click on “Edit”.
- Uncheck the box next to “Block all public access”.
- Check the box next to “Block public access to buckets and objects granted through new public bucket policies”.
- Check the box next to “Block public and cross-account access to buckets and objects through any public bucket policies”.
- Click on “Save changes”.
Using CLI
Using CLI
The following steps can be taken to remediate the S3 bucket public write issue in AWS using AWS CLI:Replace Replace Note: It is important to regularly audit the S3 buckets in your AWS account to ensure that they are not publicly accessible and have the appropriate access controls in place.
- Open the AWS CLI on your local machine.
- Run the following command to list all the S3 buckets in your AWS account:
- Identify the S3 bucket that has public write access.
- Run the following command to remove public write access from the S3 bucket:
BUCKET-NAME with the name of the S3 bucket that has public write access.- Run the following command to verify that the public write access has been removed from the S3 bucket:
BUCKET-NAME with the name of the S3 bucket that has public write access.- If the above command returns the following output, then public write access has been successfully removed from the S3 bucket:
Using Python
Using Python
To remediate the misconfiguration “S3 Buckets Should Not Allow Public Writes” in AWS, you can use the following steps in Python:The final code to remediate the misconfiguration “S3 Buckets Should Not Allow Public Writes” in AWS using Python will look something like this:
-
Install the AWS SDK for Python (Boto3) using the command
pip install boto3. - Create an S3 client using the following code:
- Get a list of all S3 buckets in your AWS account using the
list_buckets()method:
- For each bucket, check if it allows public write access using the
get_bucket_acl()method:
- If the bucket allows public write access, remove the permission using the
put_bucket_acl()method:
Using Terraform
Using Terraform
s3:PutBucketPublicAccessBlock CLI fix and will block all current and future public access (including reads) for YOUR_BUCKET_NAME.It does not force replacement of the bucket; Terraform will create or update only the
aws_s3_bucket_public_access_block resource.Verification: terraform plan should show an aws_s3_bucket_public_access_block resource being created or updated with all four arguments set to true and no aws_s3_bucket.THIS_BUCKET replacement.
