The blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

95 lines
4.1 KiB

  1. ---
  2. title: TLS Client Authentication Leaks User Info (pre-TLS1.3)
  3. description: >
  4. TLS Client Authentication Leaks User Info (pre-TLS1.3)
  5. posted: !!timestamp '2018-10-15'
  6. created: !!timestamp '2018-10-15'
  7. time: 10:54 AM
  8. tags:
  9. - TLS
  10. - security
  11. ---
  12. It's been long known that TLS is not the best privacy protecting
  13. protocol in that SNI leaks what domain the client connects to. I'm a
  14. bit surprised that I haven't seen the failure to protect user
  15. information when using client authentication mentioned, but it's likely
  16. that TLS client authentication is so rarely used, that this have not
  17. been on anyone's radar.
  18. TL;DR: Just don't use TLS client authentication on anything before TLS
  19. 1.3.
  20. With TLS 1.2 and earlier, if you use client authentication, the client
  21. certificate is transmitted in the clear. This contains enough
  22. information to uniquely identify the user. If it didn't, then there
  23. would be no way for the server to do the authentication.
  24. The danger of this is that Eve (eavesdroppers) on path will be able to
  25. track your user's (or your) connections, where they connect from, figure
  26. out how much data they transfer between to/from your site and likely
  27. profile their usage.
  28. I was confident that this was the case as I know that the entire
  29. handshake is in the clear. It isn't till the Finished messages that
  30. the session becomes encrypted. (TLS 1.3 fixed this by using a new
  31. derived key, `[sender]_handshake_traffic_secret`, to encrypt all the
  32. server params, which the client will use to encrypt it's response to
  33. the certificate request in the server params.) I decided to verify
  34. that this was the case.
  35. I generated a server and a client certificate and key:
  36. ```
  37. openssl req -batch -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout server.key -out server.crt
  38. openssl req -batch -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout client.key -out client.crt
  39. ```
  40. I then launched the server, and included the `-Verify` and `-CAfile` options
  41. for `s_server` to request a client certificate:
  42. ```
  43. openssl s_server -accept 5829 -cert server.crt -key server.key -Verify 5 -CAfile client.crt -debug
  44. ```
  45. Then I ran tcpdump to capture the session:
  46. ```
  47. sudo tcpdump -s 0 -n -i lo0 -w clientcert.tcpdump port 5829
  48. ```
  49. And then the client to connect to the server:
  50. ```
  51. openssl s_client -connect localhost:5829 -key client.key -cert client.crt -debug
  52. ```
  53. A usual, non-client authenticated connection and close was about 17
  54. packets, but when I included the client authentication, it became 42
  55. packets (the answer!).
  56. I loaded the packet capture into wireshark, applied the SSL protocol
  57. analysis and confirmed that the client certificate was present in clear
  58. text:
  59. [![Wireshark shows TLS handshake with client authentication, with the client certificate displayed in plaintext.]([[!!images/tls.packet.capture.screenshot.png]])]({{ media_url('images/tls.packet.capture.screenshot.png') }})
  60. So, there you have it. Do not use client authentication, pre-TLS 1.3,
  61. if you care about the privacy of your users.
  62. It is safe to use client authentication w/ a TLS 1.3 server as long as
  63. the server requires all clients be 1.3 clients. If the key exchange
  64. algorithm is one of DHE_DSA, DHE_RSA, or an ECDH key exchange algorithm,
  65. the random bytes in the Hello messages are signed and these bytes are
  66. used by TLS 1.3 for downgrade protection. As the signature covers these
  67. bytes, the client would be able to detect any attempts to modify the
  68. server or client handshake messages to force a downgrade before it would
  69. send the client certificate.
  70. Thanks to Mike Hamburg for reviewing an earlier version of this blog
  71. post and pointing out that TLS 1.3 was not vulnerable to this and
  72. helping w/ some of the research to prove it.
  73. References:
  74. * [TLS 1.2 Protocol Diagram](https://tools.ietf.org/html/rfc5246#page-36)
  75. * [TLS 1.2 ServerKeyExchange](https://tools.ietf.org/html/rfc5246#page-52)
  76. * [ECC Cipher Suites for TLS ServerKeyExchange Signature](https://tools.ietf.org/html/rfc4492#page-20)
  77. * [TLS 1.3 Protocol Diagram](https://tools.ietf.org/html/rfc8446#section-2)
  78. * [TLS 1.3 Server Hello](https://tools.ietf.org/html/rfc8446#section-4.1.3) Downgrade Protection