π‘οΈ AWS CloudFront Web Distribution does not encrypt traffic to Custom Originsπ’
- Contextual name: π‘οΈ Web Distribution does not encrypt traffic to Custom Originsπ’
- ID:
/ce/ca/aws/cloudfront/distribution-traffic-encryption-to-custom-origins - 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.9] CloudFront distributions should encrypt traffic to custom origins
- Internal:
dec-x-3181f359
Similar Internal Rulesβ
| Rule | Policies | Flags |
|---|---|---|
| βοΈ dec-x-3181f359 | 1 |
Descriptionβ
Descriptionβ
Ensure that AWS CloudFront Distributions communicating with custom origins enforce endβtoβend encryption by using HTTPS.
Note: Distributions using Amazon S3 buckets as custom origins for static website hosting are excluded, as those endpoints do not support HTTPS.
Rationaleβ
Requiring HTTPS between CloudFront edge locations and your origin ensures that data in transit remains confidential and tamperβproof, mitigating the risk of manβinβtheβmiddle attacks.
Auditβ
This policy flags an AWS CloudFront Web Distribution as
INCOMPLIANTif at least one custom AWS CloudFront Origin associated with the distribution (excluding S3 static websites as origin) meets one of the following conditions:
- The Origin's
Custom Origin Config Protocol Policyfield is set to http-only- The Origin's
Custom Origin Config Protocol Policyfield is set to match-viewer , and at least one associated AWS CloudFront Cache Behavior has theViewer Protocol Policyfield set to allow-all.If a Web Distribution has no Origins in the CMDB or a custom Origin's
Config Protocol Policyis set to match-viewer but there are no related Cache Behaviors in the CMDB, the Distribution is marked asUNDETERMINED.
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 origins (items in theOriginsarray) and set theOriginProtocolPolicykey inCustomOriginConfigtohttps-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}}.jsonInstall an SSL/TLS certificate on your custom origin.
Importantβ
If the origin server presents an expired, invalid, or self-signed certificate, supplies the certificate chain in an incorrect order, or omits any intermediate certificates, CloudFront will terminate the TCP connection immediately, return HTTP status code 502 (Bad Gateway) to the viewer, set the
X-Cacheheader toError from cloudfront.