Skip to content

Commit

Permalink
Fix gss-krb5 handling of high sequence numbers
Browse files Browse the repository at this point in the history
Commits abcfdaf and
41ddaae incorrectly changed the
interpretation of authenticator sequence numbers in the range
2^31..2^32-1, mapping them to sign-extended 64-bit values.  The major
Kerberos implementations do not generate sequence numbers this large,
so the changed went unnoticed.  Prevent unwanted sign extension by
casting sequence numbers retrieved from auth contexts to uint32_t
before assigning them to uint64_t fields.  Reported by Jake Scott.

ticket: 8994 (new)
  • Loading branch information
greghudson committed Mar 31, 2021
1 parent ae40b2e commit dac8de0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/gssapi/krb5/accept_sec_context.c
Expand Up @@ -982,7 +982,7 @@ kg_accept_krb5(minor_status, context_handle,
{
krb5_int32 seq_temp;
krb5_auth_con_getremoteseqnumber(context, auth_context, &seq_temp);
ctx->seq_recv = seq_temp;
ctx->seq_recv = (uint32_t)seq_temp;
}

if ((code = krb5_timeofday(context, &now))) {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ kg_accept_krb5(minor_status, context_handle,
}

krb5_auth_con_getlocalseqnumber(context, auth_context, &seq_temp);
ctx->seq_send = seq_temp & 0xffffffffL;
ctx->seq_send = (uint32_t)seq_temp;

if (cfx_generate_subkey) {
/* Get the new acceptor subkey. With the code above, there
Expand Down
2 changes: 1 addition & 1 deletion src/lib/gssapi/krb5/init_sec_context.c
Expand Up @@ -631,7 +631,7 @@ kg_new_connection(
}

krb5_auth_con_getlocalseqnumber(context, ctx->auth_context, &seq_temp);
ctx->seq_send = seq_temp;
ctx->seq_send = (uint32_t)seq_temp;
code = krb5_auth_con_getsendsubkey(context, ctx->auth_context,
&keyblock);
if (code != 0)
Expand Down

0 comments on commit dac8de0

Please sign in to comment.