π‘οΈ AWS CloudFront Web Distribution Cache Behaviors allow unencrypted trafficπ’
- Contextual name: π‘οΈ Web Distribution Cache Behaviors allow unencrypted trafficπ’
- ID:
/ce/ca/aws/cloudfront/distribution-unencrypted-cache-behaviors - Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicβ
- π§ prod.logic.yamlπ’
Similar Policiesβ
- AWS Security Hub: [CloudFront.3] CloudFront distributions should require encryption in transit
- Internal:
dec-x-791dab13
Similar Internal Rulesβ
| Rule | Policies | Flags |
|---|---|---|
| βοΈ dec-x-791dab13 | 1 |
Descriptionβ
Descriptionβ
This policy checks that all cache behaviors for an AWS CloudFront Web Distribution are configured to enforce encrypted communications by prohibiting the
Viewer Protocol Policyfrom being set to allow-all, which permits unencrypted HTTP traffic.You can enforce HTTPS-only communications by configuring the
Viewer Protocol Policyto one of the following:
- Redirect HTTP to HTTPS CloudFront listens on both HTTP and HTTPS. Incoming GET and HEAD requests over HTTP receive an
HTTPΒ 301(Moved Permanently) response code with the corresponding HTTPS URL. The viewer then resubmits the request to CloudFront using the HTTPS URL.- HTTPS only CloudFront accepts only HTTPS requests. If a client sends an HTTP request, CloudFront responds with
HTTPΒ 403(Forbidden) and does not forward the request to the origin.Rationaleβ
Enforcing HTTPS for all communication between viewers and CloudFront protects data in transit from eavesdropping and man-in-theβmiddle attacks. Allowing unencrypted HTTP traffic exposes sensitive payloads (e.g., authentication tokens, user credentials, and personal information) to interception and replay.
... see more
Remediationβ
Remediationβ
From Command Lineβ
Retrieve the current distribution configuration and capture its
ETag:aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'DistributionConfig' \
> {{distribution-config}}.json
ETAG=$(aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'ETag' \
--output text)In the downloaded
{{distribution-config}}.json, modify the cache behaviors (DefaultCacheBehaviorand an item in theCacheBehaviors.Itemsarray) and set theViewerProtocolPolicykey to eitherredirect-to-httpsorhttps-only.Apply the updated configuration to your distribution using the saved ETag:
aws cloudfront update-distribution \
--id {{distribution-id}} \
--if-match $ETAG \
--distribution-config file://{{distribution-config}}.json