Slide 1

Slide 1 text

The first few milliseconds of HTTPS 1 Joshua Thijssen JayTaph

Slide 2

Slide 2 text

2

Slide 3

Slide 3 text

➡ What’s happening in the first 200+ milliseconds in a initial HTTPS connection. 2

Slide 4

Slide 4 text

➡ What’s happening in the first 200+ milliseconds in a initial HTTPS connection. ➡ Give tips and hints on hardening your setup. 2

Slide 5

Slide 5 text

➡ What’s happening in the first 200+ milliseconds in a initial HTTPS connection. ➡ Give tips and hints on hardening your setup. ➡ Give you insights in new and upcoming technologies. 2

Slide 6

Slide 6 text

➡ What’s happening in the first 200+ milliseconds in a initial HTTPS connection. ➡ Give tips and hints on hardening your setup. ➡ Give you insights in new and upcoming technologies. ➡ Show you things to you (probably) didn’t knew. 2

Slide 7

Slide 7 text

HTTPS == HTTP on top of TLS 3

Slide 8

Slide 8 text

Transport Layer Security (TLS) 4

Slide 9

Slide 9 text

Secure Socket Layer (SSL) 5 A short and scary history

Slide 10

Slide 10 text

then now 6

Slide 11

Slide 11 text

then now SSL 1.0 Vaporware 1994 6

Slide 12

Slide 12 text

then now feb 1995 SSL 2.0 Not-so-secure-socket-layer SSL 1.0 Vaporware 1994 6

Slide 13

Slide 13 text

then now feb 1995 SSL 2.0 Not-so-secure-socket-layer jun 1996 SSL 3.0 Something stable! SSL 1.0 Vaporware 1994 6

Slide 14

Slide 14 text

then now feb 1995 SSL 2.0 Not-so-secure-socket-layer jun 1996 SSL 3.0 Something stable! jan 1999 TLS 1.0 SSL 3.1 SSL 1.0 Vaporware 1994 6

Slide 15

Slide 15 text

then now feb 1995 SSL 2.0 Not-so-secure-socket-layer jun 1996 SSL 3.0 Something stable! jan 1999 TLS 1.0 SSL 3.1 apr 2006 TLS 1.1 SSL 1.0 Vaporware 1994 6

Slide 16

Slide 16 text

then now feb 1995 SSL 2.0 Not-so-secure-socket-layer jun 1996 SSL 3.0 Something stable! jan 1999 TLS 1.0 SSL 3.1 apr 2006 TLS 1.1 TLS 1.2 aug 2008 SSL 1.0 Vaporware 1994 6

Slide 17

Slide 17 text

https://www.trustworthyinternet.org/ssl-pulse/ 25,7% 99,6% 99,3% 18,2% 20,7% SSL 2.0 SSL 3.0 TLS 1.0 TLS 1.1 TLS 1.2 7 November 2013

Slide 18

Slide 18 text

https://www.trustworthyinternet.org/ssl-pulse/ 25,7% 99,6% 99,3% 18,2% 20,7% SSL 2.0 SSL 3.0 TLS 1.0 TLS 1.1 TLS 1.2 7 November 2013 4,5% 15,6% 93,9% 83,6% 86,8% SSL 2.0 SSL 3.0 TLS 1.0 TLS 1.1 TLS 1.2 June 2017

Slide 19

Slide 19 text

8

Slide 20

Slide 20 text

RFC 5246 (TLS v1.2) 9

Slide 21

Slide 21 text

➡ Authenticate and exchange information. ➡ Exchange a key (through a public key system). ➡ Create "tunnel" with symmetric encryption (both sides use the same exchanged key). 10

Slide 22

Slide 22 text

11 https://github.com/vincentbernat/rfc5077/blob/master/ssl-handshake.svg

Slide 23

Slide 23 text

Attention: (live) wiresharking up ahead 12

Slide 24

Slide 24 text

13

Slide 25

Slide 25 text

TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 14

Slide 26

Slide 26 text

TLS ECDHE_ECDSA WITH AES_128_GCM SHA256 15

Slide 27

Slide 27 text

TLS ECDHE_ECDSA WITH AES_128_GCM SHA256 Cipher for exchanging key information 15

Slide 28

Slide 28 text

TLS ECDHE_ECDSA WITH AES_128_GCM SHA256 Cipher for exchanging key information Cipher for authenticating key information 15

Slide 29

Slide 29 text

TLS ECDHE_ECDSA WITH AES_128_GCM SHA256 Cipher for exchanging key information Cipher for authenticating key information Actual cipher (and length) used for communication 15

Slide 30

Slide 30 text

TLS ECDHE_ECDSA WITH AES_128_GCM SHA256 Cipher for exchanging key information Cipher for authenticating key information Hash algo for message authenticating Actual cipher (and length) used for communication 15

Slide 31

Slide 31 text

TLS_RSA_WITH_AES_256_CBC_SHA256 16

Slide 32

Slide 32 text

TLS_NULL_WITH_NULL_NULL 17

Slide 33

Slide 33 text

Client gives cipher options, Server ultimately decides on cipher! 18

Slide 34

Slide 34 text

THIS IS WHY YOU SHOULD ALWAYS CONFIGURE YOUR CIPHERS ON YOUR WEB SERVER! 19 Unknown fact!

Slide 35

Slide 35 text

20 https://cipherli.st Gives you strong cipher configuration webservers (apache,nginx etc) and other software.

Slide 36

Slide 36 text

https://www.ssllabs.com/ssltest/ 21

Slide 37

Slide 37 text

22

Slide 38

Slide 38 text

23 ➡ SNI (Server Name Indication) ➡ Extension 0x0000 ➡ Pretty much every decent browser / server / os ➡ Except: IE6, Win XP, Blackberry, Android 2.x, java 1.6.x

Slide 39

Slide 39 text

24

Slide 40

Slide 40 text

What an SSL certificate is NOT: 25 ➡ SSL certificate (but a X.509 certificate) ➡ Automatically secure ➡ Automatically trustworthy ➡ In any way better self-signed certificates ➡ Cheap

Slide 41

Slide 41 text

What an SSL certificate is: 26 ➡ The best way (but not perfect) to prove authenticity ➡ A way to bootstrap encrypted communication ➡ Misleading ➡ (Too) Expensive

Slide 42

Slide 42 text

Certificate: Data: Version: 3 (0x2) Serial Number: 0c:00:93:10:d2:06:db:e3:37:55:35:80:11:8d:dc:87 Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 Extended Validation Server CA Validity Not Before: Apr 8 00:00:00 2014 GMT Not After : Apr 12 12:00:00 2016 GMT Subject: ... C=US, ST=California, L=San Francisco, O=GitHub, Inc., CN=github.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:b1:d4:dc:3c:af:fd:f3:4e:ed:c1:67:ad:e6:cb: 22:e8:b7:e2:ab:28:f2:f7:dc:62:70:08:d1:0c:af: ....... 67:8d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Alternative Name: DNS:github.com, DNS:www.github.com X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: TLS Web Server Authentication, TLS Web Client Authentication X509v3 Basic Constraints: critical CA:FALSE Signature Algorithm: sha256WithRSAEncryption 6f:e7:6d:cb:82:f3:ef:90:87:09:d7:0f:15:22:2c:8c:fe:d3: ab:1c:8a:96:db:5d:12:5d:d1:78:c0:31:b0:ff:45:c8:89:f7: 08:98:52:17:1f:4c:4b:20:64:6a:6d:db:50:d7:10:be:7e:ab: ...... ee:b7:33:69 27

Slide 43

Slide 43 text

28 yourdomain.com

Slide 44

Slide 44 text

28 yourdomain.com Intermediate CA

Slide 45

Slide 45 text

28 yourdomain.com Intermediate CA

Slide 46

Slide 46 text

28 yourdomain.com Root CA Intermediate CA

Slide 47

Slide 47 text

28 yourdomain.com Root CA Intermediate CA

Slide 48

Slide 48 text

28 yourdomain.com Root CA Intermediate CA

Slide 49

Slide 49 text

29 IMPLIED TRU$T

Slide 50

Slide 50 text

➡ (Root) Certificate Authorities ➡ They are built into your browser / OS and you will automatically trust them. 30

Slide 51

Slide 51 text

31 wget http://mxr.mozilla.org/mozilla-central/source/security/nss/lib/ckfw/builtins/certdata.txt\?raw\=1 -O - -q | grep Issuer | sort | uniq | wc -l

Slide 52

Slide 52 text

31 wget http://mxr.mozilla.org/mozilla-central/source/security/nss/lib/ckfw/builtins/certdata.txt\?raw\=1 -O - -q | grep Issuer | sort | uniq | wc -l 181 And rising...

Slide 53

Slide 53 text

32

Slide 54

Slide 54 text

32 ➡ X.509 certificates are used to authenticate the server.

Slide 55

Slide 55 text

32 ➡ X.509 certificates are used to authenticate the server. ➡ Servers can ask clients to authenticate themselves as well.

Slide 56

Slide 56 text

32 ➡ X.509 certificates are used to authenticate the server. ➡ Servers can ask clients to authenticate themselves as well. ➡ APIs

Slide 57

Slide 57 text

Sending over our initial secret data 33

Slide 58

Slide 58 text

➡ Client generates random key (pre-shared key). ➡ Client encrypts key with public key from server SSL certificate. ➡ Client sends encrypted key to server. ➡ Server decrypts key with private key. 34 RSA

Slide 59

Slide 59 text

➡ Server generates key pair ➡ Server sends public key to client, with signature to prove authenticity (pub key from SSL certificate) ➡ Client generates key pair ➡ Client sends public key to server ➡ Both server and client calculate "secret". 35 (Elliptic curve) Diffie-Hellman (ephemeral)

Slide 60

Slide 60 text

36

Slide 61

Slide 61 text

37 Generating secrets:

Slide 62

Slide 62 text

37 pre master secret Generating secrets:

Slide 63

Slide 63 text

37 pre master secret server rand client rand Generating secrets: + +

Slide 64

Slide 64 text

37 pre master secret server rand client rand master secret Generating secrets: + +

Slide 65

Slide 65 text

37 pre master secret server rand client rand master secret master secret server rand client rand Generating secrets: + + + +

Slide 66

Slide 66 text

37 pre master secret server rand client rand master secret master secret server rand client rand key buffer Generating secrets: + + + +

Slide 67

Slide 67 text

37 pre master secret server rand client rand master secret client MAC client KEY client IV server MAC server KEY server IV master secret server rand client rand key buffer Generating secrets: + + + +

Slide 68

Slide 68 text

https://github.com/jaytaph/TLS-decoder 38 http://www.adayinthelifeof.nl/2013/12/30/decoding-tls-with-php/ Try it yourself, php style:

Slide 69

Slide 69 text

39

Slide 70

Slide 70 text

40

Slide 71

Slide 71 text

41

Slide 72

Slide 72 text

42 Wireshark CAN decrypt your HTTPS traffic Unknown fact! SSLKEYLOGFILE https://isc.sans.edu/forums/diary/Psst+Your+Browser+Knows+All+Your+Secrets+/16415

Slide 73

Slide 73 text

43 launchctl setenv SSLKEYLOGFILE /tmp/keylog.secret on a mac:

Slide 74

Slide 74 text

-ETOOMUCHINFO 44

Slide 75

Slide 75 text

➡ TLS has overhead in computation and transfers. But definitely worth it. ➡ Google likes it. ➡ Some cipher suites are better, but slower. ➡ Speed / Security compromise ➡ (try: “openssl speed”) 45

Slide 76

Slide 76 text

https://tools.ietf.org/html/rfc7457 46 Summarizing Known Attacks on Transport Layer Security (TLS) and Datagram TLS (DTLS)

Slide 77

Slide 77 text

TLS 1.3 47

Slide 78

Slide 78 text

48 ➡ Still in draft ➡ 1-RTT (initial 0-RTT) for handshakes ➡ Dropped insecure features

Slide 79

Slide 79 text

49 https://www.ssllabs.com/projects/best-practices/index.html

Slide 80

Slide 80 text

http://farm1.static.flickr.com/73/163450213_18478d3aa6_d.jpg 50

Slide 81

Slide 81 text

51 Find me on twitter: @jaytaph Find me for development and training: www.noxlogic.nl Find me on email: jthijssen@noxlogic.nl Find me for blogs: www.adayinthelifeof.nl