Symmetric encryption communication

The most straightforward way is that you can decide on an encryption key in reality and use symmetric encryption such as AES-256 to encrypt and decrypt all messages.
But it’s not convenient to exchange the key online. Because if you send the key using an unsafe channel that is being monitored, the attacker can also get the key and decrypt all your messages. The attacker can directly use passive attack (read-only, without any modification) to monitor the messages.
One way is to use asymmetric encryption communication.

Asymmetric encryption communication

The mechanism of asymmetric encryption can be that A and B each generate a set of public keys and private keys and then use the other one’s public key to encrypt the content and send it, and the other one can decrypt it with its private key after receiving it.
Therefore, even if the attacker gets A and B’s public keys, he cannot decrypt the messages because he needs to know the private key.
But it’s still not perfect.

MITM attack in asymmetric encryption communication

MITM means man-in-the-middle attack. Suppose you generate a public key and a private key for two clients, A and B, and then exchange the public keys of the two through a server C, and the server C is not secure. It is useless to monitor the public keys because only obtaining the public key cannot decrypt messages with the private key, so it cannot be monitored. But suppose B’s public key is replaced by C, and A uses this replaced public key C to encrypt messages. In that case, server C decrypts it with C’s private key, encrypts it with B’s public key, and B decrypts it with its private key. A and B have no sense, and C succeeds in a man-in-the-middle attack. Even if a secure key exchange technology such as the D-H key exchange method is used, the key exchange process can still be relayed by server C as a middleman.
The attacker cannot directly use passive attack to monitor the messages in asymmetric encryption communication. The attacker needs to manipulate and change the communication flow.

Prevent from MITM attack

Therefore, to avoid man-in-the-middle attacks, certificate authentication must be used, or keys must be exchanged in another channel that the middleman cannot participate in, such as in reality.

Certificate authentication

Certificate authentication is similar to that each operating system comes with its own CA root certificates. The CA signs and issues an SSL certificate to a certified website, and the operating system can verify whether the website’s certificate is signed by a built-in CA root certificate. This is based on the belief that the CA is trustworthy and not being manipulated. However, we should not trust any organization.

PGP communication

PGP (or GPG) is one kind of asymmetric encryption communication that uses public and private keys to encrypt and decrypt and mainly uses emails to send messages.

MITM in PGP online key exchange

PGP (or GPG) online key exchange is generally based on email registration, uploading the public key to the keyserver, searching for the other one’s public key according to the email, and then using email communication. This is based on the belief that the keyserver is not being manipulated. But it has an advantage that the keyserver and the communication channel (email) are independent. If a MITM attack is possible, the website of the keyserver and the user’s email must be controlled at the same time. Otherwise, even if the public key is replaced (A uses C’s public key to encrypt and send an email to B) if C can’t manipulate A and B’s mail server’s data (let A’s email be sent to C, and C decrypts with its own private key and encrypt with B’s public key and send to B pretends that A is sent to B), they can’t be attacked by MITM. If A and B’s PGP keyservers and mail manufacturers are completely controlled by the same company, it is possible for this company to completely replace keys and relay mail messages. So the key is that the keyserver company and the mail company cannot be controlled by the same country.

A simple method to exchange public keys

Actually, you don’t even need a keyserver. Suppose, after exchanging the public key directly through WhatsApp or WeChat (assuming these two channels are monitored), then immediately start a video call, and look at each other’s screen to see if the public key of the other one is the same as the public key on your own computer screen. You can also talk about some randomly selected daily questions at the same time (to increase the difficulty of making fake AI-generated videos). It’s basically foolproof. The public key is originally public, and it doesn’t matter if it is monitored. The main point is how to prove that the other one’s public key has not been replaced by an intermediary. Video calls are all about assuming they can’t replace the video stream in real-time, and then they can’t fake the public key.

Conclusion

Security is based on assumptions

The best way to avoid man-in-the-middle attacks is to make an assumption that “the middleman can’t do something,” and based on this assumption, do something that a middleman can’t intervene. For example, it is assumed that the middleman cannot monitor the exchange of keys between two people in a safe place in reality. For another example, it is assumed that the middleman cannot replace the video with a fake video that contains a fake public key on your friend’s screen in real-time and use an AI-generated voice to answer your random question in real-time perfectly when the two people have a video call to verify the public key.
To be completely decentralized, without trusting any server, you can only exchange in reality, like joining a key signing party.

Use a safe deivce

In the end, do not forget to use a safe device.
For example, if you

  • buy a hardware with a BIOS backdoor (even if you reinstall the system, it will automatically install the backdoor for you)
  • use a closed-source network-updated commercial operating system (the company may compromise and then control your computer over the network)
  • use commercial software that is not open source (the software may connect to the Internet and then push a Trojan to your computer, or it may contain a Trojan function)
  • use an open-source software but contains evil codes

you cannot protect your private key, or your keyboard input could be completely monitored, or your screen could be captured. Then all your previous efforts were in vain. It is not enough if you use a secure device. Even if there is one unsecured device in your area, it can steal sound and light from the environment through microphones and cameras, make side channel attacks, guesses what you typed and restore what you said.

Comments

⬆︎TOP