When I download PGP keys from keyservers like so:

gpg --search-keys steve@openssl.org

How are the public keys transferred down to my machine? Is there a possibility of a MITM attack to serve me the wrong key?


If you use the signatures on the key to validate it (such as the web of trust model), then you only depend on the key material you have, and not the key served to you. In fact, if you know the fingerprint of the key you want (with certainty) you can just verify the fingerprint after retrieving it.

If you want to avoid a MITM, you can use the hkps protocol described on the SKS Keyserver page here: https://sks-keyservers.net/overview-of-pools.php.

Keep in mind that anyone can upload any key to the keyserver, so just because it has the email you want doesn't mean it's the right key. Only the signatures on the key (and the trustworthiness of the signatures) can help determine if the key you have is the legitimate one.

  • Your answer would seem to indicate that by default, keys are downloaded from keyservers over a plaintext connection, which is terrifying. – Naftuli Kay Jun 11 '14 at 15:38
  • Why is it terrifying? And yes, hkp is the "HTTP Keyserver Protocol", and is in plaintext. – David Jun 11 '14 at 15:39
  • It's terrifying because it makes it incredibly easy for an attacker in the middle to do lots of not-so-fun things like serving you a different key for gpg --search-keys somebody@openssl.org. Then its trivial to serve signed packages with the malicious key. – Naftuli Kay Jun 11 '14 at 15:43
  • 1
    And what if a malicious keyserver serves you a different key? Or someone uploads a malicious key the keyserver? The keyservers and the data they are serving should not be trusted. – David Jun 11 '14 at 15:44
  • Ah, I suppose that's something I may have overlooked in the trust model of PGP. – Naftuli Kay Jun 11 '14 at 15:45

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.