]> 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:58:23 +0000 (12:58 +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 dbbef9e7a3ce979e15324b969ce4ca436bd8ecbb..64b424c099f01e4d7c836a4b05c6c9b9457aa474 100644 (file)
 #include "../libcli/security/dom_sid.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 82797d453ed670e383424a06fec0a7f7e77f41eb..ad768682b9fd5008d88182237571f02abbe77539 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);