Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The first few milliseconds of HTTPS

Joshua Thijssen
October 03, 2014
66

The first few milliseconds of HTTPS

Joshua Thijssen

October 03, 2014
Tweet

Transcript

  1. The first 200 milliseconds of HTTPS
    1
    Joshua Thijssen
    jaytaph

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  4. ➡ 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

    View full-size slide

  5. ➡ 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

    View full-size slide

  6. This talk is inspired by
    a blogpost from Jeff Moser
    http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html
    Unknown fact!
    3

    View full-size slide

  7. HTTPS ==
    HTTP on top of TLS
    4

    View full-size slide

  8. Transport Layer Security
    (TLS)
    5

    View full-size slide

  9. Secure Socket Layer
    (SSL)
    6
    A short and scary history

    View full-size slide

  10. then
    now
    SSL 1.0
    Vaporware
    1994
    7

    View full-size slide

  11. then
    now
    feb
    1995
    SSL 2.0
    Not-so-secure-socket-layer
    SSL 1.0
    Vaporware
    1994
    7

    View full-size slide

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

    View full-size slide

  13. 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
    7

    View full-size slide

  14. 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
    7

    View full-size slide

  15. 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
    7

    View full-size slide

  16. 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
    8
    November 2013

    View full-size slide

  17. 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
    8
    20,5%
    98,5% 99,3%
    38,4% 40,8%
    SSL 2.0 SSL 3.0 TLS 1.0 TLS 1.1 TLS 1.2
    November 2013 Aug 2014

    View full-size slide

  18. RFC 5246
    (TLS v1.2)
    9

    View full-size slide

  19. 10
    Record Layer

    View full-size slide

  20. 10
    Record Layer
    Type Version Length

    View full-size slide

  21. 10
    Record Layer
    Type Version Length
    Protocol

    View full-size slide

  22. 10
    Record Layer
    Type Version Length
    Protocol
    Protocol
    Protocol

    View full-size slide

  23. 10
    Record Layer
    Type Version Length
    Protocol
    Protocol
    Protocol
    Record Layer
    Type Version Length
    Protocol

    View full-size slide

  24. ➡ Handshake protocol records
    ➡ Setup communication
    ➡ Change Cipher Spec protocol records
    ➡ Change communication
    ➡ Alert protocol records
    ➡ Errors
    ➡ Application Data protocol records
    ➡ Actual data transfers
    11

    View full-size slide

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

    View full-size slide

  26. Attention:
    (live)
    wiresharking
    up ahead
    13

    View full-size slide

  27. Generating
    randomness is HARD
    16

    View full-size slide

  28. entropy
    (uncertainty)
    17

    View full-size slide

  29. TIME is NOT random
    thus not a very good
    entropy source
    18

    View full-size slide

  30. PHP is bad
    when it comes to
    entropy
    19
    Unknown fact!

    View full-size slide

  31. openssl_pseudo_random_bytes()
    20

    View full-size slide

  32. openssl_pseudo_random_bytes()
    read from /dev/(u)random
    20

    View full-size slide

  33. openssl_pseudo_random_bytes()
    read from /dev/(u)random
    Use a HRNG
    20

    View full-size slide

  34. openssl_pseudo_random_bytes()
    read from /dev/(u)random
    Use a HRNG
    “A million random digits”
    20

    View full-size slide

  35. openssl_pseudo_random_bytes()
    read from /dev/(u)random
    Use a HRNG
    “A million random digits”
    https://github.com/ircmaxell/RandomLib
    20

    View full-size slide

  36. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    22

    View full-size slide

  37. TLS
    ECDHE_ECDSA
    WITH
    AES_128_GCM
    SHA256
    23

    View full-size slide

  38. TLS
    ECDHE_ECDSA
    WITH
    AES_128_GCM
    SHA256
    Cipher for exchanging
    key information
    23

    View full-size slide

  39. TLS
    ECDHE_ECDSA
    WITH
    AES_128_GCM
    SHA256
    Cipher for exchanging
    key information
    Cipher for
    authenticating key
    information
    23

    View full-size slide

  40. 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
    23

    View full-size slide

  41. 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
    23

    View full-size slide

  42. TLS_RSA_WITH_AES_256_CBC_SHA256
    24

    View full-size slide

  43. TLS_NULL_WITH_NULL_NULL
    25

    View full-size slide

  44. Client gives cipher options,
    Server ultimately decides on cipher!
    26

    View full-size slide

  45. THIS IS WHY YOU SHOULD ALWAYS
    CONFIGURE YOUR CIPHERS
    ON YOUR WEB SERVER!
    27
    Unknown fact!

    View full-size slide

  46. 28
    https://cipherli.st
    SSLCipherSuite AES256+EECDH:AES256+EDH
    SSLProtocol All -SSLv2 -SSLv3
    SSLCompression off # Requires Apache >= 2.4
    SSLHonorCipherOrder On
    SSLUseStapling on # Requires Apache >= 2.4
    SSLStaplingCache "shmcb:logs/stapling-cache(150000)" # Requires >= Apache 2.4
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
    Header always set X-Frame-Options DENY
    ssl_ciphers 'AES256+EECDH:AES256+EDH';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
    add_header X-Frame-Options DENY;
    ssl_stapling on; # Requires nginx >= 1.3.7
    ssl_stapling_verify on; # Requires nginx => 1.3.7
    resolver $DNS-IP-1 $DNS-IP-2 valid=300s;
    resolver_timeout 5s;
    Apache:
    nginx:

    View full-size slide

  47. https://www.ssllabs.com/ssltest/
    29

    View full-size slide

  48. 32
    https://www.overheid.nl/

    View full-size slide

  49. 37
    ➡ SNI (Server Name Indication)
    ➡ Extension 0x0000
    ➡ Pretty much every decent browser /
    server.
    ➡ IE6, Win XP, Blackberry, Android 2.x,
    java 1.6.x
    ➡ So no worries!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  52. 42
    ➡ X.509 Certificate

    View full-size slide

  53. 42
    ➡ X.509 Certificate
    ➡ Owner info (who is this owner)

    View full-size slide

  54. 42
    ➡ X.509 Certificate
    ➡ Owner info (who is this owner)
    ➡ Domain info (for which domain(s) is
    this certificate valid)

    View full-size slide

  55. 42
    ➡ X.509 Certificate
    ➡ Owner info (who is this owner)
    ➡ Domain info (for which domain(s) is
    this certificate valid)
    ➡ Expiry info (from when to when is this
    certificate valid)

    View full-size slide

  56. 43
    yourdomain.com

    View full-size slide

  57. 43
    yourdomain.com
    Intermediate
    CA

    View full-size slide

  58. 43
    yourdomain.com
    Intermediate
    CA

    View full-size slide

  59. 43
    yourdomain.com
    Root
    CA
    Intermediate
    CA

    View full-size slide

  60. 43
    yourdomain.com
    Root
    CA
    Intermediate
    CA

    View full-size slide

  61. 43
    yourdomain.com
    Root
    CA
    Intermediate
    CA

    View full-size slide

  62. 44
    IMPLIED TRU$T

    View full-size slide

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

    View full-size slide

  64. 46
    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

    View full-size slide

  65. 46
    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...

    View full-size slide

  66. 47
    ➡ X.509 certificates are used to authenticate
    the server.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  69. 50
    Generating secrets:

    View full-size slide

  70. 50
    pre master secret server rand
    client rand
    Generating secrets:
    + +

    View full-size slide

  71. 50
    pre master secret server rand
    client rand
    master secret
    Generating secrets:
    + +

    View full-size slide

  72. 50
    pre master secret server rand
    client rand
    master secret
    master secret server rand client rand
    Generating secrets:
    + +
    +
    +

    View full-size slide

  73. 50
    pre master secret server rand
    client rand
    master secret
    master secret server rand client rand
    key buffer
    Generating secrets:
    + +
    +
    +

    View full-size slide

  74. 50
    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:
    + +
    +
    +

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  79. Are we safe yet?
    60

    View full-size slide

  80. euh,.. no :/
    61

    View full-size slide

  81. 62
    PRE MASTER
    SECRET

    View full-size slide

  82. What if somebody*
    got hold of the site
    private key?
    63

    View full-size slide

  83. (PERFECT)
    FORWARDING
    SECRECY
    68

    View full-size slide

  84. Compromising the
    pre-master secret does
    not compromise our
    communication.
    69

    View full-size slide

  85. PFS:
    Can’t compromise
    other keys with a
    compromised key.
    70

    View full-size slide

  86. Unfortunately..
    71

    View full-size slide

  87. 72
    PFS needs server
    AND browser support

    View full-size slide

  88. 73
    http://news.netcraft.com/archives/2013/06/25/ssl-intercepted-today-decrypted-tomorrow.html

    View full-size slide

  89. 74
    http://news.netcraft.com/archives/2013/06/25/ssl-intercepted-today-decrypted-tomorrow.html

    View full-size slide

  90. Update your cipher
    suite list and place
    PFS ciphers at the top
    75

    View full-size slide

  91. But beware:
    heavy computations
    76

    View full-size slide

  92. 77
    SSL Test
    https://www.ssllabs.com/ssltest/

    View full-size slide

  93. -ETOOMUCHINFO
    78

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  96. 81
    Find me on twitter: @jaytaph
    Find me for development and training: www.noxlogic.nl
    Find me on email: [email protected]
    Find me for blogs: www.adayinthelifeof.nl

    View full-size slide