Description
A cache behavior with ViewerProtocolPolicy set to allow-all serves content over HTTP as well as HTTPS.
Potential impact
Credentials and request data sent over HTTP can be read or changed in transit.
Remediation
Use https-only to reject HTTP or redirect-to-https to redirect supported requests. Send credentials over HTTPS from the start because the first HTTP request is unencrypted.
Examples
Only DefaultCacheBehavior changes here. Check HTTP handling on paths covered by additional CacheBehaviors too. Configure HTTPS to a custom origin separately.
Before
yaml
Resources:
WebDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
ViewerProtocolPolicy: allow-all
TargetOriginId: myOrigin
After
yaml
Resources:
WebDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
ViewerProtocolPolicy: https-only
TargetOriginId: myOrigin