Skip to content

Commit

Permalink
CVE-2022-3437 third_party/heimdal: Use constant-time memcmp() for arc…
Browse files Browse the repository at this point in the history
…four unwrap

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15134

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
  • Loading branch information
jsutton24 authored and Jule Anger committed Oct 24, 2022
1 parent 846fbd0 commit 2ee62a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions third_party/heimdal/lib/gssapi/krb5/arcfour.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ _gssapi_verify_mic_arcfour(OM_uint32 * minor_status,
_gsskrb5_decode_be_om_uint32(SND_SEQ, &seq_number);

if (context_handle->more_flags & LOCAL)
cmp = (memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4) != 0);
cmp = (ct_memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4) != 0);
else
cmp = (memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4) != 0);
cmp = (ct_memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4) != 0);

memset_s(SND_SEQ, sizeof(SND_SEQ), 0, sizeof(SND_SEQ));
if (cmp != 0) {
Expand Down Expand Up @@ -659,9 +659,9 @@ OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status,
_gsskrb5_decode_be_om_uint32(SND_SEQ, &seq_number);

if (context_handle->more_flags & LOCAL)
cmp = (memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4) != 0);
cmp = (ct_memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4) != 0);
else
cmp = (memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4) != 0);
cmp = (ct_memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4) != 0);

if (cmp != 0) {
*minor_status = 0;
Expand Down Expand Up @@ -1282,9 +1282,9 @@ _gssapi_unwrap_iov_arcfour(OM_uint32 *minor_status,
_gsskrb5_decode_be_om_uint32(snd_seq, &seq_number);

if (ctx->more_flags & LOCAL) {
cmp = (memcmp(&snd_seq[4], "\xff\xff\xff\xff", 4) != 0);
cmp = (ct_memcmp(&snd_seq[4], "\xff\xff\xff\xff", 4) != 0);
} else {
cmp = (memcmp(&snd_seq[4], "\x00\x00\x00\x00", 4) != 0);
cmp = (ct_memcmp(&snd_seq[4], "\x00\x00\x00\x00", 4) != 0);
}
if (cmp != 0) {
*minor_status = 0;
Expand Down Expand Up @@ -1359,7 +1359,7 @@ _gssapi_unwrap_iov_arcfour(OM_uint32 *minor_status,
return GSS_S_FAILURE;
}

cmp = (memcmp(cksum_data, p0 + 16, 8) != 0); /* SGN_CKSUM */
cmp = (ct_memcmp(cksum_data, p0 + 16, 8) != 0); /* SGN_CKSUM */
if (cmp) {
*minor_status = 0;
return GSS_S_BAD_MIC;
Expand Down

0 comments on commit 2ee62a7

Please sign in to comment.