Connection between CloudFront origin not encrypted
This product is not supported for your selected
Datadog site. (
).
Id: a5366a50-932f-4085-896b-41402714a388
Cloud Provider: AWS
Platform: CloudFormation
Severity: Medium
Category: Encryption
Learn More
Description
CloudFront distributions must require or redirect viewers to HTTPS to prevent plaintext HTTP traffic that can expose sensitive data in transit and enable interception or downgrade attacks. In AWS::CloudFront::Distribution resources, set DistributionConfig.DefaultCacheBehavior.ViewerProtocolPolicy and each DistributionConfig.CacheBehaviors[].ViewerProtocolPolicy to https-only or redirect-to-https. Resources missing these properties or configured with allow-all (which permits HTTP) will be flagged as insecure.
Secure configuration example:
MyDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
DefaultCacheBehavior:
TargetOriginId: myOrigin
ViewerProtocolPolicy: redirect-to-https
CacheBehaviors:
- PathPattern: '/images/*'
TargetOriginId: myOrigin
ViewerProtocolPolicy: https-only
Compliant Code Examples
#this code is a correct code for which the query should not find any result
AWSTemplateFormatVersion: "2010-09-09"
Resources:
cloudfrontdistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
CacheBehaviors:
- LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
DefaultCacheBehavior:
LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
IPV6Enabled: true
Origins:
- CustomOriginConfig:
OriginKeepaliveTimeout: 60
OriginReadTimeout: 30
Tags:
- Key: name
Value: example
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"cloudfrontdistribution": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
},
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginKeepaliveTimeout": 60,
"OriginReadTimeout": 30
}
}
],
"CacheBehaviors": [
{
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
}
]
},
"Tags": [
{
"Key": "name",
"Value": "example"
}
]
}
}
}
}
Non-Compliant Code Examples
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"cloudfrontdistribution_1": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"CacheBehaviors": [
{
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
}
],
"DefaultCacheBehavior": {
"ViewerProtocolPolicy": "allow-all",
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
},
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginKeepaliveTimeout": 60,
"OriginReadTimeout": 30
}
}
]
},
"Tags": [
{
"Key": "name",
"Value": "example"
}
]
}
},
"cloudfrontdistribution_2": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"Tags": [
{
"Key": "name",
"Value": "example"
}
],
"CacheBehaviors": {
"ViewerProtocolPolicy": "allow-all",
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
},
"DefaultCacheBehavior": {
"LambdaFunctionAssociations": [
{
"EventType": "viewer-request",
"LambdaFunctionARN": "examp"
}
]
},
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginKeepaliveTimeout": 60,
"OriginReadTimeout": 30
}
}
]
}
}
}
}
}
#this is a problematic code where the query should report a result(s)
AWSTemplateFormatVersion: "2010-09-09"
Resources:
cloudfrontdistribution_1:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
CacheBehaviors:
- LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
DefaultCacheBehavior:
ViewerProtocolPolicy: allow-all
LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
IPV6Enabled: true
Origins:
- CustomOriginConfig:
OriginKeepaliveTimeout: 60
OriginReadTimeout: 30
Tags:
- Key: name
Value: example
cloudfrontdistribution_2:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
CacheBehaviors:
ViewerProtocolPolicy: allow-all
LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
DefaultCacheBehavior:
LambdaFunctionAssociations:
- EventType: viewer-request
LambdaFunctionARN: examp
IPV6Enabled: true
Origins:
- CustomOriginConfig:
OriginKeepaliveTimeout: 60
OriginReadTimeout: 30
Tags:
- Key: name
Value: example