AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

65
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Eric Brandwine, AWS Senior Principal Security Engineer December 1, 2016 Encryption It Was the Best of Controls, It Was the Worst of Controls SAC306

Transcript of AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Page 1: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Eric Brandwine, AWS Senior Principal Security Engineer

December 1, 2016

EncryptionIt Was the Best of Controls,

It Was the Worst of Controls

SAC306

Page 2: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

A tale of twociphers

datasets

Page 3: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

What is this talk?

Page 4: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 5: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 6: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 7: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Why Encrypt?

PCI:DSS Requirement 3: Protection at rest

PCI:DSS Requirement 4: Encrypt on the network

"A covered entity must, in accordance with §164.306…

Implement a mechanism to encrypt and decrypt electronic

protected health information.” (45 CFR § 164.312(a)(2)(iv))

Etc., etc., etc.

Page 8: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption is

HARD

Page 9: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption is

EXPENSIVE

Page 10: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption is

worth it(sometimes)

Page 11: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

+ + =

A recipe

Page 12: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

+ + =

Unbreaking an egg

Page 13: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

How I thought crypto failed

Page 14: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

How crypto actually fails

Page 15: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Primitives, Modes, and Protocols

MA

TH

+ + = Super_Secret_Message

S u p e r _ S e

E n c r y p t e

Block

Cipher

c r e t _ M e s

d _ C i p h e r

Block

Cipher…

Page 16: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

TLS as a protocolArbitrarily bad

network

(The Internet)

Confidentiality

Server authentication

Tamper evidence

Replay protection

Page 17: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

A leak!

MA

TH

+ + = Awfully_Awfully_Secret

A w f u l l y _

E n c r y p t e

Block

Cipher

A w f u l l y _

E n c r y p t e

Block

Cipher…

Page 18: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

A big pile of crypto

Primitive

Protocol

Mode

Primitive

Protocol

Mode

Primitive

Mode

Page 19: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

We believe

Page 20: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Crypto here and crypto there

Page 21: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption in transit

Page 22: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

A tale of one cipher

Super_Secret_Message

S u p e r _ S e

E n c r y p t e

Stream

Cipher

c r e t _ M e s

d _ C i p h e r

K e y s t r e a m _ b y t e s _

⨁ ⨁⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁ ⨁

RC4

Page 23: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

RC4 timeline

1987: Created by Rivest at RSA

1994: Anonymously leaked

1995: Included in SSL

1999: RFC 2246, TLS 1.0

Use RC4,

don't use RC4,

I don't care

Page 24: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

A wild BEAST appears

Browser Exploit Against SSL/TLS

Page 25: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Cipher Block Chaining

E n c r y p t e

Block

Cipher

d _ C i p h e r

Block

Cipher …

Awfully_Awfully_Secret

A w f u l l y _ A w f u l l y _

⨁ ⨁IV

Page 26: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Chosen Plaintext Attack

x ⨁ A ⨁ A = x

Ci = AES(k, Ci-1 ⨁ Pi)

We want to decrypt Ci, and obtain Pi.

Pick m as a guess for Pi.

Let Pj = Cj-1 ⨁ Ci-1⨁ m

Cj = AES(k, Cj-1 ⨁ Pj)

Cj = AES(k, Cj-1 ⨁ Cj-1⨁ Ci-1 ⨁ m)

Cj = AES(k, Ci-1 ⨁ m)

Thus, m = Pi iff Cj = Ci

Page 27: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Blockwise Chosen Boundary Attack

POST /A HTTP 1.1\r\nCookie: SessionID=XXXX

POST /AAAAAA HTTP 1.1\r\nCookie: SessionID=XXXX

Let m = ‘P 1.1\r\nCookie: a’

Let m = ‘P 1.1\r\nCookie: b’

Let m = ‘P 1.1\r\nCookie: S’…

POST /AAAAA HTTP 1.1\r\nCookie: SessionID=XXXX

Let m = ‘ 1.1\r\nCookie: Sa’

Cj ≠ Ci

Cj ≠ Ci

Cj = Ci

Page 28: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Assume the cookie is 16 characters, one full block.

Guessing the entire cookie at once:

2128 guesses (worst case) = 340,282,366,920,938,463,463,374,607,431,768,211,456

Guessing the entire cookie one byte at a time:

16 * 28 guesses (worst case)

= 4,096

That’s 2116 times faster or just

0.0000000000000000000000000000000012%

as many guesses

Page 29: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

The short version

If:

I can cause your client to make requests

JavaScript

I can control block alignment

I can sniff the resulting TLS traffic

There is a repeated field worth stealing

Cookies

Then:

I can guess byte-wise rather than block-wise

Page 30: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

RC4 timeline

1987: Created by Rivest at RSA

1994: Anonymously leaked

1995: Included in SSL

1999: RFC 2246, TLS 1.0

2011: BEAST

Use RC4,

don't use RC4,

I don't care

Use RC4!!!

Page 31: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

But….

If:

I can cause your client to make requests

JavaScript

I can control block alignment

I can sniff the resulting TLS traffic

There is a repeated field worth stealing

Cookies

Then:

I can guess byte-wise rather than block-wise

Page 32: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Defense in depth

Includes timestamp!

Page 33: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

The end approaches

Page 34: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

RC4 timeline

1987: Created by Rivest at RSA

1994: Anonymously leaked

1995: Included in SSL

1999: RFC 2246, TLS 1.0

2011: BEAST

2013: Statistical biases

2015: RFC7465, Nope!

Use RC4,

don't use RC4,

I don't care

Use RC4!!!

Oh my, no way!

Page 35: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

IoT, the Internet of Television

I like RC4, AES, and 3DES

In that order.

Cool! Let's use AES

'cause RC4 is broken

LIES!

Page 36: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 37: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Don't fly blind

2015-05-13T23:39:43.945958Z my-loadbalancer

192.168.131.39:2817 10.0.0.1:80 0.000086 0.001048 0.001337

200 200 0 57 "GET https://www.example.com:443/ HTTP/1.1"

"curl/7.38.0" DHE-RSA-AES128-SHA TLSv1.2

Page 38: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

We've got a logjam

Page 39: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Diffie Hellman key agreement

Page 40: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Tackling the discrete log problem

512 bit: 50 core-years 35 core-minutes

768 bit: 36.5k core-years 2 core-days

1024 bit: 45M core-years 30 core-days

Page 41: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Meet SSL Labs

Page 42: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 43: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Diffie-Hellman in S3

Every webserver thread creates a new prime at startup

>> 10k primes in use at any time

We fingerprint the ClientHello and alter our response

Browsers are not offered DHE

SSL Labs gets a different view than your browser

Page 44: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

https://github.com/awslabs/s2n

Page 45: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

The bathtub curve of change

How

scary

is it?

How often does it happen?

Page 46: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption at rest

Page 47: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

+ + =

Our recipe

Page 48: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

Following the recipe

Page 49: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

This is a human

Page 50: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

She's a beauty! Low, low miles!

Page 51: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

This one, not so much

Data

Encryption

Standard

1975: Published

1976: Approved as a standard

1977: FIPS

1992: Differential cryptanalysis

1998: First public break

1998: Break in 58 hours

1999: Break in 22 hours

2006: COPACOBANA: 9 days, $10,000

Page 52: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

+ + =

Another recipe

MORE

MATH

Page 53: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Keys are sensitive

Ciphertext is sensitive

Page 54: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Keep your ciphertext close

Page 55: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

MA

TH

Oblivious clients

Page 56: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Keys in the network

Page 57: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Keys on disk

Page 58: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Keys are long term sensitive

Ciphertext is long term sensitive

Page 59: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)
Page 60: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

How we do this in S3

S3

Storage

Backend

S3 Web

AWS KMS

Page 61: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Encryption is HARD

Encryption is EXPENSIVE

Encryption is worth it

(sometimes)

Page 62: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

In theory, there's no

difference between theory

and practice.

In practice, there is.

Page 63: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Thank you!

Page 64: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Remember to complete

your evaluations!

Page 65: AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst of Controls (SAC306)

Rules of Crypto

Rule #1: Don’t do it unless you’re an expert

Rule #2: You’re not an expert

Rule #3: You’re going to screw it up, even if you are an

expert