Skip to content

Commit f96110b

Browse files
committed
krb5: Fix MIT KRB5 Bug #9181
According to https://krbdev.mit.edu/rt/Ticket/Display.html?id=9181, The function verify_mic_v3() in src/lib/gssapi/krb5/verify_mic.c calls kg_verify_checksum_v3() as it returns an OM_uint32 status but kg_verify_checksum_v3() returns a krb5_boolean which has the opposite interpretation: - OM_uint32 0 is GSS_S_COMPLETE so no error - krb5_boolean 0 is false so failure This patch will be in MIT KRB5 1.22.1. Obtained from: Greg Hudson <rt@krbdev.mit.edu> on krbdev.mit.edu ML. Reviewed by: ivy, ngie Differential review: https://reviews.freebsd.org/D51990
1 parent d5f5535 commit f96110b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crypto/krb5/src/lib/gssapi/krb5/util_crypt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,16 @@ kg_verify_checksum_v3(krb5_context context, krb5_key key, krb5_keyusage usage,
322322
uint8_t ckhdr[16];
323323
krb5_boolean valid;
324324

325-
/* Compose an RFC 4121 token header with EC and RRC set to 0. */
325+
/*
326+
* Compose an RFC 4121 token header for the checksum. For a wrap token,
327+
* the EC and RRC fields have the value 0 for the checksum operation,
328+
* regardless of their values in the actual token (RFC 4121 section 4.2.4).
329+
* For a MIC token, the corresponding four bytes have the value 0xFF.
330+
*/
326331
store_16_be(toktype, ckhdr);
327332
ckhdr[2] = flags;
328333
ckhdr[3] = 0xFF;
329-
store_16_be(0, ckhdr + 4);
330-
store_16_be(0, ckhdr + 6);
334+
store_32_be((toktype == KG2_TOK_MIC_MSG) ? 0xFFFFFFFF : 0, ckhdr + 4);
331335
store_64_be(seqnum, ckhdr + 8);
332336

333337
/* Verify the checksum over the data and composed header. */

crypto/krb5/src/lib/gssapi/krb5/verify_mic.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ verify_mic_v3(krb5_context context, OM_uint32 *minor_status,
9090
krb5_gss_ctx_id_rec *ctx, struct k5input *in,
9191
gss_buffer_t message)
9292
{
93-
OM_uint32 status;
9493
krb5_keyusage usage;
9594
krb5_key key;
9695
krb5_cksumtype cksumtype;
@@ -124,12 +123,10 @@ verify_mic_v3(krb5_context context, OM_uint32 *minor_status,
124123
}
125124
assert(key != NULL);
126125

127-
status = kg_verify_checksum_v3(context, key, usage, cksumtype,
128-
KG2_TOK_MIC_MSG, flags, seqnum,
129-
message->value, message->length,
130-
in->ptr, in->len);
131-
if (status != GSS_S_COMPLETE)
132-
return status;
126+
if (!kg_verify_checksum_v3(context, key, usage, cksumtype, KG2_TOK_MIC_MSG,
127+
flags, seqnum, message->value, message->length,
128+
in->ptr, in->len))
129+
return GSS_S_BAD_SIG;
133130

134131
return g_seqstate_check(ctx->seqstate, seqnum);
135132
}

0 commit comments

Comments
 (0)