CloudFront Security
- CloudFront Security has multiple features, including
- Support for Encryption at Rest and Transit.
- Prevent users in specific geographic locations from accessing content
- Configure HTTPS connections.
- Use signed URLs or cookies to restrict access for selected users.
- Restrict access to content in S3 buckets using Origin Access Control (OAC), to prevent users from using the direct URL of the file.
- Set up field-level encryption for specific content fields
- Use AWS WAF web ACLs to create a web access control list (web ACL) to restrict access to your content.
- Use geo-restriction, also known as geoblocking, to prevent users in specific geographic locations from accessing content served through a CloudFront distribution.
- Integration with AWS Shield to protect from DDoS attacks.
- Support for Mutual TLS (mTLS) authentication for both viewer and origin connections.
- VPC Origins to deliver content from applications in private subnets without exposing them to the public internet.
Data Protection
- CloudFront supports both Encryption at Rest and in Transit.
- CloudFront provides Encryption in Transit and can be configured
- to require viewers to use HTTPS to request the files so that connections are encrypted when CloudFront communicates with viewers.
- to use HTTPS to get files from the origin, so that connections are encrypted when CloudFront communicates with the origin.
- HTTPS can be enforced using the Viewer Protocol Policy and Origin Protocol Policy.
- CloudFront supports TLS 1.3 for origin connections (launched November 2025), providing stronger encryption algorithms, reduced handshake latency (up to 30% improvement), and better security posture for data transmission between edge locations and origin servers. TLS 1.3 is automatically enabled for all origin types including custom origins, S3, and ALBs.
- CloudFront supports Post-Quantum TLS (launched September 2025) with the TLS1.3_2025 security policy, providing quantum-resistant key exchange to protect against “harvest now, decrypt later” threats.
- CloudFront provides Encryption at Rest
- using SSDs which are encrypted for edge location points of presence (POPs), and encrypted EBS volumes for Regional Edge Caches (RECs).
- Function code and configuration are always stored in an encrypted format on the encrypted SSDs on the edge location POPs, and in other storage locations used by CloudFront.
Mutual TLS (mTLS) Authentication
- Mutual TLS (mTLS) extends standard TLS by requiring bidirectional certificate-based authentication, where both client and server must prove their identity before establishing a secure connection.
- CloudFront supports mTLS in two configurations:
- Viewer mTLS (launched November 2025) – Authenticates end users/clients connecting to CloudFront using client certificates. Requires HTTPS connections.
- Origin mTLS (launched January 2026) – CloudFront authenticates itself to origin servers using client certificates, ensuring only authorized CloudFront distributions can connect to application servers.
- Together, viewer and origin mTLS enable true end-to-end zero-trust authentication from viewers through CloudFront to origin servers.
- Origin mTLS supports per-origin configuration, allowing different client certificates for different origins within the same distribution.
- mTLS Passthrough mode (launched May 2026) allows CloudFront to forward client certificates to the origin without verifying them at CloudFront, enabling custom validation at the origin.
- mTLS is available at no additional cost and can be configured via Console, CLI, SDK, CDK, and CloudFormation.
Restrict Viewer Access
Serving Private Content
- To securely serve private content using CloudFront
- Require the users to access the private content by using special CloudFront signed URLs or signed cookies with the following restrictions
- end date and time, after which the URL is no longer valid
- start date-time, when the URL becomes valid
- IP address or range of addresses to access the URLs
- Require that users access the S3 content only using CloudFront URLs, not S3 URLs. Requiring CloudFront URLs isn’t required, but recommended to prevent users from bypassing the restrictions specified in signed URLs or signed cookies.
- Require the users to access the private content by using special CloudFront signed URLs or signed cookies with the following restrictions
- Signed URLs or Signed Cookies can be used with CloudFront using an HTTP server as an origin. It requires the content to be publicly accessible and care should be taken to not share the direct URL of the content
- Restriction for Origin can be applied by
- For S3, using Origin Access Control (OAC) to grant only CloudFront access to the content and removing any other access permissions. (OAI is legacy; see OAC section below)
- For a Load balancer OR HTTP server, custom headers can be added by CloudFront which can be used at Origin to verify the request has come from CloudFront.
- Custom origins can also be configured to allow traffic from CloudFront IPs only. CloudFront managed prefix list can be used to allow inbound traffic to the origin only from CloudFront’s origin-facing servers, preventing any non-CloudFront traffic from reaching your origin
- For origins in private subnets, VPC Origins can be used to restrict access so that only CloudFront can reach the ALB, NLB, or EC2 instances directly.
- Trusted Key Groups (Recommended)
- AWS recommends using trusted key groups instead of trusted signers (CloudFront key pairs) for creating signed URLs and signed cookies.
- Trusted key groups use public keys that you manage in CloudFront, associated with IAM-managed key pairs.
- Benefits over legacy trusted signers:
- No need for the AWS account root user to manage CloudFront key pairs.
- Can use IAM policies and API to manage keys.
- Can have more key groups per distribution (not limited to 5 trusted signers).
- Supports key rotation without disrupting viewers.
- A key group contains one or more public keys that CloudFront uses to verify signed URLs or signed cookies.
- Trusted Signer (Legacy)
- To create signed URLs or signed cookies, at least one AWS account (trusted signer) is needed that has an active CloudFront key pair
- Once the AWS account is added as a trusted signer to the distribution, CloudFront starts to require that users use signed URLs or signed cookies to access the objects.
- Private key from the trusted signer’s key pair to sign a portion of the URL or the cookie. When someone requests a restricted object, CloudFront compares the signed portion of the URL or cookie with the unsigned portion to verify that the URL or cookie hasn’t been tampered with. CloudFront also validates the URL or cookie is valid for e.g, that the expiration date and time hasn’t passed.
- Each Trusted signer AWS account used to create CloudFront signed URLs or signed cookies must have its own active CloudFront key pair, which should be frequently rotated
- A maximum of 5 trusted signers can be assigned for each cache behavior
- Note: AWS recommends migrating to trusted key groups for better security and management flexibility.
Signed URLs vs Signed Cookies
- CloudFront signed URLs and signed cookies help to secure the content and provide control to decide who can access the content.
- Use signed URLs in the following cases:
- to restrict access to individual files, for e.g., an installation download for the application.
- users using a client, for e.g. a custom HTTP client, that doesn’t support cookies
- Use signed cookies in the following cases:
- provide access to multiple restricted files, e.g., all of the video files in HLS format or all of the files in the subscribers’ area of a website.
- don’t want to change the current URLs.
- Signed URLs take precedence over signed cookies, if both signed URLs and signed cookies are used to control access to the same files and a viewer uses a signed URL to request a file, CloudFront determines whether to return the file to the viewer based only on the signed URL.
Canned Policy vs Custom Policy
- Canned policy or a custom policy is a policy statement, used by the Signed URLs, that helps define the restrictions for e.g. expiration date and time

- CloudFront validates the expiration time at the start of the event.
- If the user is downloading a large object, and the URL expires the download would still continue.
- However, if the user is using range GET requests, or while streaming video skips to another position which might trigger another event, the request would fail.
Origin Access Control (OAC)
✅ OAC is the recommended method for restricting origin access. AWS deprecated Origin Access Identity (OAI) creation in 2024, and as of March 2026, new distributions can only use OAC. Existing OAI configurations continue to work but should be migrated to OAC.

- Origin Access Control (OAC) restricts access so that only designated CloudFront distributions can access your origin.
- OAC uses AWS Signature Version 4 (SigV4) to sign requests to the origin, providing enhanced security over legacy OAI.
- OAC supports multiple origin types:
- Amazon S3 bucket origins – primary use case for restricting S3 access
- AWS Lambda function URL origins (April 2024) – secure Lambda function URLs
- AWS Elemental MediaPackage v2 origins (April 2024) – secure media streaming
- AWS Elemental MediaStore origins – secure media storage
- OAC advantages over legacy OAI:
- Supports all AWS regions including opt-in regions
- Supports SSE-KMS encrypted S3 objects
- Supports HTTP and HTTPS requests using POST method in all regions
- Supports granular policy configurations with IAM resource policies
- Supports S3 Object Ownership set to bucket owner enforced (default for new buckets)
- For S3 origins, OAC works with bucket policies to allow only the CloudFront service principal (
cloudfront.amazonaws.com) access, scoped to the specific distribution ID. - Users accessing S3 objects directly would
- bypass the controls provided by CloudFront signed URLs or signed cookies
- make CloudFront access logs less useful because they’re incomplete.
Migrating from OAI to OAC
- Existing OAI configurations continue to work but should be migrated to OAC.
- Migration steps:
- Create an OAC in the CloudFront console or via API
- Update the S3 bucket policy to allow the CloudFront service principal
- Update the distribution origin to use OAC instead of OAI
- Remove the OAI from the bucket policy after verifying OAC works
- Both OAI and OAC can coexist during migration to avoid downtime.
Legacy: Origin Access Identity (OAI)
⚠️ OAI is legacy. AWS deprecated new OAI creation in 2024 and recommends migrating to Origin Access Control (OAC). As of March 2026, OAI cannot be attached to new distributions.
- Origin Access Identity (OAI) was the original method to prevent users from directly accessing objects from S3.
- OAI is a special CloudFront user that can be created and associated with the distribution.
- S3 bucket/object permissions are configured to only provide access to the OAI.
- OAI limitations (addressed by OAC):
- Does not support SSE-KMS
- Does not support POST method in regions requiring SigV4
- Limited to S3 origins only
- Does not support granular IAM policies
VPC Origins
- CloudFront VPC Origins (launched November 2024) allows delivering content from applications hosted in VPC private subnets, preventing direct public internet access to origins.
- Supported origin types within private subnets:
- Application Load Balancers (ALB)
- Network Load Balancers (NLB)
- EC2 Instances
- Key benefits:
- Origins remain completely private – accessible only through CloudFront
- No need for public IPs, NAT gateways, or complex security group rules
- Eliminates the need for custom header verification or IP allowlisting for origin protection
- Available at no additional cost
- Cross-account support (November 2025) allows CloudFront distributions in one account to access VPC origins in another account.
- WebSocket support (May 2026) enables real-time applications hosted in private subnets to use WebSockets through CloudFront VPC origins.
- VPC Origins is the recommended approach for securing non-S3 custom origins, replacing the legacy pattern of custom headers or IP allowlisting.
Custom Headers
- Custom headers can be added by CloudFront which can be used at Origin to verify the request has come from CloudFront.

- A viewer accesses the website or application and requests one or more files, such as an image file and an HTML file.
- DNS routes the request to the CloudFront edge location that can best serve the request – typically the nearest edge location in terms of latency.
- At the edge location, AWS WAF inspects the incoming request according to configured web ACL rules.
- At the edge location, CloudFront checks its cache for the requested content.
- If the content is in the cache, CloudFront returns it to the user.
- If the content isn’t in the cache, CloudFront adds the custom header,
X-Origin-Verify, with the value of the secret from Secrets Manager, and forwards the request to the origin.
- At the origin ALB, ALB rules or AWS WAF inspects the incoming request header,
X-Origin-Verify, and allows the request if the string value is valid. If the header isn’t valid, AWS WAF blocks the request. - At the configured interval, Secrets Manager automatically rotates the custom header value and updates the origin AWS WAF and CloudFront configurations.
- Note: For stronger origin protection, consider using VPC Origins (for ALB/NLB/EC2) or Origin mTLS instead of shared secret headers, as these provide cryptographic authentication rather than shared secrets.
CloudFront Security Dashboard
- CloudFront Security Dashboard (launched November 2023) provides a unified CDN and security experience within the CloudFront console.
- Key features:
- One-click WAF protection – creates an AWS WAF web ACL, configures rules to protect against common web threats (OWASP Top 10, known threat IPs, scanner detection), and attaches it to the distribution automatically.
- Security metrics – displays allowed/blocked requests, challenge and CAPTCHA requests, top attack types, and traffic ratios over time.
- Geo-restriction management – block countries directly from the dashboard with metrics visibility.
- Built-in pricing calculators – estimate WAF and CloudWatch costs when enabling protections.
- Standard pricing for AWS WAF and Amazon CloudWatch apply when security protections are enabled.
Geo-Restriction – Geoblocking
- Geo restriction can help allow or prevent users in selected countries from accessing the content.
- CloudFront distribution can be configured either to allow users in
- an allowlist of specified countries to access the content or to
- deny users in a denylist of specified countries to access the content
- Geo restriction can be used to restrict access to all of the files that are
associated with distribution and to restrict access at the country level. - CloudFront responds to a request from a viewer in a restricted country with an HTTP status code 403 (Forbidden).
- Use a third-party geolocation service, if access is to be restricted to a subset of the files that are associated with a distribution or to restrict access at a finer granularity than the country level.
- CloudFront geographic restrictions are provided for free, but metrics for blocked country requests are only visible through AWS WAF geographic restrictions in the security dashboard.
- Geo-restriction is also critical for reducing attack surface by limiting traffic to expected geographic regions.
Field Level Encryption Config
- CloudFront can enforce secure end-to-end connections to origin servers by using HTTPS.
- Field-level encryption adds an additional layer of security that helps protect specific data throughout system processing so that only certain applications can see it.
- Field-level encryption can be used to securely upload user-submitted sensitive information. The sensitive information provided by the clients is encrypted at the edge closer to the user and remains encrypted throughout the entire application stack, ensuring that only applications that need the data – and have the credentials to decrypt it – are able to do so.
- Up to 10 data fields can be encrypted in a request.
- Uses asymmetric encryption (public key at edge, private key at application) for protection.
AWS Certification Exam Practice Questions
- Questions are collected from Internet and the answers are marked as per my knowledge and understanding (which might differ with yours).
- AWS services are updated everyday and both the answers and questions might be outdated soon, so research accordingly.
- AWS exam questions are not updated to keep up the pace with AWS updates, so even if the underlying feature has changed the question might not be updated
- Open to further feedback, discussion and correction.
- You are building a system to distribute confidential training videos to employees. Using CloudFront, what method could be used to serve content that is stored in S3, but not publically accessible from S3 directly?
- Create an Origin Access Control (OAC) for CloudFront and grant access to the objects in your S3 bucket to that OAC. (Note: OAI is legacy; OAC is the current recommended approach)
- Add the CloudFront account security group “amazon-cf/amazon-cf-sg” to the appropriate S3 bucket policy.
- Create an Identity and Access Management (IAM) User for CloudFront and grant access to the objects in your S3 bucket to that IAM User.
- Create a S3 bucket policy that lists the CloudFront distribution ID as the Principal and the target bucket as the Amazon Resource Name (ARN).
- A media production company wants to deliver high-definition raw video for preproduction and dubbing to customer all around the world. They would like to use Amazon CloudFront for their scenario, and they require the ability to limit downloads per customer and video file to a configurable number. A CloudFront download distribution with TTL=0 was already setup to make sure all client HTTP requests hit an authentication backend on Amazon Elastic Compute Cloud (EC2)/Amazon RDS first, which is responsible for restricting the number of downloads. Content is stored in S3 and configured to be accessible only via CloudFront. What else needs to be done to achieve an architecture that meets the requirements? Choose 2 answers
- Enable URL parameter forwarding, let the authentication backend count the number of downloads per customer in RDS, and return the content S3 URL unless the download limit is reached.
- Enable CloudFront logging into an S3 bucket, leverage EMR to analyze CloudFront logs to determine the number of downloads per customer, and return the content S3 URL unless the download limit is reached. (CloudFront logs are logged periodically and EMR not being real time, hence not suitable)
- Enable URL parameter forwarding, let the authentication backend count the number of downloads per customer in RDS, and invalidate the CloudFront distribution as soon as the download limit is reached. (Distribution are not invalidated but Objects)
- Enable CloudFront logging into the S3 bucket, let the authentication backend determine the number of downloads per customer by parsing those logs, and return the content S3 URL unless the download limit is reached. (CloudFront logs are logged periodically and EMR not being real time, hence not suitable)
- Configure a list of trusted signers, let the authentication backend count the number of download requests per customer in RDS, and return a dynamically signed URL unless the download limit is reached.
- To enable end-to-end HTTPS connections from the user’s browser to the origin via CloudFront, which of the following options are valid? Choose 2 answers
- Use self-signed certificate in the origin and CloudFront default certificate in CloudFront. (Origin cannot be self-signed)
- Use the CloudFront default certificate in both origin and CloudFront (CloudFront cert cannot be applied to origin)
- Use a 3rd-party CA certificate in the origin and CloudFront default certificate in CloudFront
- Use 3rd-party CA certificate in both origin and CloudFront
- Use a self-signed certificate in both the origin and CloudFront (Origin cannot be self-signed)
- A company needs to ensure that only authenticated IoT devices can access their API through CloudFront. The devices have client certificates issued by the company’s internal CA. Which CloudFront feature should they use?
- CloudFront signed URLs with trusted key groups
- CloudFront viewer mutual TLS (mTLS) authentication
- CloudFront Origin Access Control (OAC)
- CloudFront field-level encryption
- An organization wants to ensure that requests reaching their origin servers are exclusively from their authorized CloudFront distributions, using cryptographic identity verification rather than shared secrets. Which approach provides the strongest origin protection?
- Custom headers with X-Origin-Verify and Secrets Manager rotation
- CloudFront managed prefix list with security group rules
- CloudFront Origin mTLS authentication with client certificates
- Origin Access Control (OAC) with S3 bucket policies
- A company wants to serve their web application through CloudFront, but their backend ALB must not be accessible from the public internet. The ALB is in a private subnet. Which CloudFront feature enables this?
- Origin Access Control (OAC) with ALB
- Custom headers with Secrets Manager rotation
- CloudFront VPC Origins
- CloudFront managed prefix list with security groups
- A company is currently using Origin Access Identity (OAI) to restrict S3 access through CloudFront. They need to serve SSE-KMS encrypted objects. What should they do?
- Add the OAI to the KMS key policy
- Migrate from OAI to Origin Access Control (OAC), which supports SSE-KMS
- Use CloudFront field-level encryption instead of SSE-KMS
- Create a Lambda@Edge function to decrypt the objects























