Skip to main content

Triage and Remediation

Remediation

Using Console

Sure, I can help you with that. Here are the steps to remediate the HTTPS misconfiguration on CloudFront Distributions in AWS using the AWS console:
  1. Log in to the AWS Management Console.
  2. Navigate to the CloudFront service.
  3. Click on the ID of the distribution you want to remediate.
  4. Click on the “Behaviors” tab.
  5. Select the behavior that requires HTTPS.
  6. Click on the “Edit” button.
  7. In the “Viewer Protocol Policy” section, select “Redirect HTTP to HTTPS”.
  8. Click on the “Yes, Edit” button to save the changes.
Once the above steps are completed, HTTPS will be enabled on the CloudFront distribution. If you have multiple distributions, you will need to repeat these steps for each of them.

To remediate this misconfiguration for AWS using AWS CLI, you can follow the below steps:
  1. Open the AWS CLI on your local machine or on an EC2 instance.
  2. Run the following command to enable HTTPS on your CloudFront distributions:
Note: Replace <distribution-id> with the ID of your CloudFront distribution.
  1. Wait for the distribution to update. This might take a few minutes.
  2. Run the following command to verify that HTTPS is enabled:
Note: This command should return “true” to indicate that HTTPS is enabled.
  1. Repeat the above steps for all of your CloudFront distributions.
By following these steps, you will have successfully enabled HTTPS on your CloudFront distributions.
To remediate the HTTPS should be enabled on CloudFront Distributions misconfiguration in AWS using Python, follow these steps:
  1. Import the required modules:
  1. Create a boto3 client for CloudFront:
  1. Get a list of all CloudFront distributions:
  1. Loop through the distributions and check if HTTPS is enabled:
  1. If HTTPS is not enabled, update the distribution to enable HTTPS:
This will enable HTTPS on the CloudFront distribution.
This change updates viewer_protocol_policy from allow-all (HTTP and HTTPS) to redirect-to-https in default_cache_behavior and every ordered_cache_behavior, matching the CLI remediation’s requirement to enforce HTTPS. The distribution is updated in place (no resource replacement), but CloudFront changes can take several minutes to propagate.To verify, terraform plan should show viewer_protocol_policy changing from "allow-all" (or "https-only", if that was set) to "redirect-to-https" for the affected cache behaviors, with the resource marked for in-place update (~), not +/-.