AWS Certified Security – Specialty — Question 426

A company has a single-page application (SPA) that is served by Amazon CloudFront. An Amazon S3 bucket is the origin of the CloudFront distribution. The company is using Amazon Cognito for authentication.

An external security review reveals that unauthenticated users can download the application source code from the SPA in index.html and view internal details of the SPA. A security engineer needs to implement a solution to avoid exposing the source code to unauthenticated users.

Which solution will meet these requirements?

Answer options

Correct answer: C

Explanation

Lambda@Edge allows you to run code at the AWS edge locations, intercepting requests to CloudFront to validate Amazon Cognito tokens before serving content like index.html. If a user is unauthenticated, Lambda@Edge can seamlessly redirect them to the Amazon Cognito hosted UI, keeping the SPA source code secure. Other options like AWS WAF or an OAI cannot natively validate Cognito authentication states to restrict static file delivery.