]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2022-3437 source4/heimdal: Use constant-time memcmp() for arcfour unwrap
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 12 Oct 2022 00:57:13 +0000 (13:57 +1300)
committerJule Anger <janger@samba.org>
Mon, 24 Oct 2022 05:27:02 +0000 (07:27 +0200)
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>
[jsutton@samba.org Adapted to small differences in comparisons, and
 removed erroneous duplicate code in conflicting region]

source4/heimdal/lib/gssapi/krb5/arcfour.c

index a61f7686e95db664406368ff470887f7d82e799b..c6b317ff6836298862e46c82bfa861b45ae6b348 100644 (file)
@@ -385,9 +385,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);
+       cmp = ct_memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4);
     else
-       cmp = memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
+       cmp = ct_memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
 
     memset(SND_SEQ, 0, sizeof(SND_SEQ));
     if (cmp != 0) {
@@ -656,9 +656,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);
+       cmp = ct_memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4);
     else
-       cmp = memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
+       cmp = ct_memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
 
     if (cmp != 0) {
        *minor_status = 0;
@@ -1266,19 +1266,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);
+       cmp = ct_memcmp(&snd_seq[4], "\xff\xff\xff\xff", 4);
     } else {
-       cmp = memcmp(&snd_seq[4], "\x00\x00\x00\x00", 4);
-    }
-    if (cmp != 0) {
-       *minor_status = 0;
-       return GSS_S_BAD_MIC;
-    }
-
-    if (ctx->more_flags & LOCAL) {
-       cmp = memcmp(&snd_seq[4], "\xff\xff\xff\xff", 4);
-    } else {
-       cmp = memcmp(&snd_seq[4], "\x00\x00\x00\x00", 4);
+       cmp = ct_memcmp(&snd_seq[4], "\x00\x00\x00\x00", 4);
     }
     if (cmp != 0) {
        *minor_status = 0;
@@ -1353,7 +1343,7 @@ _gssapi_unwrap_iov_arcfour(OM_uint32 *minor_status,
        return GSS_S_FAILURE;
     }
 
-    cmp = memcmp(cksum_data, p0 + 16, 8); /* SGN_CKSUM */
+    cmp = ct_memcmp(cksum_data, p0 + 16, 8); /* SGN_CKSUM */
     if (cmp != 0) {
        *minor_status = 0;
        return GSS_S_BAD_MIC;