171

It's often said that HTTPS SSL/TLS connections are encrypted and said to be secure because the communication between the server and me is encrypted (also provides server authentication) so if someone sniffs my packets, they will need zillions of years to decrypt if using brute force in theory.

Let's assume I'm on a public wifi and there is a malicious user on the same wifi who sniffs every packet. Now let's assume I'm trying to access my gmail account using this wifi. My browser does a SSL/TLS handshake with the server and gets the keys to use for encryption and decryption.

If that malicious user sniffed all my incoming and outgoing packets. Can he calculate the same keys and read my encrypted traffic too or even send encrypted messages to the server in my name?

AviD
  • 73,317
  • 24
  • 140
  • 221
Calmarius
  • 1,965
  • 2
  • 12
  • 6
  • 7
    I think this is appropriate, as understanding the risks of such an environment is within remit of security professionals. Some of us have had to run public hotspots within corporate sites, and some need to work from a variety of locations - which can include public hotspots. – Rory Alsop Jan 10 '11 at 09:37
  • 2
    What about sslstrip ? (http://www.thoughtcrime.org/software/sslstrip/) Also see this video about sslstrip – labmice Jan 13 '11 at 20:55
  • 1
    Note that while the HTTPS sites may be secure in this scenario, if at any point during your browisng session an HTTP site ever gets loaded (even in an iframe or seperate tab), a malicious hotspot can leverage that to steal your cookies on all popular non-HTTPS sites (even ones you're not currently browsing), and install backdoors for those sites which persist even after you're no longer connected to the malicious hotspot: https://samy.pl/poisontap/

    So... yeah.

    – Ajedi32 Dec 05 '16 at 16:08

11 Answers11

125

HTTPS is secure over public hotspots. Only a public key and encrypted messages are transmitted (and these too are signed by root certificates) during the setup of TLS, the security layer used by HTTPS. The client uses the public key to encrypt a master secret, which the server then decrypts with its private key. All data is encrypted with a function that uses the master secret and pseudo-random numbers generated by each side.

Thus,

  • the data is secure because it is signed by the master secret and pseudo-random numbers
  • the master secret and pseudo-random numbers are secure because it uses public-private key encryption when the TLS handshake occurs
  • the public-private key encryption is secure because:
    • the private keys are kept secret
    • public-private key encryption is designed to be useless without the private key
    • the public keys are known to be legitimate because they are signed by root certificates, which either
    • came with your computer
    • or were specifically authorized by you (pay attention to browser warnings!)

Thus, your HTTPS connections and data are safe as long as:

  1. you trust the certificates that come with your computer,
  2. you take care to only authorize certificates that you trust.
waiwai933
  • 1,351
  • 1
  • 7
  • 8
  • 2
    My local swimming baths (Hillingdon, UK) return their own certificates, so actually have full sight of what you send, even if the https is shown. 99.9% of users wouldn't notice this. – Paul May 19 '16 at 08:48
  • Question: Can you clarify how any response from the HTTPS server could be encrypted in such a way that someone listening in the middle could not interpret it? The only key that the client has is the public key which is also available to listener / hacker. – Josh G Apr 22 '19 at 18:36
  • 3
    @JoshG The client also has a private key, which only they know about. This is the essence of asymmetric (public/private key-pair) encryption. To decrypt a response from the server, a man in the middle would need the client's private key. – Ash Jun 18 '19 at 07:44