One often hears/reads that with SSL or better an VPN your data is safe even if the WLAN is not secure.

I don't understand much about Handshakes and SSL or VPN security but it was always hard to believe that one could establish a secure connection over an malicious one. Since I now more often use public WLANs, this becomes an issue for me, so I started reading a bit, but the answers are always a bit vague. So maybe an example is the better way to explain/ask what I mean.

Let's say you are in a library with an unencrypted WLAN. Somebody brought his Pineapple 5 one hour before I arrive at the library, fakes the SSID of that network.

An hour later I arrive, start my laptop and login into the WLAN of the library, but little do I know, it has the same name and the landing page looks similar, but the hacker redirected me to his fake site. He now has for sure my login for the library - which is bad but not my main concern.

I see that I now have a established connection to the WLAN. Now I start my Cyberghost VPN and connect with it everything goes well.

Are the passwords that go through this channel secure?

In my head the answer would be: "How on earth should it be secure??" if the hacker can read the negotiation like "use AES, 256 bit, and the private key is XXX" he can "unwind" the encryption and read the cleartext of my communication or am I missing something?

  • Read up on public key infrastructure (PKI), digital certificates and digital signatures... – Kinnectus Jul 22 at 16:30
  • I did and i found it a) confusing and b) imprecise in regard to answer this questions.. – user54512 Jul 23 at 8:40
  • I wrote it in Harries comment section but want to have it for everybody. Adding some detail regarding how cyberghost works (it sounds like a lot of marketing bs, but there is some information in it): "CyberGhost VPN operates using a protected surfing encryption based on the SSL standard (RSA procedure) which, unlike the procedures used by rival products, creates both the public and private keys directly and individually on the users system. This prevents Man in the middle attacks that are possible if key pairs are created on the server." – user54512 Jul 23 at 16:31
  • Instead of adding information as comments, add them to your question! – Daniel B Jul 24 at 9:35
  • @Daniel B: Well i couldn't as you know. But thanks for the handy link. How much Reputation do i need to edit my postings or how does this work? – user54512 Jul 24 at 19:24

This is actually a good question and not as simple as it looks. The actual answer of whether a VPN protects against Man In The Middle (MiTM) attacks depends a lot on the implementation of the VPN software and on where in the chain of communication has the attacker gained entrance.

In the simple case you outlined, the element you forgot is the certificate returned by the VPN server. The client can verify the server's public key by consulting the issuing Certificate Authority. This public key lets him talk to the VPN server, but only the VPN server has the private key required to decode the message, so the MiTM attacker is left clueless as to what is going on.

HTTPS works in somewhat the same manner as VPN, so is also a good protection, although no protection is ever perfect.

Useful resources:

Visual description of the process:

enter image description here

  • Hi harrymc, i searched the web about how Cyberghost handles this and it states: "CyberGhost VPN operates using a protected surfing encryption based on the SSL standard (RSA procedure) which, unlike the procedures used by rival products, creates both the public and private keys directly and individually on the users system. This prevents Man in the middle attacks that are possible if key pairs are created on the server." Could you elaborate how the answer changes given that information? Unfortunately i don't get very far with it, it is a bit hard to imagine how my machine can do everything.. – user54512 Jul 23 at 16:22
  • That's the most elementary description of digital certificates: Generating a public and private key and communicating only the public one. Every VPN product must do that on the client side, for the server to be able to send messages to the client that are encrypted with the client's public key. Certainly not only Cyberghost. Written by a commercial that understood nothing of what he was told by the developers and thought they invented RSA. – harrymc Jul 23 at 16:49
  • I added an image of how SSL works. All communications are encrypted all the time and cannot be decrypted without having the private keys, which keys are never sent in plaintext. – harrymc Jul 23 at 17:02
  • Harrymc thx for your time and answers, but i do not really get anywhere with my Question. It would be much bettter for me to really understand if there was an answer that explains step by step what happens on initial setup like 1. My machine send hello 2. Gets back hello with paramters AES 256bit... And so on. It would be ok if contains speculative assumptions (since no VPN seems to care to explain EXACTLY what happens). Since all the answers basically say: "Depends" on your VPN - which is not good if you want to use an example to learn something. – user54512 Jul 23 at 17:04
  • Put the attacker into the above image - he can intercept and understand the first message. He cannot answer with a false public key, since the client will discover this when consulting the Certificate Authority. The second message will be encoded with the server's public key that only the server can decrypt. Communications are from then on encrypted and unbreakable. A problem can only occur if the public key is weak and the attacker has enough CPU power to break it, or if the attacker managed to connect before/after the encrypted part. ... – harrymc Jul 23 at 17:13

You say your VPN is using SSL, so the process is relatively simple and there are many learning resources.

First of, there’s both asymmetric and symmetric encryption involved. Asymmetric encryption is used to securely negotiate the key for the symmetric encryption.

Asymmetric encryption is generally very computationally expensive (RSA even more so than modern elliptic curve crypto). It’s not suitable for transferring the actual data of a VPN connection. This is done using a fast symmetric cipher like AES.

When establishing a one-way authenticated (no client certificate) RSA SSL/TLS connection, this is the procedure:

  1. The client knows either the VPN server certificate directly or the issuing certificate beforehand. This is required to determine whether the server can be trusted.
  2. The client sends the Client Hello message, containing a list of supported ciphers and whatnot.
  3. The server responds with the Server Hello message, containing the cipher etc that will be used and the server’s certificate (contains public key) along with any intermediate certificates.
  4. The client sends the symmetric key using asymmetric encryption (using the server’s public key—yes, this is secure and can only be decrypted using the server’s private key).
  5. The data connection can now be established because both ends know the symmetric key.

The symmetric key typically expires and will be renewed when the connection remains active for extended periods of time.

There’s a different type of key exchange called Diffie-Hellman (DH). It’s more complicated but the end result is the same. It’s also what’s used with with elliptic curves (ECDH).

If an attacker tries to attach the key exchange, they would have to replace the server’s certificate to be able to decrypt the symmetric key. This can be detected by the client because the attacker’s replacement certificate would not be trusted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.