]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2022-3437 source4/heimdal: Check for overflow in _gsskrb5_get_mech()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 10 Oct 2022 07:33:09 +0000 (20:33 +1300)
committerJule Anger <janger@samba.org>
Mon, 24 Oct 2022 05:27:02 +0000 (07:27 +0200)
If len_len is equal to total_len - 1 (i.e. the input consists only of a
0x60 byte and a length), the expression 'total_len - 1 - len_len - 1',
used as the 'len' parameter to der_get_length(), will overflow to
SIZE_MAX. Then der_get_length() will proceed to read, unconstrained,
whatever data follows in memory. Add a check to ensure that doesn't
happen.

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>
selftest/knownfail.d/heimdal-des-overflow
source4/heimdal/lib/gssapi/krb5/decapsulate.c

index 94a49bbee7fbaae85688727620b26abcd457e555..a7416dc61d98eb72d66adbd9952011c933696ca3 100644 (file)
@@ -1,3 +1,2 @@
-^samba.unittests.auth.heimdal_gensec_unwrap_des.test_unwrap_truncated_header_0.none
 ^samba.unittests.auth.heimdal_gensec_unwrap_des.test_unwrap_with_padding_truncated_0.none
 ^samba.unittests.auth.heimdal_gensec_unwrap_des.test_unwrap_with_padding_truncated_1.none
index 031a621eabc7f0c8f596adc11cc67352047e20e5..d7b75a642224cc17973b3205f4b2726421e78607 100644 (file)
@@ -54,6 +54,8 @@ _gsskrb5_get_mech (const u_char *ptr,
     e = der_get_length (p, total_len - 1, &len, &len_len);
     if (e || 1 + len_len + len != total_len)
        return -1;
+    if (total_len < 1 + len_len + 1)
+       return -1;
     p += len_len;
     if (*p++ != 0x06)
        return -1;