Skip to content

Commit

Permalink
Prevent use of invalid local TGT key
Browse files Browse the repository at this point in the history
Commit 570967e took a shortcut in
get_local_tgt() by using the first key data entry in the TGT principal
entry.  This is usually correct, but if the first key data entry has
an invalid enctype (such as a single-DES enctype), we can select a key
we can't use.  Call krb5_dbe_find_enctype() instead.  Reported by
Leonard Peirce.

(cherry picked from commit d7ed635)

ticket: 8906
version_fixed: 1.18.2
  • Loading branch information
greghudson committed May 21, 2020
1 parent a5d504e commit 32f3659
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/kdc/kdc_util.c
Expand Up @@ -564,6 +564,7 @@ get_local_tgt(krb5_context context, const krb5_data *realm,
krb5_error_code ret;
krb5_principal princ;
krb5_db_entry *storage = NULL, *tgt;
krb5_key_data *kd;

*alias_out = NULL;
*storage_out = NULL;
Expand All @@ -584,12 +585,11 @@ get_local_tgt(krb5_context context, const krb5_data *realm,
tgt = candidate;
}

if (tgt->n_key_data == 0) {
ret = KRB5_KDB_NO_MATCHING_KEY;
/* Find and decrypt the first valid key of the current kvno. */
ret = krb5_dbe_find_enctype(context, tgt, -1, -1, 0, &kd);
if (ret)
goto cleanup;
}
ret = krb5_dbe_decrypt_key_data(context, NULL, &tgt->key_data[0], key_out,
NULL);
ret = krb5_dbe_decrypt_key_data(context, NULL, kd, key_out, NULL);
if (ret)
goto cleanup;

Expand Down

0 comments on commit 32f3659

Please sign in to comment.