]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_is_random_challenge() to...
authorStefan Metzmacher <metze@samba.org>
Wed, 16 Sep 2020 14:15:26 +0000 (16:15 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 18 Sep 2020 10:45:37 +0000 (12:45 +0200)
This is the check Windows is using, so we won't generate challenges,
which are rejected by Windows DCs (and future Samba DCs).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
libcli/auth/credentials.c
libcli/auth/proto.h

index c79f5e2ce24514fb2608d9d5909b224253dbaab1..dce0a9151e94a5d88d4de9def72424ecdff792b2 100644 (file)
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
+bool netlogon_creds_is_random_challenge(const struct netr_Credential *challenge)
+{
+       /*
+        * If none of the first 5 bytes of the client challenge is unique, the
+        * server MUST fail session-key negotiation without further processing
+        * of the following steps.
+        */
+
+       if (challenge->data[1] == challenge->data[0] &&
+           challenge->data[2] == challenge->data[0] &&
+           challenge->data[3] == challenge->data[0] &&
+           challenge->data[4] == challenge->data[0])
+       {
+               return false;
+       }
+
+       return true;
+}
+
 void netlogon_creds_random_challenge(struct netr_Credential *challenge)
 {
        ZERO_STRUCTP(challenge);
-       generate_random_buffer(challenge->data, sizeof(challenge->data));
+       while (!netlogon_creds_is_random_challenge(challenge)) {
+               generate_random_buffer(challenge->data, sizeof(challenge->data));
+       }
 }
 
 static void netlogon_creds_step_crypt(struct netlogon_creds_CredentialState *creds,
index 19a0e846357e0530f6af5918d83f8f718c991548..51d5deaab2d20f595c989eb1d8c62f8e1db0a251 100644 (file)
@@ -11,6 +11,7 @@
 
 /* The following definitions come from /home/jeremy/src/samba/git/master/source3/../source4/../libcli/auth/credentials.c  */
 
+bool netlogon_creds_is_random_challenge(const struct netr_Credential *challenge);
 void netlogon_creds_random_challenge(struct netr_Credential *challenge);
 
 void netlogon_creds_des_encrypt_LMKey(struct netlogon_creds_CredentialState *creds, struct netr_LMSessionKey *key);