Skip to main content

More Info:

S3 buckets should use DNS-compliant bucket names in order to adhere to AWS best practices and to benefit from the new S3 features such as S3 Transfer Acceleration, to benefit from operational improvements and to receive support for virtual-host style access to buckets.

Risk Level

Low

Address

Operational Maturity, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • Digital Operational Resilience Act (EU)
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Sure, here are the step-by-step instructions to remediate the misconfiguration in AWS:
  1. Log in to your AWS Management Console.
  2. Navigate to the S3 service.
  3. Select the bucket that is non-compliant with DNS naming conventions.
  4. Click on the “Properties” tab.
  5. Scroll down to the “Static Website Hosting” section.
  6. In the “Static website hosting” section, click on the “Edit” button.
  7. In the “Edit static website hosting” dialog box, select the “Use this bucket to host a website” checkbox.
  8. In the “Index document” field, enter a valid index document name (e.g. index.html).
  9. In the “Error document” field, enter a valid error document name (e.g. error.html).
  10. Click on the “Save changes” button.
Once you have completed the above steps, your S3 bucket will be compliant with DNS naming conventions. It is important to note that you should choose a bucket name that is unique, easy to remember and relevant to your organization.

To remediate the S3 bucket name non-compliance issue, you need to follow the below steps using AWS CLI:
  1. Open your terminal or command prompt and install the AWS CLI (if not already installed) by following the instructions provided in the AWS documentation.
  2. After installing AWS CLI, open your terminal or command prompt and enter the following command:
Note: Replace BUCKET_NAME with the name of your S3 bucket.
  1. Once the above command is executed successfully, enter the following command to rename the non-compliant bucket name:
Note: Replace BUCKET_NAME with the name of your non-compliant S3 bucket and NEW_BUCKET_NAME with the new DNS-compliant name you want to give to your S3 bucket.
  1. After executing the above command successfully, enter the following command to delete the non-compliant bucket:
Note: Replace BUCKET_NAME with the name of your non-compliant S3 bucket.
  1. Finally, verify that the new bucket name is DNS-compliant by entering the following command:
If the above command returns no error, it means that your S3 bucket name is now DNS-compliant.
To remediate this misconfiguration in AWS using Python, you can follow these steps:
  1. Install the AWS SDK for Python (boto3) using pip:
  1. Create an AWS S3 client object:
  1. List all the S3 buckets in your AWS account:
  1. Check if the bucket names are DNS-compliant:
  1. If a bucket name is not DNS-compliant, rename the bucket:
Note: Make sure to replace “new-dns-compliant-bucket-name” with a DNS-compliant bucket name of your choice. Also, be aware that renaming a bucket can have implications for any applications or services that rely on the original bucket name.
You cannot rename an existing S3 bucket in Terraform; bucket names are immutable. To align with the verified CLI remediation, you must:
  1. Add the new aws_s3_bucket (and any related config resources) with a DNS‑compliant name, and update all Terraform references, IAM policies, and application configuration to use NEW_DNS_COMPLIANT_BUCKET_NAME.
  2. Migrate objects between buckets out‑of‑band (e.g., using aws s3 sync s3://OLD_BUCKET_NAME s3://NEW_DNS_COMPLIANT_BUCKET_NAME as in the CLI fix). Terraform does not provide an equivalent data-copy resource.
  3. Remove the old bucket resource (aws_s3_bucket.old and related resources) from Terraform so that the next terraform apply issues DeleteBucket/DeleteObject* API calls and destroys the old bucket. With force_destroy = true, this is DESTRUCTIVE and IRREVERSIBLE.
This change forces replacement of the bucket: the old bucket is destroyed and a completely new bucket is created with a compliant name.Verification:
After you introduce the new bucket resource and remove the old one, terraform plan should show:
  • + creation of aws_s3_bucket.new_dns_compliant (and its related config resources), and
  • - destruction of the old aws_s3_bucket and its related resources.

Additional Reading: