Infrastructure Security · Topic 1 of 7
CloudFront Edge Security
Secure content delivery with CloudFront origin access control, signed URLs and cookies, TLS settings, geo restriction and locked down ALB origins.
- 5 min
- Includes a diagram
- Use origin access control for S3 origins, and a bucket policy that trusts
cloudfront.amazonaws.comwithAWS:SourceArn. - OAC replaces OAI, and SSE-KMS objects need the key policy to allow the CloudFront service.
- To lock down an ALB origin, use the CloudFront managed prefix list, a secret header check and HTTPS to the origin.
What it is
Amazon CloudFront is a content delivery network (CDN) that serves content from edge locations close to users. It is also an edge security layer: it terminates TLS, absorbs traffic spikes, hides the origin and is the place to attach AWS WAF (Web Application Firewall).
The security design question is always the same: how do you make sure users reach your content only through CloudFront, and only the right users get private content?
How it works

Protecting an S3 origin
Use origin access control (OAC). CloudFront signs its requests to S3 using SigV4 (the AWS request signing method), and the bucket policy trusts only the CloudFront service principal for your distribution. Keep Block Public Access on.
{
"Version": "2012-10-17",
"Statement": {
"Sid": "AllowCloudFrontServicePrincipalReadOnly",
"Effect": "Allow",
"Principal": { "Service": "cloudfront.amazonaws.com" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
"Condition": { "StringEquals": { "AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/EDFDVBD6EXAMPLE" } }
}
}
OAC replaces the older origin access identity (OAI). OAC supports SSE-KMS encrypted objects, and the KMS key policy must then allow the CloudFront service principal to use the key.
Protecting an ALB or custom origin
A custom origin is reachable on the internet unless you lock it down. Combine these controls.
- Allow the AWS managed prefix list for CloudFront origin facing addresses in the load balancer security group.
- Have CloudFront add a secret custom header, and make the ALB or WAF reject requests that lack it.
- Require HTTPS between CloudFront and the origin, with a valid certificate on the origin.
- Optionally use VPC origins, which let CloudFront reach an origin in a private subnet.
Restricting who can view content
| Mechanism | Use it to |
|---|---|
| Signed URL | Give access to one file, or support clients that cannot use cookies |
| Signed cookie | Give access to many files without changing every URL, such as a whole video library |
| Geo restriction | Allow or block countries, using a built in list |
| WAF rules | Filter by IP, rate, headers and managed threat lists |
| Lambda@Edge or CloudFront Functions | Run custom authentication or header logic at the edge |
Signed URLs and cookies use a trusted key group, which holds public keys that you upload. Prefer key groups to the older method that relies on the root user's CloudFront key pair. The distribution must have the behaviour set to require signed requests.
Signed URL expiry and source IP limits can be set per URL in a custom policy. A canned policy is simpler and sets only an expiry.
TLS settings
- Viewer protocol policy. Choose redirect HTTP to HTTPS or HTTPS only.
- Security policy. Set a minimum TLS version for viewers. Use a recent policy and avoid old protocol versions.
- Certificate. Use a certificate from AWS Certificate Manager (ACM). For CloudFront the certificate must be requested in us-east-1.
- Origin protocol policy. Use HTTPS only to protect the CloudFront to origin leg.
- Alternate domain names need a matching certificate, and SNI (Server Name Indication) is the usual and cheaper choice for serving them.
Field level encryption
Field level encryption encrypts chosen form fields at the edge with a public key, so that only the application holding the private key can decrypt them. Intermediate components, such as the web servers, see only ciphertext. Choose it to protect sensitive fields like card numbers from everything between the edge and a specific back end service.
Response headers and logging
A response headers policy adds security headers such as HSTS (HTTP Strict Transport Security), content security policy and frame options. Enable standard logging or real time logs to find abuse, and send WAF logs to a central place.
CloudFront and DDoS
Because CloudFront absorbs traffic at the edge and only forwards cache misses, it is a core part of DDoS resilient design. AWS Shield Standard protects CloudFront distributions automatically. Attach WAF rate based rules for layer 7 floods, and use Shield Advanced where you need extra protection and response support.
What to remember for the exam
- Use origin access control for S3 origins, and a bucket policy that trusts
cloudfront.amazonaws.comwithAWS:SourceArn. - OAC replaces OAI, and SSE-KMS objects need the key policy to allow the CloudFront service.
- To lock down an ALB origin, use the CloudFront managed prefix list, a secret header check and HTTPS to the origin.
- Signed URLs suit single files. Signed cookies suit many files. Use trusted key groups.
- ACM certificates for CloudFront must be in us-east-1.
- Geo restriction is a simple country allow or block list. WAF covers finer rules.
- Field level encryption protects specific form fields all the way to a back end that holds the private key.
- AWS WAF attached to CloudFront is created with the CLOUDFRONT scope in us-east-1.
"Users must not bypass CloudFront to reach the bucket directly" means OAC plus a bucket policy that allows only the distribution, not public read.
Common mistakes
Making the bucket public. Public read defeats signed URLs and lets anyone skip the CDN.
Using HTTP to the origin. The viewer leg is encrypted, but the origin leg is clear text across the network.
Putting the certificate in the wrong Region. A CloudFront certificate in eu-west-1 cannot be selected.
Forgetting to restrict the ALB. If the load balancer accepts traffic from anywhere, attackers hit it directly and bypass WAF.
A signed URL stays valid until it expires, even if you later want to cut off that user, so keep expiry short for sensitive content.
Check yourself
How do you ensure only CloudFront can read from an S3 bucket?
Use origin access control and a bucket policy that allows only the CloudFront service principal for your distribution ARN.
When do you use signed cookies instead of signed URLs?
When users need access to many files, or you do not want to change each URL.
Where must the ACM certificate for a CloudFront distribution be requested?
In the us-east-1 Region.
Topic 1 of 7 in Infrastructure Security
Test yourself on Infrastructure Security
The full AWS SCS-C03 question bank has 858 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.