Whether you are building an e-commerce site or a business application, security is a key consideration when architecting your website or application. In this session, you will learn more about some of the things Amazon CloudFront does behind the scenes to protect the delivery of your content such as OCSP Stapling and Perfect Forward Secrecy. You will also learn how you can use AWS Web Application Firewall (AWS WAF) with CloudFront to protect your site. Finally, we will share best practices on how you can use CloudFront to securely deliver content end-to-end, control who accesses your content, how to shield your origins from the Internet, and getting an A+ on SSL labs.
2. What to Expect from the Session
In this session we will talk about:
• Why security matters
• Key aspects of security
• How CloudFront can help
• Best practices for secured delivery on CloudFront
4. How AWS Can Help
Infrastructure
Security
Application
Security
Services Security
In the cloud, security is a shared responsibility
https://aws.amazon.com/compliance/shared-responsibility-model/
Encrypt data in transit
Encrypt data at rest
Protect your AWS credentials
Rotate your keys
Secure your application, OS,
stack, and AMIs
Enforce IAM policies
Use MFA, VPC, and
leverage S3 bucket policies
EC2 security groups
EFS in EC2, ACM, etc.
SOC 1,2,3
ISO 27001/2 Certification
PCI DSS 2.0 Level 1-5
HIPAA/SOX Compliance
FedRAMP, FISMA &
DIACAP ITAR
How we secure our
infrastructure
How can you secure your
application?
What security options and
features are available to you?
5. How CloudFront Can Help
Infrastructure
Security
Application
Security
Services Security
Security on CloudFront
SSL/TLS options
Private content
Origin access identities
Web Application Firewall
CloudTrail
IAM policies
Origin protection
Rotate keys
Rotate certificates
PCI DSS 2.0 Level 1
ISO 9001, 27001,
27017, 27018
6. How CloudFront Can Help
What CloudFront
does automatically
What you can do
using CloudFront
features
+ =
What should you do?
Secured content
delivery
14. CloudFront Protects Data in Transit
Origin
Edge
Location
User Request A
• Deliver content over
HTTPS to protect data
in transit
• HTTPS authenticates
CloudFront to viewers
• HTTPS authenticates
origin to CloudFront
19. Session Tickets
• Session tickets allow client to
resume session
• CloudFront sends encrypted
session data to client
• Client does an abbreviated
SSL handshake
CloudFront
Edge location
20. OCSP Stapling
1
2 3
4
5
Client
OCSP Responder
Origin Server
Amazon
CloudFront
1) Client sends TLS Client Hello
2) CloudFront requests certificate status from
OCSP responder
3) OCSP responder sends certificate status
4) CloudFront completes TLS handshake with
client
5) Request/response from origin server
21. OCSP Stapling
…
OCSP Stapling
Client Side Revocation Checks
0 50 100 150 200 250 …
(time in milliseconds)
0 50 100 150 200 250 …
(time in milliseconds)
TCP Handshake
Client Hello
Server Hello
DNS for OCSP Responder
TCP to OCSP Responder
OCSP Request/Response
… Follow Certificate Chain
Complete Handshake
Application Data
30%
Improvement
120 ms faster
22. Validate Origin Certificate
CloudFront validates SSL certificates to origin
Origin domain name must match Subject Name on
certificate
Certificate must be issued by a Trusted CA
Certificate must be within expiration window
24. Deliver Content using HTTPS
• CloudFront makes it easy
• Create one distribution, and deliver both
HTTP & HTTPS content
• There are other options as well:
• Strict HTTPS
• HTTP to HTTPS redirect
25. CloudFront TLS Options
Default CloudFront
SSL Domain Name
CloudFront certificate
shared across customers
When to use?
Example: dxxx.cloudfront.net
SNI Custom SSL
Bring your own SSL certificate
OR Use AWS Certificate Manager
Relies on the SNI extension of the
Transport Layer Security protocol
When to use?
Example: www.mysite.com
Some older browsers/OS do not support
SNI extension
Dedicated IP Custom
SSL
Bring your own SSL certificate
OR Use AWS Certificate
Manager
CloudFront allocates dedicated
IP addresses to serve your SSL
content
When to use?
Example: www.mysite.com
Supported by all browsers/OS
26. Before (time-consuming & complex)
3rd Party
Certificate
Authority
3-5 days
Upload to IAM
via AWS CLI
Connect to CloudFront
via AWS CLI
After (simple & automated & super fast)
AWS
Certificate
Manager
End-to-end process
within minutes
Using a couple of
mouse clicks on the
console
Integrated with AWS Certificate Manager
28. MapBox uses SNI Custom SSL
• They wanted to use a custom domain
xxxxx.mapbox.com
• Their clients support TLS
• They wanted to use an economical option
30. Half Bridge TLS Termination
CloudFront
HTTP
Better performance by leveraging HTTP connections to origin
region
31. Full Bridge TLS Termination
Amazon
CloudFront
HTTPS
• Secured connection all the way to origin
• Use origin ‘Match Viewer’ or ‘HTTPS Only’
region
32. MapBox uses multiple origins
• Have multiple API endpoints (origin servers)
• One with Half Bridge: HTTP from Edge to Origin
• Second with Full Bridge: HTTPS from Edge to Origin
33. You are not done yet…
You need to protect content cached at
the Edge
34. Access Control
What if you want to…
• Deliver content only to selected customers
• Allow access to content only until ‘time n’
• Allow only certain IPs to access content
35. Access Control: Private Content
Signed URLs
• Add signature to the Querystring in URL
• Your URL changes
When should you use it?
• Restrict access to individual files
• Users are using a client that doesn't
support cookies
• You want to use an RTMP distribution
Signed Cookies
• Add signature to a cookie
• Your URL does not change
When should you use it?
• Restrict access to multiple files
• You don’t want to change URLs
40. Amazon CloudFront
Edge Location
Access Control with AWS WAF, a Web
Application Firewall Service
Scraper Bot
Host: www.internetkitties.com
User-Agent: badbot
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://www.InTeRnEkItTiEs.com/
Connection: keep-alive
AWS WAF
Host: www.internetkitties.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)…..
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://www.mysite.com/
Connection: keep-alive
41. MapBox uses AWS WAF to Protect from Bots
Good Users
Bad Guys
Serve
r
AWS
WAF
Logs
Threat
Analysis
Rule Updater
42. AWS WAF Example: A Technical Implementation
Blocking bad bots dynamically with AWS WAF web ACLs
43. AWS WAF Example: Blocking Bad Bots
What We Need…
• IPSet: contains our list of blocked IP addresses
• Rule: blocks requests if requests match IP in our IPSet
• WebACL: allow requests by default, contains our Rule
and…
• Mechanism to detect bad bots
• Mechanism to add bad bot IP address to IPSet
44. AWS WAF Example: Detecting Bad Bots
• Use robots.txt to specify which
areas of your site or web app
should not be scraped
• Place file in your web root
• Ensure there are links pointing to
non-scrapable content
• Hide a trigger script that normal
users don’t see and good bots
ignore
$ cat webroot/robots.txt
User-agent: *
Disallow: /honeypot/
<a href="/honeypot/"
class="hidden" aria-
hidden="true">click me</a>
45. AWS WAF Example: Blacklist Bad Bots
• Bad bots (ignoring your robots.txt) will
request the hidden link
• Trigger script will detect the source IP
of the request
• Trigger script requests change token
• Trigger script adds source IP to IPSet
blacklist
• WebACL will block subsequent
requests from that source
$ aws --endpoint-url
https://waf.amazonaws.com/ waf get-
change-token
{
"ChangeToken": "acbc53f2-46db-4fbd-
b8d5-dfb8c466927f”
}
$ aws --endpoint-url
https://waf.amazonaws.com/ waf update-ip-
set --cli-input-json '{ "IPSetId": ”<<IP
SET ID>>", "ChangeToken": "acbc53f2-46db-
4fbd-b8d5-dfb8c466927f", "Updates": [ {
"Action": "INSERT", "IPSetDescriptor": {
"Type": "IPV4", "Value": ”<<SOURCE
IP>>/32" } } ] }’
{
"ChangeToken": "acbc53f2-46db-4fbd-
b8d5-dfb8c466927f”
}
51. Access Control: Restricting Origin Access
Amazon S3
Origin Access Identify (OAI)
• Prevents direct access to your Amazon
S3 bucket
• Ensures performance benefits to all
customers
Custom Origin
Block by IP Address
Pre-shared Secret Header
• Whitelist only CloudFront
• Protects origin from overload
• Ensures performance benefits to all customers
52. Object Access Identity (OAI)
• Only CloudFront can access
Amazon S3 bucket
• We make it simple for you
Amazon CloudFront
Region
Amazon S3
bucket
Custom Origin
53. Shield Custom Origin
1. Whitelist CloudFront IP range
2. Whitelist a pre-shared secret origin header
Amazon CloudFront
Region
Amazon S3
bucket
Custom Origin
54. Shield Custom Origin
• Subscribe to SNS notifications on changes to IP ranges
• Automatically update security groups
• https://github.com/awslabs/aws-cloudfront-samples
AWS Lambda
Amazon CloudFront
Amazon SNS
Security Group
Web app
server
Web app
server
AWS IP Ranges
Update IP Range
SNS Message
55. Origin Best Practices
1. Match Viewer
Origin Protocol Policy
• Enable Only TLS 1.1
or 1.2 to Origin
• Enforce HTTPS-Only
Connections to Origin
2. Restrict Access
using Security Groups
& Shared Secret
3. Use a SHA256
certificate
security group
56. Origin Best Practices
4. Use ELB with custom
certificate
5. Use ELB pre-defined policy 6. Send HSTS header
*Strict-Transport-Security: max-
age=15552000;
*X-Frame-Options: SAMEORIGIN
*X-XSS-Protection: 1; mode=block
Options
You can request an SSL certificate
from AWS Certificate Manager