From d038b36c8f814e518c64b608b51a551186c5440e Mon Sep 17 00:00:00 2001 From: David Shaw Date: Tue, 21 Feb 2006 22:23:35 +0000 Subject: [PATCH] * getkey.c (get_pubkey_byname): Fix minor security problem with PKA when importing at -r time. The URL in the PKA record may point to a key put in by an attacker. Fix is to use the fingerprint from the PKA record as the recipient. This ensures that the PKA record is followed. * keyserver-internal.h, keyserver.c (keyserver_import_pka): Return the fingerprint we requested. --- g10/ChangeLog | 9 +++++++++ g10/getkey.c | 15 ++++++++++++++- g10/gpgv.c | 2 +- g10/keyserver-internal.h | 2 +- g10/keyserver.c | 5 ++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 7162a1556..7ae181d9f 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,14 @@ 2006-02-21 David Shaw + * getkey.c (get_pubkey_byname): Fix minor security problem with + PKA when importing at -r time. The URL in the PKA record may + point to a key put in by an attacker. Fix is to use the + fingerprint from the PKA record as the recipient. This ensures + that the PKA record is followed. + + * keyserver-internal.h, keyserver.c (keyserver_import_pka): Return + the fingerprint we requested. + * gpgv.c: Stub keyserver_import_ldap. * keyserver-internal.h, keyserver.c (keyserver_import_ldap): diff --git a/g10/getkey.c b/g10/getkey.c index d247b3bcb..8ec1e52d1 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -938,6 +938,7 @@ get_pubkey_byname (PKT_public_key *pk, && opt.allow_pka_lookup && (opt.keyserver_options.options&KEYSERVER_AUTO_PKA_RETRIEVE)) { + unsigned char fpr[MAX_FINGERPRINT_LEN]; /* If the requested name resembles a valid mailbox and automatic retrieval via PKA records has been enabled, we try to import the key via the URI and try again. */ @@ -945,13 +946,25 @@ get_pubkey_byname (PKT_public_key *pk, tried_pka=1; glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_pka(name); + res=keyserver_import_pka(name,fpr); glo_ctrl.in_auto_key_retrieve--; if(res==0) { + int i; + char fpr_string[2+(MAX_FINGERPRINT_LEN*2)+1]; + log_info(_("Automatically retrieved `%s' via %s\n"), name,"PKA"); + + free_strlist(namelist); + namelist=NULL; + + for(i=0;i