π 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
- 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.3] CloudFront distributions should require encryption in transit]([CloudFront.3] CloudFront distributions should require encryption in transit (https://docs.aws.amazon.com/securityhub/latest/userguide/cloudfront-controls.html#cloudfront-3)]
- Internal
dec-x-791dab13
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-791dab13 | 1 |
Logicβ
- π§ prod.logic.yaml π’
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 Policy
from being set to allow-all, which permits unencrypted HTTP traffic.You can enforce HTTPS-only communications by configuring the
Viewer Protocol Policy
to 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 (DefaultCacheBehavior
and an item in theCacheBehaviors.Items
array) and set theViewerProtocolPolicy
key to eitherredirect-to-https
orhttps-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