In messengers like WhatsApp and Signal you can detect this attack by having your friend comparing a security code (safety number) that looks like this, using some other channel.
Almost nobody does this. Even my cryptographer friends are like “nah, let’s YOLO this one.” /6
Anyway: one potential solution to this problem is Key Transparency.
The idea of key transparency is that you (1) publish a single hash that commits to every key/identity in the system at a given time. Then people can (2) compare their hashes… /7
@signalapp take notice
Indeed initial key exchange, as difficult as recovery once in a new device.
All systems have their own turnarounds for these two, so common standardization proposals towards handling these are need!
Against this, we here use Shibboleth/s, secrets, which only Alice and Bob know.