π 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
- Located in: π AWS CloudFront
Flagsβ
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
Our Metadataβ
- Policy Type:
COMPLIANCE_POLICY
- Policy Category:
SECURITY
Similar Policiesβ
- AWS Security Hub
- [[CloudFront.9] CloudFront distributions should encrypt traffic to custom origins]([CloudFront.9] CloudFront distributions should encrypt traffic to custom origins (https://docs.aws.amazon.com/securityhub/latest/userguide/cloudfront-controls.html#cloudfront-9)]
- Internal
dec-x-3181f359
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-3181f359 | 1 |
Logicβ
- π§ prod.logic.yaml π’
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
INCOMPLIANT
if 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 Policy
field is set to http-only- The Origin's
Custom Origin Config Protocol Policy
field is set to match-viewer , and at least one associated AWS CloudFront Cache Behavior has theViewer Protocol Policy
field set to allow-all.If a Web Distribution has no Origins in the CMDB or a custom Origin's
Config Protocol Policy
is 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 theOrigins
array) and set theOriginProtocolPolicy
key inCustomOriginConfig
tohttps-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-Cache
header toError from cloudfront
.