update to 4.12.5
This commit is contained in:
parent
37e59746ec
commit
58e362e7a2
@ -1,371 +0,0 @@
|
||||
From 21073bff847fbc41d3dab0a649fa400d8188fa16 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Boukris <iboukris@gmail.com>
|
||||
Date: Sat, 19 Oct 2019 23:48:19 +0300
|
||||
Subject: [PATCH 1/2] smbdes: add des_crypt56_gnutls() using use DES-CBC with
|
||||
zeroed IV
|
||||
|
||||
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
|
||||
---
|
||||
libcli/auth/smbdes.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 47 insertions(+)
|
||||
|
||||
diff --git a/libcli/auth/smbdes.c b/libcli/auth/smbdes.c
|
||||
index 6d9a6dc2ce8..37ede91ad22 100644
|
||||
--- a/libcli/auth/smbdes.c
|
||||
+++ b/libcli/auth/smbdes.c
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "includes.h"
|
||||
#include "libcli/auth/libcli_auth.h"
|
||||
|
||||
+#include <gnutls/gnutls.h>
|
||||
+#include <gnutls/crypto.h>
|
||||
+
|
||||
/* NOTES:
|
||||
|
||||
This code makes no attempt to be fast! In fact, it is a very
|
||||
@@ -273,6 +276,50 @@ static void str_to_key(const uint8_t *str,uint8_t *key)
|
||||
}
|
||||
}
|
||||
|
||||
+static int des_crypt56_gnutls(uint8_t out[8], const uint8_t in[8],
|
||||
+ const uint8_t key_in[7], bool enc)
|
||||
+{
|
||||
+ static uint8_t iv8[8];
|
||||
+ gnutls_datum_t iv = { iv8, 8 };
|
||||
+ gnutls_datum_t key;
|
||||
+ gnutls_cipher_hd_t ctx;
|
||||
+ uint8_t key2[8];
|
||||
+ uint8_t outb[8];
|
||||
+ int ret;
|
||||
+
|
||||
+ memset(out, 0, 8);
|
||||
+
|
||||
+ str_to_key(key_in, key2);
|
||||
+
|
||||
+ key.data = key2;
|
||||
+ key.size = 8;
|
||||
+
|
||||
+ ret = gnutls_global_init();
|
||||
+ if (ret != 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = gnutls_cipher_init(&ctx, GNUTLS_CIPHER_DES_CBC, &key, &iv);
|
||||
+ if (ret != 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(outb, in, 8);
|
||||
+ if (enc) {
|
||||
+ ret = gnutls_cipher_encrypt(ctx, outb, 8);
|
||||
+ } else {
|
||||
+ ret = gnutls_cipher_decrypt(ctx, outb, 8);
|
||||
+ }
|
||||
+
|
||||
+ if (ret == 0) {
|
||||
+ memcpy(out, outb, 8);
|
||||
+ }
|
||||
+
|
||||
+ gnutls_cipher_deinit(ctx);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
basic des crypt using a 56 bit (7 byte) key
|
||||
*/
|
||||
--
|
||||
2.22.0
|
||||
|
||||
|
||||
From 6d6651213f391840e3004ec3b055f8f25be9b360 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Boukris <iboukris@gmail.com>
|
||||
Date: Mon, 21 Oct 2019 20:03:04 +0300
|
||||
Subject: [PATCH 2/2] smbdes: use the new des_crypt56_gnutls()
|
||||
|
||||
and remove builtin DES crypto.
|
||||
|
||||
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
|
||||
---
|
||||
libcli/auth/smbdes.c | 258 +------------------------------------------
|
||||
1 file changed, 1 insertion(+), 257 deletions(-)
|
||||
|
||||
diff --git a/libcli/auth/smbdes.c b/libcli/auth/smbdes.c
|
||||
index 37ede91ad22..7de05b75303 100644
|
||||
--- a/libcli/auth/smbdes.c
|
||||
+++ b/libcli/auth/smbdes.c
|
||||
@@ -26,239 +26,6 @@
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/crypto.h>
|
||||
|
||||
-/* NOTES:
|
||||
-
|
||||
- This code makes no attempt to be fast! In fact, it is a very
|
||||
- slow implementation
|
||||
-
|
||||
- This code is NOT a complete DES implementation. It implements only
|
||||
- the minimum necessary for SMB authentication, as used by all SMB
|
||||
- products (including every copy of Microsoft Windows95 ever sold)
|
||||
-
|
||||
- In particular, it can only do a unchained forward DES pass. This
|
||||
- means it is not possible to use this code for encryption/decryption
|
||||
- of data, instead it is only useful as a "hash" algorithm.
|
||||
-
|
||||
- There is no entry point into this code that allows normal DES operation.
|
||||
-
|
||||
- I believe this means that this code does not come under ITAR
|
||||
- regulations but this is NOT a legal opinion. If you are concerned
|
||||
- about the applicability of ITAR regulations to this code then you
|
||||
- should confirm it for yourself (and maybe let me know if you come
|
||||
- up with a different answer to the one above)
|
||||
-*/
|
||||
-
|
||||
-
|
||||
-static const uint8_t perm1[56] = {57, 49, 41, 33, 25, 17, 9,
|
||||
- 1, 58, 50, 42, 34, 26, 18,
|
||||
- 10, 2, 59, 51, 43, 35, 27,
|
||||
- 19, 11, 3, 60, 52, 44, 36,
|
||||
- 63, 55, 47, 39, 31, 23, 15,
|
||||
- 7, 62, 54, 46, 38, 30, 22,
|
||||
- 14, 6, 61, 53, 45, 37, 29,
|
||||
- 21, 13, 5, 28, 20, 12, 4};
|
||||
-
|
||||
-static const uint8_t perm2[48] = {14, 17, 11, 24, 1, 5,
|
||||
- 3, 28, 15, 6, 21, 10,
|
||||
- 23, 19, 12, 4, 26, 8,
|
||||
- 16, 7, 27, 20, 13, 2,
|
||||
- 41, 52, 31, 37, 47, 55,
|
||||
- 30, 40, 51, 45, 33, 48,
|
||||
- 44, 49, 39, 56, 34, 53,
|
||||
- 46, 42, 50, 36, 29, 32};
|
||||
-
|
||||
-static const uint8_t perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2,
|
||||
- 60, 52, 44, 36, 28, 20, 12, 4,
|
||||
- 62, 54, 46, 38, 30, 22, 14, 6,
|
||||
- 64, 56, 48, 40, 32, 24, 16, 8,
|
||||
- 57, 49, 41, 33, 25, 17, 9, 1,
|
||||
- 59, 51, 43, 35, 27, 19, 11, 3,
|
||||
- 61, 53, 45, 37, 29, 21, 13, 5,
|
||||
- 63, 55, 47, 39, 31, 23, 15, 7};
|
||||
-
|
||||
-static const uint8_t perm4[48] = { 32, 1, 2, 3, 4, 5,
|
||||
- 4, 5, 6, 7, 8, 9,
|
||||
- 8, 9, 10, 11, 12, 13,
|
||||
- 12, 13, 14, 15, 16, 17,
|
||||
- 16, 17, 18, 19, 20, 21,
|
||||
- 20, 21, 22, 23, 24, 25,
|
||||
- 24, 25, 26, 27, 28, 29,
|
||||
- 28, 29, 30, 31, 32, 1};
|
||||
-
|
||||
-static const uint8_t perm5[32] = { 16, 7, 20, 21,
|
||||
- 29, 12, 28, 17,
|
||||
- 1, 15, 23, 26,
|
||||
- 5, 18, 31, 10,
|
||||
- 2, 8, 24, 14,
|
||||
- 32, 27, 3, 9,
|
||||
- 19, 13, 30, 6,
|
||||
- 22, 11, 4, 25};
|
||||
-
|
||||
-
|
||||
-static const uint8_t perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32,
|
||||
- 39, 7, 47, 15, 55, 23, 63, 31,
|
||||
- 38, 6, 46, 14, 54, 22, 62, 30,
|
||||
- 37, 5, 45, 13, 53, 21, 61, 29,
|
||||
- 36, 4, 44, 12, 52, 20, 60, 28,
|
||||
- 35, 3, 43, 11, 51, 19, 59, 27,
|
||||
- 34, 2, 42, 10, 50, 18, 58, 26,
|
||||
- 33, 1, 41, 9, 49, 17, 57, 25};
|
||||
-
|
||||
-
|
||||
-static const uint8_t sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
|
||||
-
|
||||
-static const uint8_t sbox[8][4][16] = {
|
||||
- {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
|
||||
- {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
|
||||
- {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
|
||||
- {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}},
|
||||
-
|
||||
- {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
|
||||
- {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
|
||||
- {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
|
||||
- {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}},
|
||||
-
|
||||
- {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
|
||||
- {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
|
||||
- {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
|
||||
- {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}},
|
||||
-
|
||||
- {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
|
||||
- {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
|
||||
- {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
|
||||
- {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}},
|
||||
-
|
||||
- {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
|
||||
- {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
|
||||
- {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
|
||||
- {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}},
|
||||
-
|
||||
- {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
|
||||
- {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
|
||||
- {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
|
||||
- {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}},
|
||||
-
|
||||
- {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
|
||||
- {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
|
||||
- {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
|
||||
- {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}},
|
||||
-
|
||||
- {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
|
||||
- {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
|
||||
- {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
|
||||
- {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}};
|
||||
-
|
||||
-static void permute(char *out, const char *in, const uint8_t *p, int n)
|
||||
-{
|
||||
- int i;
|
||||
- for (i=0;i<n;i++)
|
||||
- out[i] = in[p[i]-1];
|
||||
-}
|
||||
-
|
||||
-static void lshift(char *d, int count, int n)
|
||||
-{
|
||||
- char out[64];
|
||||
- int i;
|
||||
- for (i=0;i<n;i++)
|
||||
- out[i] = d[(i+count)%n];
|
||||
- for (i=0;i<n;i++)
|
||||
- d[i] = out[i];
|
||||
-}
|
||||
-
|
||||
-static void concat(char *out, char *in1, char *in2, int l1, int l2)
|
||||
-{
|
||||
- while (l1--)
|
||||
- *out++ = *in1++;
|
||||
- while (l2--)
|
||||
- *out++ = *in2++;
|
||||
-}
|
||||
-
|
||||
-static void xor(char *out, char *in1, char *in2, int n)
|
||||
-{
|
||||
- int i;
|
||||
- for (i=0;i<n;i++)
|
||||
- out[i] = in1[i] ^ in2[i];
|
||||
-}
|
||||
-
|
||||
-static void dohash(char *out, char *in, char *key, int forw)
|
||||
-{
|
||||
- int i, j, k;
|
||||
- char pk1[56];
|
||||
- char c[28];
|
||||
- char d[28];
|
||||
- char cd[56];
|
||||
- char ki[16][48];
|
||||
- char pd1[64];
|
||||
- char l[32], r[32];
|
||||
- char rl[64];
|
||||
-
|
||||
- permute(pk1, key, perm1, 56);
|
||||
-
|
||||
- for (i=0;i<28;i++)
|
||||
- c[i] = pk1[i];
|
||||
- for (i=0;i<28;i++)
|
||||
- d[i] = pk1[i+28];
|
||||
-
|
||||
- for (i=0;i<16;i++) {
|
||||
- lshift(c, sc[i], 28);
|
||||
- lshift(d, sc[i], 28);
|
||||
-
|
||||
- concat(cd, c, d, 28, 28);
|
||||
- permute(ki[i], cd, perm2, 48);
|
||||
- }
|
||||
-
|
||||
- permute(pd1, in, perm3, 64);
|
||||
-
|
||||
- for (j=0;j<32;j++) {
|
||||
- l[j] = pd1[j];
|
||||
- r[j] = pd1[j+32];
|
||||
- }
|
||||
-
|
||||
- for (i=0;i<16;i++) {
|
||||
- char er[48];
|
||||
- char erk[48];
|
||||
- char b[8][6];
|
||||
- char cb[32];
|
||||
- char pcb[32];
|
||||
- char r2[32];
|
||||
-
|
||||
- permute(er, r, perm4, 48);
|
||||
-
|
||||
- xor(erk, er, ki[forw ? i : 15 - i], 48);
|
||||
-
|
||||
- for (j=0;j<8;j++)
|
||||
- for (k=0;k<6;k++)
|
||||
- b[j][k] = erk[j*6 + k];
|
||||
-
|
||||
- for (j=0;j<8;j++) {
|
||||
- int m, n;
|
||||
- m = (b[j][0]<<1) | b[j][5];
|
||||
-
|
||||
- n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4];
|
||||
-
|
||||
- for (k=0;k<4;k++)
|
||||
- b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0;
|
||||
- }
|
||||
-
|
||||
- for (j=0;j<8;j++)
|
||||
- for (k=0;k<4;k++)
|
||||
- cb[j*4+k] = b[j][k];
|
||||
- permute(pcb, cb, perm5, 32);
|
||||
-
|
||||
- xor(r2, l, pcb, 32);
|
||||
-
|
||||
- for (j=0;j<32;j++)
|
||||
- l[j] = r[j];
|
||||
-
|
||||
- for (j=0;j<32;j++)
|
||||
- r[j] = r2[j];
|
||||
- }
|
||||
-
|
||||
- concat(rl, r, l, 32, 32);
|
||||
-
|
||||
- permute(out, rl, perm6, 64);
|
||||
-}
|
||||
-
|
||||
static void str_to_key(const uint8_t *str,uint8_t *key)
|
||||
{
|
||||
int i;
|
||||
@@ -325,30 +92,7 @@ static int des_crypt56_gnutls(uint8_t out[8], const uint8_t in[8],
|
||||
*/
|
||||
void des_crypt56(uint8_t out[8], const uint8_t in[8], const uint8_t key[7], int forw)
|
||||
{
|
||||
- int i;
|
||||
- char outb[64];
|
||||
- char inb[64];
|
||||
- char keyb[64];
|
||||
- uint8_t key2[8];
|
||||
-
|
||||
- str_to_key(key, key2);
|
||||
-
|
||||
- for (i=0;i<64;i++) {
|
||||
- inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
|
||||
- keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
|
||||
- outb[i] = 0;
|
||||
- }
|
||||
-
|
||||
- dohash(outb, inb, keyb, forw);
|
||||
-
|
||||
- for (i=0;i<8;i++) {
|
||||
- out[i] = 0;
|
||||
- }
|
||||
-
|
||||
- for (i=0;i<64;i++) {
|
||||
- if (outb[i])
|
||||
- out[i/8] |= (1<<(7-(i%8)));
|
||||
- }
|
||||
+ (void)des_crypt56_gnutls(out, in, key, forw);
|
||||
}
|
||||
|
||||
void E_P16(const uint8_t *p14,uint8_t *p16)
|
||||
--
|
||||
2.22.0
|
||||
|
||||
@ -1,314 +0,0 @@
|
||||
From 3828e798da8e0b44356039dd927f0624d5d182f9 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Boukris <iboukris@gmail.com>
|
||||
Date: Wed, 6 Nov 2019 12:12:55 +0200
|
||||
Subject: [PATCH] Remove DES support if MIT Kerberos version does not support
|
||||
it
|
||||
|
||||
---
|
||||
source3/libads/kerberos_keytab.c | 2 -
|
||||
source3/passdb/machine_account_secrets.c | 36 ------------------
|
||||
source4/auth/kerberos/kerberos.h | 2 +-
|
||||
.../dsdb/samdb/ldb_modules/password_hash.c | 12 ++++++
|
||||
source4/kdc/db-glue.c | 4 +-
|
||||
source4/torture/rpc/remote_pac.c | 37 -------------------
|
||||
testprogs/blackbox/dbcheck-oldrelease.sh | 2 +-
|
||||
testprogs/blackbox/functionalprep.sh | 2 +-
|
||||
.../blackbox/test_export_keytab_heimdal.sh | 16 ++++----
|
||||
.../blackbox/upgradeprovision-oldrelease.sh | 2 +-
|
||||
10 files changed, 26 insertions(+), 89 deletions(-)
|
||||
|
||||
diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c
|
||||
index 97d5535041c..7d193e1a600 100644
|
||||
--- a/source3/libads/kerberos_keytab.c
|
||||
+++ b/source3/libads/kerberos_keytab.c
|
||||
@@ -240,8 +240,6 @@ int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc, bool update_ads)
|
||||
krb5_data password;
|
||||
krb5_kvno kvno;
|
||||
krb5_enctype enctypes[6] = {
|
||||
- ENCTYPE_DES_CBC_CRC,
|
||||
- ENCTYPE_DES_CBC_MD5,
|
||||
#ifdef HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96
|
||||
ENCTYPE_AES128_CTS_HMAC_SHA1_96,
|
||||
#endif
|
||||
diff --git a/source3/passdb/machine_account_secrets.c b/source3/passdb/machine_account_secrets.c
|
||||
index dfc21f295a1..efba80f1474 100644
|
||||
--- a/source3/passdb/machine_account_secrets.c
|
||||
+++ b/source3/passdb/machine_account_secrets.c
|
||||
@@ -1031,7 +1031,6 @@ static int secrets_domain_info_kerberos_keys(struct secrets_domain_info1_passwor
|
||||
krb5_keyblock key;
|
||||
DATA_BLOB aes_256_b = data_blob_null;
|
||||
DATA_BLOB aes_128_b = data_blob_null;
|
||||
- DATA_BLOB des_md5_b = data_blob_null;
|
||||
bool ok;
|
||||
#endif /* HAVE_ADS */
|
||||
DATA_BLOB arc4_b = data_blob_null;
|
||||
@@ -1177,32 +1176,6 @@ static int secrets_domain_info_kerberos_keys(struct secrets_domain_info1_passwor
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
- krb5_ret = smb_krb5_create_key_from_string(krb5_ctx,
|
||||
- NULL,
|
||||
- &salt,
|
||||
- &cleartext_utf8,
|
||||
- ENCTYPE_DES_CBC_MD5,
|
||||
- &key);
|
||||
- if (krb5_ret != 0) {
|
||||
- DBG_ERR("generation of a des-cbc-md5 key failed: %s\n",
|
||||
- smb_get_krb5_error_message(krb5_ctx, krb5_ret, keys));
|
||||
- krb5_free_context(krb5_ctx);
|
||||
- TALLOC_FREE(keys);
|
||||
- TALLOC_FREE(salt_data);
|
||||
- return krb5_ret;
|
||||
- }
|
||||
- des_md5_b = data_blob_talloc(keys,
|
||||
- KRB5_KEY_DATA(&key),
|
||||
- KRB5_KEY_LENGTH(&key));
|
||||
- krb5_free_keyblock_contents(krb5_ctx, &key);
|
||||
- if (des_md5_b.data == NULL) {
|
||||
- DBG_ERR("data_blob_talloc failed for des-cbc-md5.\n");
|
||||
- krb5_free_context(krb5_ctx);
|
||||
- TALLOC_FREE(keys);
|
||||
- TALLOC_FREE(salt_data);
|
||||
- return ENOMEM;
|
||||
- }
|
||||
-
|
||||
krb5_free_context(krb5_ctx);
|
||||
no_kerberos:
|
||||
|
||||
@@ -1227,15 +1200,6 @@ no_kerberos:
|
||||
keys[idx].value = arc4_b;
|
||||
idx += 1;
|
||||
|
||||
-#ifdef HAVE_ADS
|
||||
- if (des_md5_b.length != 0) {
|
||||
- keys[idx].keytype = ENCTYPE_DES_CBC_MD5;
|
||||
- keys[idx].iteration_count = 4096;
|
||||
- keys[idx].value = des_md5_b;
|
||||
- idx += 1;
|
||||
- }
|
||||
-#endif /* HAVE_ADS */
|
||||
-
|
||||
p->salt_data = salt_data;
|
||||
p->default_iteration_count = 4096;
|
||||
p->num_keys = idx;
|
||||
diff --git a/source4/auth/kerberos/kerberos.h b/source4/auth/kerberos/kerberos.h
|
||||
index 2ff9e3868af..1dd63acc838 100644
|
||||
--- a/source4/auth/kerberos/kerberos.h
|
||||
+++ b/source4/auth/kerberos/kerberos.h
|
||||
@@ -50,7 +50,7 @@ struct keytab_container {
|
||||
#define TOK_ID_GSS_GETMIC ((const uint8_t *)"\x01\x01")
|
||||
#define TOK_ID_GSS_WRAP ((const uint8_t *)"\x02\x01")
|
||||
|
||||
-#define ENC_ALL_TYPES (ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5 | \
|
||||
+#define ENC_ALL_TYPES (ENC_RC4_HMAC_MD5 | \
|
||||
ENC_HMAC_SHA1_96_AES128 | ENC_HMAC_SHA1_96_AES256)
|
||||
|
||||
#ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
|
||||
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
|
||||
index 006e35c46d5..f16937c6cab 100644
|
||||
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
|
||||
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
|
||||
@@ -786,6 +786,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io)
|
||||
* create ENCTYPE_DES_CBC_MD5 key out of
|
||||
* the salt and the cleartext password
|
||||
*/
|
||||
+#ifdef SAMBA4_USES_HEIMDAL
|
||||
krb5_ret = smb_krb5_create_key_from_string(io->smb_krb5_context->krb5_context,
|
||||
NULL,
|
||||
&salt,
|
||||
@@ -804,6 +805,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io)
|
||||
KRB5_KEY_DATA(&key),
|
||||
KRB5_KEY_LENGTH(&key));
|
||||
krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key);
|
||||
+#else
|
||||
+ /* MIT has dropped support for DES enctypes, store a random key instead. */
|
||||
+ io->g.des_md5 = data_blob_talloc(io->ac, NULL, 8);
|
||||
+ generate_secret_buffer(io->g.des_md5.data, 8);
|
||||
+#endif
|
||||
if (!io->g.des_md5.data) {
|
||||
return ldb_oom(ldb);
|
||||
}
|
||||
@@ -812,6 +818,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io)
|
||||
* create ENCTYPE_DES_CBC_CRC key out of
|
||||
* the salt and the cleartext password
|
||||
*/
|
||||
+#ifdef SAMBA4_USES_HEIMDAL
|
||||
krb5_ret = smb_krb5_create_key_from_string(io->smb_krb5_context->krb5_context,
|
||||
NULL,
|
||||
&salt,
|
||||
@@ -830,6 +837,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io)
|
||||
KRB5_KEY_DATA(&key),
|
||||
KRB5_KEY_LENGTH(&key));
|
||||
krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key);
|
||||
+#else
|
||||
+ /* MIT has dropped support for DES enctypes, store a random key instead. */
|
||||
+ io->g.des_crc = data_blob_talloc(io->ac, NULL, 8);
|
||||
+ generate_secret_buffer(io->g.des_crc.data, 8);
|
||||
+#endif
|
||||
if (!io->g.des_crc.data) {
|
||||
return ldb_oom(ldb);
|
||||
}
|
||||
diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c
|
||||
index f62a633c6c7..023ae7b580d 100644
|
||||
--- a/source4/kdc/db-glue.c
|
||||
+++ b/source4/kdc/db-glue.c
|
||||
@@ -359,10 +359,10 @@ static krb5_error_code samba_kdc_message2entry_keys(krb5_context context,
|
||||
|
||||
/* If UF_USE_DES_KEY_ONLY has been set, then don't allow use of the newer enc types */
|
||||
if (userAccountControl & UF_USE_DES_KEY_ONLY) {
|
||||
- supported_enctypes = ENC_CRC32|ENC_RSA_MD5;
|
||||
+ supported_enctypes = 0;
|
||||
} else {
|
||||
/* Otherwise, add in the default enc types */
|
||||
- supported_enctypes |= ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5;
|
||||
+ supported_enctypes |= ENC_RC4_HMAC_MD5;
|
||||
}
|
||||
|
||||
/* Is this the krbtgt or a RODC krbtgt */
|
||||
diff --git a/source4/torture/rpc/remote_pac.c b/source4/torture/rpc/remote_pac.c
|
||||
index 7a5cda74b74..f12060e3c8f 100644
|
||||
--- a/source4/torture/rpc/remote_pac.c
|
||||
+++ b/source4/torture/rpc/remote_pac.c
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
#define TEST_MACHINE_NAME_BDC "torturepacbdc"
|
||||
#define TEST_MACHINE_NAME_WKSTA "torturepacwksta"
|
||||
-#define TEST_MACHINE_NAME_WKSTA_DES "torturepacwkdes"
|
||||
#define TEST_MACHINE_NAME_S4U2SELF_BDC "tests4u2selfbdc"
|
||||
#define TEST_MACHINE_NAME_S4U2SELF_WKSTA "tests4u2selfwk"
|
||||
|
||||
@@ -581,39 +580,6 @@ static bool test_PACVerify_workstation_aes(struct torture_context *tctx,
|
||||
NETLOGON_NEG_AUTH2_ADS_FLAGS | NETLOGON_NEG_SUPPORTS_AES);
|
||||
}
|
||||
|
||||
-static bool test_PACVerify_workstation_des(struct torture_context *tctx,
|
||||
- struct dcerpc_pipe *p, struct cli_credentials *credentials, struct test_join *join_ctx)
|
||||
-{
|
||||
- struct samr_SetUserInfo r;
|
||||
- union samr_UserInfo user_info;
|
||||
- struct dcerpc_pipe *samr_pipe = torture_join_samr_pipe(join_ctx);
|
||||
- struct smb_krb5_context *smb_krb5_context;
|
||||
- krb5_error_code ret;
|
||||
-
|
||||
- ret = cli_credentials_get_krb5_context(popt_get_cmdline_credentials(),
|
||||
- tctx->lp_ctx, &smb_krb5_context);
|
||||
- torture_assert_int_equal(tctx, ret, 0, "cli_credentials_get_krb5_context() failed");
|
||||
-
|
||||
- if (smb_krb5_get_allowed_weak_crypto(smb_krb5_context->krb5_context) == FALSE) {
|
||||
- torture_skip(tctx, "Cannot test DES without [libdefaults] allow_weak_crypto = yes");
|
||||
- }
|
||||
-
|
||||
- /* Mark this workstation with DES-only */
|
||||
- user_info.info16.acct_flags = ACB_USE_DES_KEY_ONLY | ACB_WSTRUST;
|
||||
- r.in.user_handle = torture_join_samr_user_policy(join_ctx);
|
||||
- r.in.level = 16;
|
||||
- r.in.info = &user_info;
|
||||
-
|
||||
- torture_assert_ntstatus_ok(tctx, dcerpc_samr_SetUserInfo_r(samr_pipe->binding_handle, tctx, &r),
|
||||
- "failed to set DES info account flags");
|
||||
- torture_assert_ntstatus_ok(tctx, r.out.result,
|
||||
- "failed to set DES into account flags");
|
||||
-
|
||||
- return test_PACVerify(tctx, p, credentials, SEC_CHAN_WKSTA,
|
||||
- TEST_MACHINE_NAME_WKSTA_DES,
|
||||
- NETLOGON_NEG_AUTH2_ADS_FLAGS);
|
||||
-}
|
||||
-
|
||||
#ifdef SAMBA4_USES_HEIMDAL
|
||||
static NTSTATUS check_primary_group_in_validation(TALLOC_CTX *mem_ctx,
|
||||
uint16_t validation_level,
|
||||
@@ -1000,9 +966,6 @@ struct torture_suite *torture_rpc_remote_pac(TALLOC_CTX *mem_ctx)
|
||||
&ndr_table_netlogon, TEST_MACHINE_NAME_WKSTA);
|
||||
torture_rpc_tcase_add_test_creds(tcase, "verify-sig-aes", test_PACVerify_workstation_aes);
|
||||
|
||||
- tcase = torture_suite_add_machine_workstation_rpc_iface_tcase(suite, "netlogon-member-des",
|
||||
- &ndr_table_netlogon, TEST_MACHINE_NAME_WKSTA_DES);
|
||||
- torture_rpc_tcase_add_test_join(tcase, "verify-sig", test_PACVerify_workstation_des);
|
||||
#ifdef SAMBA4_USES_HEIMDAL
|
||||
tcase = torture_suite_add_machine_bdc_rpc_iface_tcase(suite, "netr-bdc-arcfour",
|
||||
&ndr_table_netlogon, TEST_MACHINE_NAME_S4U2SELF_BDC);
|
||||
diff --git a/testprogs/blackbox/dbcheck-oldrelease.sh b/testprogs/blackbox/dbcheck-oldrelease.sh
|
||||
index 3d0ee2c165a..41c55178d4e 100755
|
||||
--- a/testprogs/blackbox/dbcheck-oldrelease.sh
|
||||
+++ b/testprogs/blackbox/dbcheck-oldrelease.sh
|
||||
@@ -388,7 +388,7 @@ referenceprovision() {
|
||||
|
||||
ldapcmp() {
|
||||
if [ x$RELEASE = x"release-4-0-0" ]; then
|
||||
- $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName
|
||||
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName,msDS-SupportedEncryptionTypes
|
||||
fi
|
||||
}
|
||||
|
||||
diff --git a/testprogs/blackbox/functionalprep.sh b/testprogs/blackbox/functionalprep.sh
|
||||
index 80e82252d45..1d37611ef7a 100755
|
||||
--- a/testprogs/blackbox/functionalprep.sh
|
||||
+++ b/testprogs/blackbox/functionalprep.sh
|
||||
@@ -61,7 +61,7 @@ provision_2012r2() {
|
||||
ldapcmp_ignore() {
|
||||
# At some point we will need to ignore, but right now, it should be perfect
|
||||
IGNORE_ATTRS=$1
|
||||
- $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn
|
||||
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn --filter msDS-SupportedEncryptionTypes
|
||||
}
|
||||
|
||||
ldapcmp() {
|
||||
diff --git a/testprogs/blackbox/test_export_keytab_heimdal.sh b/testprogs/blackbox/test_export_keytab_heimdal.sh
|
||||
index cfa245fd4de..6a2595cd684 100755
|
||||
--- a/testprogs/blackbox/test_export_keytab_heimdal.sh
|
||||
+++ b/testprogs/blackbox/test_export_keytab_heimdal.sh
|
||||
@@ -43,7 +43,7 @@ test_keytab() {
|
||||
|
||||
echo "test: $testname"
|
||||
|
||||
- NKEYS=$($VALGRIND $samba4ktutil $keytab | grep -i "$principal" | egrep -c "des|aes|arcfour")
|
||||
+ NKEYS=$($VALGRIND $samba4ktutil $keytab | grep -i "$principal" | egrep -c "aes|arcfour")
|
||||
status=$?
|
||||
if [ x$status != x0 ]; then
|
||||
echo "failure: $testname"
|
||||
@@ -64,22 +64,22 @@ unc="//$SERVER/tmp"
|
||||
testit "create user locally" $VALGRIND $PYTHON $newuser nettestuser $USERPASS $@ || failed=`expr $failed + 1`
|
||||
|
||||
testit "dump keytab from domain" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "read keytab from domain" "$PREFIX/tmpkeytab" "$SERVER\\\$" 5
|
||||
+test_keytab "read keytab from domain" "$PREFIX/tmpkeytab" "$SERVER\\\$" 3
|
||||
testit "dump keytab from domain (2nd time)" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "read keytab from domain (2nd time)" "$PREFIX/tmpkeytab" "$SERVER\\\$" 5
|
||||
+test_keytab "read keytab from domain (2nd time)" "$PREFIX/tmpkeytab" "$SERVER\\\$" 3
|
||||
|
||||
testit "dump keytab from domain for cifs principal" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-server --principal=cifs/$SERVER_FQDN $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "read keytab from domain for cifs principal" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 5
|
||||
+test_keytab "read keytab from domain for cifs principal" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 3
|
||||
testit "dump keytab from domain for cifs principal (2nd time)" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-server --principal=cifs/$SERVER_FQDN $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "read keytab from domain for cifs principal (2nd time)" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 5
|
||||
+test_keytab "read keytab from domain for cifs principal (2nd time)" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 3
|
||||
|
||||
testit "dump keytab from domain for user principal" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=nettestuser $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 5
|
||||
+test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 3
|
||||
testit "dump keytab from domain for user principal (2nd time)" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=nettestuser@$REALM $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "dump keytab from domain for user principal (2nd time)" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 5
|
||||
+test_keytab "dump keytab from domain for user principal (2nd time)" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 3
|
||||
|
||||
testit "dump keytab from domain for user principal with SPN as UPN" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-3 --principal=http/testupnspn.$DNSDOMAIN $@ || failed=`expr $failed + 1`
|
||||
-test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-3" "http/testupnspn.$DNSDOMAIN@$REALM" 5
|
||||
+test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-3" "http/testupnspn.$DNSDOMAIN@$REALM" 3
|
||||
|
||||
KRB5CCNAME="$PREFIX/tmpuserccache"
|
||||
export KRB5CCNAME
|
||||
diff --git a/testprogs/blackbox/upgradeprovision-oldrelease.sh b/testprogs/blackbox/upgradeprovision-oldrelease.sh
|
||||
index 76276168011..208baa54a02 100755
|
||||
--- a/testprogs/blackbox/upgradeprovision-oldrelease.sh
|
||||
+++ b/testprogs/blackbox/upgradeprovision-oldrelease.sh
|
||||
@@ -106,7 +106,7 @@ referenceprovision() {
|
||||
|
||||
ldapcmp() {
|
||||
if [ x$RELEASE != x"alpha13" ]; then
|
||||
- $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName
|
||||
+ $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/${RELEASE}_upgrade_reference/private/sam.ldb tdb://$PREFIX_ABS/${RELEASE}_upgrade/private/sam.ldb --two --skip-missing-dn --filter=dnsRecord,displayName,msDS-SupportedEncryptionTypes
|
||||
fi
|
||||
}
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
From 5a084994144704a6c146b94f8a22cf57ce08deab Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Bokovoy <ab@samba.org>
|
||||
Date: Mon, 7 Oct 2019 18:24:28 +0300
|
||||
Subject: [PATCH] samba-tool: create working private krb5.conf
|
||||
|
||||
DNS update tool uses private krb5.conf which should have enough details
|
||||
to authenticate with GSS-TSIG when running nsupdate.
|
||||
|
||||
Unfortunately, the configuration we provide is not enough. We set
|
||||
defaults to not lookup REALM via DNS but at the same time we don't
|
||||
provide any realm definition. As result, MIT Kerberos cannot actually
|
||||
find a working realm for Samba AD deployment because it cannot query DNS
|
||||
for a realm discovery or pick it up from the configuration.
|
||||
|
||||
Extend private krb5.conf with a realm definition that will allow MIT
|
||||
Kerberos to look up KDC over DNS.
|
||||
|
||||
Signed-off-by: Alexander Bokovoy <ab@samba.org>
|
||||
Reviewed-by: Andreas Schneider <asn@samba.org>
|
||||
---
|
||||
source4/setup/krb5.conf | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/source4/setup/krb5.conf b/source4/setup/krb5.conf
|
||||
index b1bf6cf907d..ad6f2818fb5 100644
|
||||
--- a/source4/setup/krb5.conf
|
||||
+++ b/source4/setup/krb5.conf
|
||||
@@ -2,3 +2,11 @@
|
||||
default_realm = ${REALM}
|
||||
dns_lookup_realm = false
|
||||
dns_lookup_kdc = true
|
||||
+
|
||||
+[realms]
|
||||
+${REALM} = {
|
||||
+ default_domain = ${DNSDOMAIN}
|
||||
+}
|
||||
+
|
||||
+[domain_realm]
|
||||
+ ${HOSTNAME} = ${REALM}
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -1,222 +0,0 @@
|
||||
From 0e77fa7747d789bd8c9256373498a352251f6877 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Bartlett <abartlet@samba.org>
|
||||
Date: Mon, 30 Mar 2020 09:44:20 +0000
|
||||
Subject: [PATCH 1/4] CVE-2020-10700: dsdb: Add test for ASQ and ASQ in
|
||||
combination with paged_results
|
||||
|
||||
Thanks to Andrei Popa <andrei.popa@next-gen.ro> for finding,
|
||||
reporting and working with us to diagnose this issue!
|
||||
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14331
|
||||
|
||||
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
||||
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
---
|
||||
selftest/knownfail.d/asq | 1 +
|
||||
source4/dsdb/tests/python/asq.py | 171 +++++++++++++++++++++++++++++++
|
||||
source4/selftest/tests.py | 1 +
|
||||
3 files changed, 173 insertions(+)
|
||||
create mode 100644 selftest/knownfail.d/asq
|
||||
create mode 100644 source4/dsdb/tests/python/asq.py
|
||||
|
||||
diff --git a/selftest/knownfail.d/asq b/selftest/knownfail.d/asq
|
||||
new file mode 100644
|
||||
index 00000000000..eb0e3e0aba1
|
||||
--- /dev/null
|
||||
+++ b/selftest/knownfail.d/asq
|
||||
@@ -0,0 +1 @@
|
||||
+samba4.asq.python\(ad_dc_default\).__main__.ASQLDAPTest.test_asq_paged
|
||||
\ No newline at end of file
|
||||
diff --git a/source4/dsdb/tests/python/asq.py b/source4/dsdb/tests/python/asq.py
|
||||
new file mode 100644
|
||||
index 00000000000..a32c9f40cd3
|
||||
--- /dev/null
|
||||
+++ b/source4/dsdb/tests/python/asq.py
|
||||
@@ -0,0 +1,171 @@
|
||||
+#!/usr/bin/env python3
|
||||
+#
|
||||
+# Test ASQ LDAP control behaviour in Samba
|
||||
+# Copyright (C) Andrew Bartlett 2019-2020
|
||||
+#
|
||||
+# Based on Unit tests for the notification control
|
||||
+# Copyright (C) Stefan Metzmacher 2016
|
||||
+#
|
||||
+# This program is free software; you can redistribute it and/or modify
|
||||
+# it under the terms of the GNU General Public License as published by
|
||||
+# the Free Software Foundation; either version 3 of the License, or
|
||||
+# (at your option) any later version.
|
||||
+#
|
||||
+# This program is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+# GNU General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+import optparse
|
||||
+import sys
|
||||
+import os
|
||||
+import random
|
||||
+
|
||||
+sys.path.insert(0, "bin/python")
|
||||
+import samba
|
||||
+from samba.tests.subunitrun import SubunitOptions, TestProgram
|
||||
+
|
||||
+import samba.getopt as options
|
||||
+
|
||||
+from samba.auth import system_session
|
||||
+from samba import ldb
|
||||
+from samba.samdb import SamDB
|
||||
+from samba.ndr import ndr_unpack
|
||||
+from samba import gensec
|
||||
+from samba.credentials import Credentials
|
||||
+import samba.tests
|
||||
+
|
||||
+from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError
|
||||
+from ldb import ERR_TIME_LIMIT_EXCEEDED, ERR_ADMIN_LIMIT_EXCEEDED, ERR_UNWILLING_TO_PERFORM
|
||||
+from ldb import Message
|
||||
+
|
||||
+parser = optparse.OptionParser("large_ldap.py [options] <host>")
|
||||
+sambaopts = options.SambaOptions(parser)
|
||||
+parser.add_option_group(sambaopts)
|
||||
+parser.add_option_group(options.VersionOptions(parser))
|
||||
+# use command line creds if available
|
||||
+credopts = options.CredentialsOptions(parser)
|
||||
+parser.add_option_group(credopts)
|
||||
+subunitopts = SubunitOptions(parser)
|
||||
+parser.add_option_group(subunitopts)
|
||||
+opts, args = parser.parse_args()
|
||||
+
|
||||
+if len(args) < 1:
|
||||
+ parser.print_usage()
|
||||
+ sys.exit(1)
|
||||
+
|
||||
+url = args[0]
|
||||
+
|
||||
+lp = sambaopts.get_loadparm()
|
||||
+creds = credopts.get_credentials(lp)
|
||||
+
|
||||
+
|
||||
+class ASQLDAPTest(samba.tests.TestCase):
|
||||
+
|
||||
+ def setUp(self):
|
||||
+ super(ASQLDAPTest, self).setUp()
|
||||
+ self.ldb = samba.Ldb(url, credentials=creds, session_info=system_session(lp), lp=lp)
|
||||
+ self.base_dn = self.ldb.get_default_basedn()
|
||||
+ self.NAME_ASQ="asq_" + format(random.randint(0, 99999), "05")
|
||||
+ self.OU_NAME_ASQ= self.NAME_ASQ + "_ou"
|
||||
+ self.ou_dn = ldb.Dn(self.ldb, "ou=" + self.OU_NAME_ASQ + "," + str(self.base_dn))
|
||||
+
|
||||
+ samba.tests.delete_force(self.ldb, self.ou_dn,
|
||||
+ controls=['tree_delete:1'])
|
||||
+
|
||||
+ self.ldb.add({
|
||||
+ "dn": self.ou_dn,
|
||||
+ "objectclass": "organizationalUnit",
|
||||
+ "ou": self.OU_NAME_ASQ})
|
||||
+
|
||||
+ self.members = []
|
||||
+ self.members2 = []
|
||||
+
|
||||
+ for x in range(20):
|
||||
+ name = self.NAME_ASQ + "_" + str(x)
|
||||
+ dn = ldb.Dn(self.ldb,
|
||||
+ "cn=" + name + "," + str(self.ou_dn))
|
||||
+ self.members.append(dn)
|
||||
+ self.ldb.add({
|
||||
+ "dn": dn,
|
||||
+ "objectclass": "group"})
|
||||
+
|
||||
+ for x in range(20):
|
||||
+ name = self.NAME_ASQ + "_" + str(x + 20)
|
||||
+ dn = ldb.Dn(self.ldb,
|
||||
+ "cn=" + name + "," + str(self.ou_dn))
|
||||
+ self.members2.append(dn)
|
||||
+ self.ldb.add({
|
||||
+ "dn": dn,
|
||||
+ "objectclass": "group",
|
||||
+ "member": [str(x) for x in self.members]})
|
||||
+
|
||||
+ name = self.NAME_ASQ + "_" + str(x + 40)
|
||||
+ self.top_dn = ldb.Dn(self.ldb,
|
||||
+ "cn=" + name + "," + str(self.ou_dn))
|
||||
+ self.ldb.add({
|
||||
+ "dn": self.top_dn,
|
||||
+ "objectclass": "group",
|
||||
+ "member": [str(x) for x in self.members2]})
|
||||
+
|
||||
+ def tearDown(self):
|
||||
+ samba.tests.delete_force(self.ldb, self.ou_dn,
|
||||
+ controls=['tree_delete:1'])
|
||||
+
|
||||
+ def test_asq(self):
|
||||
+ """Testing ASQ behaviour.
|
||||
+
|
||||
+ ASQ is very strange, it turns a BASE search into a search for
|
||||
+ all the objects pointed to by the specified attribute,
|
||||
+ returning multiple entries!
|
||||
+
|
||||
+ """
|
||||
+
|
||||
+ msgs = self.ldb.search(base=self.top_dn,
|
||||
+ scope=ldb.SCOPE_BASE,
|
||||
+ attrs=["objectGUID", "cn", "member"],
|
||||
+ controls=["asq:1:member"])
|
||||
+
|
||||
+ self.assertEqual(len(msgs), 20)
|
||||
+
|
||||
+ for msg in msgs:
|
||||
+ self.assertNotEqual(msg.dn, self.top_dn)
|
||||
+ self.assertIn(msg.dn, self.members2)
|
||||
+ for group in msg["member"]:
|
||||
+ self.assertIn(ldb.Dn(self.ldb, str(group)),
|
||||
+ self.members)
|
||||
+
|
||||
+ def test_asq_paged(self):
|
||||
+ """Testing ASQ behaviour with paged_results set.
|
||||
+
|
||||
+ ASQ is very strange, it turns a BASE search into a search for
|
||||
+ all the objects pointed to by the specified attribute,
|
||||
+ returning multiple entries!
|
||||
+
|
||||
+ """
|
||||
+
|
||||
+ msgs = self.ldb.search(base=self.top_dn,
|
||||
+ scope=ldb.SCOPE_BASE,
|
||||
+ attrs=["objectGUID", "cn", "member"],
|
||||
+ controls=["asq:1:member",
|
||||
+ "paged_results:1:1024"])
|
||||
+
|
||||
+ self.assertEqual(len(msgs), 20)
|
||||
+
|
||||
+ for msg in msgs:
|
||||
+ self.assertNotEqual(msg.dn, self.top_dn)
|
||||
+ self.assertIn(msg.dn, self.members2)
|
||||
+ for group in msg["member"]:
|
||||
+ self.assertIn(ldb.Dn(self.ldb, str(group)),
|
||||
+ self.members)
|
||||
+
|
||||
+if "://" not in url:
|
||||
+ if os.path.isfile(url):
|
||||
+ url = "tdb://%s" % url
|
||||
+ else:
|
||||
+ url = "ldap://%s" % url
|
||||
+
|
||||
+TestProgram(module=__name__, opts=subunitopts)
|
||||
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
|
||||
index ae2b10ae659..52db18a872b 100755
|
||||
--- a/source4/selftest/tests.py
|
||||
+++ b/source4/selftest/tests.py
|
||||
@@ -885,6 +885,7 @@ plantestsuite_loadlist("samba4.tokengroups.krb5.python(ad_dc_default)", "ad_dc_d
|
||||
plantestsuite_loadlist("samba4.tokengroups.ntlm.python(ad_dc_default)", "ad_dc_default:local", [python, os.path.join(DSDB_PYTEST_DIR, "token_group.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN', '-k', 'no', '$LOADLIST', '$LISTOPT'])
|
||||
plantestsuite("samba4.sam.python(fl2008r2dc)", "fl2008r2dc", [python, os.path.join(DSDB_PYTEST_DIR, "sam.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
|
||||
plantestsuite("samba4.sam.python(ad_dc_default)", "ad_dc_default", [python, os.path.join(DSDB_PYTEST_DIR, "sam.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
|
||||
+plantestsuite("samba4.asq.python(ad_dc_default)", "ad_dc_default", [python, os.path.join(DSDB_PYTEST_DIR, "asq.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
|
||||
plantestsuite("samba4.user_account_control.python(ad_dc_default)", "ad_dc_default", [python, os.path.join(DSDB_PYTEST_DIR, "user_account_control.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN'])
|
||||
|
||||
for env in ['ad_dc_default:local', 'schema_dc:local']:
|
||||
--
|
||||
2.17.1
|
||||
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
From 34f9e6e969913629f9241522020c5895dc9636dc Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Bartlett <abartlet@samba.org>
|
||||
Date: Wed, 11 Mar 2020 16:43:31 +1300
|
||||
Subject: [PATCH 3/4] CVE-2020-10700: dsdb: Do not permit the ASQ control for
|
||||
the GUID search in paged_results
|
||||
|
||||
ASQ is a very strange control and a BASE search can return multiple results
|
||||
that are NOT the requested DN, but the DNs pointed to by it!
|
||||
|
||||
Thanks to Andrei Popa <andrei.popa@next-gen.ro> for finding,
|
||||
reporting and working with us to diagnose this issue!
|
||||
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14331
|
||||
|
||||
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
||||
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
---
|
||||
selftest/knownfail.d/asq | 1 -
|
||||
source4/dsdb/samdb/ldb_modules/paged_results.c | 18 +++++++++++++-----
|
||||
2 files changed, 13 insertions(+), 6 deletions(-)
|
||||
delete mode 100644 selftest/knownfail.d/asq
|
||||
|
||||
diff --git a/selftest/knownfail.d/asq b/selftest/knownfail.d/asq
|
||||
deleted file mode 100644
|
||||
index eb0e3e0aba1..00000000000
|
||||
--- a/selftest/knownfail.d/asq
|
||||
+++ /dev/null
|
||||
@@ -1 +0,0 @@
|
||||
-samba4.asq.python\(ad_dc_default\).__main__.ASQLDAPTest.test_asq_paged
|
||||
\ No newline at end of file
|
||||
diff --git a/source4/dsdb/samdb/ldb_modules/paged_results.c b/source4/dsdb/samdb/ldb_modules/paged_results.c
|
||||
index 940d2254fb0..dc211dd18ce 100644
|
||||
--- a/source4/dsdb/samdb/ldb_modules/paged_results.c
|
||||
+++ b/source4/dsdb/samdb/ldb_modules/paged_results.c
|
||||
@@ -483,8 +483,14 @@ paged_results_copy_down_controls(TALLOC_CTX *mem_ctx,
|
||||
if (control->oid == NULL) {
|
||||
continue;
|
||||
}
|
||||
- if (strncmp(control->oid, LDB_CONTROL_PAGED_RESULTS_OID,
|
||||
- sizeof(LDB_CONTROL_PAGED_RESULTS_OID)) == 0) {
|
||||
+ if (strcmp(control->oid, LDB_CONTROL_PAGED_RESULTS_OID) == 0) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ /*
|
||||
+ * ASQ changes everything, do not copy it down for the
|
||||
+ * per-GUID search
|
||||
+ */
|
||||
+ if (strcmp(control->oid, LDB_CONTROL_ASQ_OID) == 0) {
|
||||
continue;
|
||||
}
|
||||
new_controls[j] = talloc_steal(new_controls, control);
|
||||
@@ -534,21 +540,23 @@ static bool paged_controls_same(struct ldb_request *req,
|
||||
|
||||
num_non_null_req_controls = 0;
|
||||
for (i=0; req->controls[i] != NULL; i++) {
|
||||
- if (req->controls[i]->oid != NULL) {
|
||||
+ if (req->controls[i]->oid != NULL &&
|
||||
+ strcmp(req->controls[i]->oid,
|
||||
+ LDB_CONTROL_ASQ_OID) != 0) {
|
||||
num_non_null_req_controls++;
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point we have the number of non-null entries for both
|
||||
* control lists and we know that:
|
||||
- * 1. down_controls does not contain the paged control
|
||||
+ * 1. down_controls does not contain the paged control or ASQ
|
||||
* (because paged_results_copy_down_controls excludes it)
|
||||
* 2. req->controls does contain the paged control
|
||||
* (because this function is only called if this is true)
|
||||
* 3. down_controls is a subset of non-null controls in req->controls
|
||||
* (checked above)
|
||||
* So to confirm that the two lists are identical except for the paged
|
||||
- * control, all we need to check is: */
|
||||
+ * control and possibly ASQ, all we need to check is: */
|
||||
if (num_non_null_req_controls == num_down_controls + 1) {
|
||||
return true;
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
||||
|
||||
@ -1,547 +0,0 @@
|
||||
From b01952c6fb15b92fff3ad1bf8f1cf579875e5483 Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Fri, 3 Apr 2020 12:18:03 +1300
|
||||
Subject: [PATCH 1/8] CVE-2020-10704: lib util asn1: Add ASN.1 max tree depth
|
||||
|
||||
Add maximum parse tree depth to the call to asn1_init, which will be
|
||||
used to limit the depth of the ASN.1 parse tree.
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
auth/gensec/gensec_util.c | 2 +-
|
||||
lib/util/asn1.c | 17 +++++++++-
|
||||
lib/util/asn1.h | 9 +++++-
|
||||
lib/util/tests/asn1_tests.c | 2 +-
|
||||
libcli/auth/spnego_parse.c | 6 ++--
|
||||
libcli/cldap/cldap.c | 2 +-
|
||||
libcli/ldap/ldap_message.c | 2 +-
|
||||
source3/lib/tldap.c | 4 +--
|
||||
source3/lib/tldap_util.c | 4 +--
|
||||
source3/libsmb/clispnego.c | 4 +--
|
||||
source3/torture/torture.c | 2 +-
|
||||
source4/auth/gensec/gensec_krb5.c | 4 +--
|
||||
source4/ldap_server/ldap_server.c | 2 +-
|
||||
source4/libcli/ldap/ldap_client.c | 2 +-
|
||||
source4/libcli/ldap/ldap_controls.c | 48 ++++++++++++++---------------
|
||||
15 files changed, 66 insertions(+), 44 deletions(-)
|
||||
|
||||
diff --git a/auth/gensec/gensec_util.c b/auth/gensec/gensec_util.c
|
||||
index 20c9c2a1fbb..e185acc0c20 100644
|
||||
--- a/auth/gensec/gensec_util.c
|
||||
+++ b/auth/gensec/gensec_util.c
|
||||
@@ -76,7 +76,7 @@ NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx,
|
||||
static bool gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
|
||||
{
|
||||
bool ret = false;
|
||||
- struct asn1_data *data = asn1_init(NULL);
|
||||
+ struct asn1_data *data = asn1_init(NULL, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
|
||||
index 51da5424956..ec6e674ce20 100644
|
||||
--- a/lib/util/asn1.c
|
||||
+++ b/lib/util/asn1.c
|
||||
@@ -36,15 +36,19 @@ struct asn1_data {
|
||||
off_t ofs;
|
||||
struct nesting *nesting;
|
||||
bool has_error;
|
||||
+ unsigned depth;
|
||||
+ unsigned max_depth;
|
||||
};
|
||||
|
||||
/* allocate an asn1 structure */
|
||||
-struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx)
|
||||
+struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx, unsigned max_depth)
|
||||
{
|
||||
struct asn1_data *ret = talloc_zero(mem_ctx, struct asn1_data);
|
||||
if (ret == NULL) {
|
||||
DEBUG(0,("asn1_init failed! out of memory\n"));
|
||||
+ return ret;
|
||||
}
|
||||
+ ret->max_depth = max_depth;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -480,6 +484,11 @@ bool asn1_check_BOOLEAN(struct asn1_data *data, bool v)
|
||||
/* load a struct asn1_data structure with a lump of data, ready to be parsed */
|
||||
bool asn1_load(struct asn1_data *data, DATA_BLOB blob)
|
||||
{
|
||||
+ /*
|
||||
+ * Save the maximum depth
|
||||
+ */
|
||||
+ unsigned max_depth = data->max_depth;
|
||||
+
|
||||
ZERO_STRUCTP(data);
|
||||
data->data = (uint8_t *)talloc_memdup(data, blob.data, blob.length);
|
||||
if (!data->data) {
|
||||
@@ -487,6 +496,7 @@ bool asn1_load(struct asn1_data *data, DATA_BLOB blob)
|
||||
return false;
|
||||
}
|
||||
data->length = blob.length;
|
||||
+ data->max_depth = max_depth;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1103,9 +1113,14 @@ bool asn1_extract_blob(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
|
||||
*/
|
||||
void asn1_load_nocopy(struct asn1_data *data, uint8_t *buf, size_t len)
|
||||
{
|
||||
+ /*
|
||||
+ * Save max_depth
|
||||
+ */
|
||||
+ unsigned max_depth = data->max_depth;
|
||||
ZERO_STRUCTP(data);
|
||||
data->data = buf;
|
||||
data->length = len;
|
||||
+ data->max_depth = max_depth;
|
||||
}
|
||||
|
||||
int asn1_peek_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size)
|
||||
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
|
||||
index ddd69863574..fc365724e93 100644
|
||||
--- a/lib/util/asn1.h
|
||||
+++ b/lib/util/asn1.h
|
||||
@@ -45,7 +45,14 @@ typedef struct asn1_data ASN1_DATA;
|
||||
|
||||
#define ASN1_MAX_OIDS 20
|
||||
|
||||
-struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx);
|
||||
+/*
|
||||
+ * The maximum permitted depth for an ASN.1 parse tree, the limit is chosen
|
||||
+ * to align with the value for windows. Note that this value will trigger
|
||||
+ * ASAN stack overflow errors.
|
||||
+ */
|
||||
+#define ASN1_MAX_TREE_DEPTH 512
|
||||
+
|
||||
+struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx, unsigned max_depth);
|
||||
void asn1_free(struct asn1_data *data);
|
||||
bool asn1_has_error(const struct asn1_data *data);
|
||||
void asn1_set_error(struct asn1_data *data);
|
||||
diff --git a/lib/util/tests/asn1_tests.c b/lib/util/tests/asn1_tests.c
|
||||
index e4b386ad785..ab5262c4ffb 100644
|
||||
--- a/lib/util/tests/asn1_tests.c
|
||||
+++ b/lib/util/tests/asn1_tests.c
|
||||
@@ -330,7 +330,7 @@ static bool test_asn1_Integer(struct torture_context *tctx)
|
||||
DATA_BLOB blob;
|
||||
int val;
|
||||
|
||||
- data = asn1_init(mem_ctx);
|
||||
+ data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
if (!data) {
|
||||
goto err;
|
||||
}
|
||||
diff --git a/libcli/auth/spnego_parse.c b/libcli/auth/spnego_parse.c
|
||||
index f538b44552c..f7f19b10778 100644
|
||||
--- a/libcli/auth/spnego_parse.c
|
||||
+++ b/libcli/auth/spnego_parse.c
|
||||
@@ -296,7 +296,7 @@ ssize_t spnego_read_data(TALLOC_CTX *mem_ctx, DATA_BLOB data, struct spnego_data
|
||||
return ret;
|
||||
}
|
||||
|
||||
- asn1 = asn1_init(mem_ctx);
|
||||
+ asn1 = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
if (asn1 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ ssize_t spnego_read_data(TALLOC_CTX *mem_ctx, DATA_BLOB data, struct spnego_data
|
||||
|
||||
ssize_t spnego_write_data(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct spnego_data *spnego)
|
||||
{
|
||||
- struct asn1_data *asn1 = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *asn1 = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
ssize_t ret = -1;
|
||||
|
||||
if (asn1 == NULL) {
|
||||
@@ -411,7 +411,7 @@ bool spnego_write_mech_types(TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *blob)
|
||||
{
|
||||
bool ret = false;
|
||||
- struct asn1_data *asn1 = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *asn1 = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (asn1 == NULL) {
|
||||
return false;
|
||||
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
|
||||
index daba37a21d7..8fa9ce0b273 100644
|
||||
--- a/libcli/cldap/cldap.c
|
||||
+++ b/libcli/cldap/cldap.c
|
||||
@@ -229,7 +229,7 @@ static bool cldap_socket_recv_dgram(struct cldap_socket *c,
|
||||
goto error;
|
||||
}
|
||||
|
||||
- asn1 = asn1_init(in);
|
||||
+ asn1 = asn1_init(in, ASN1_MAX_TREE_DEPTH);
|
||||
if (!asn1) {
|
||||
goto nomem;
|
||||
}
|
||||
diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c
|
||||
index f21598374a1..ba82bddeab1 100644
|
||||
--- a/libcli/ldap/ldap_message.c
|
||||
+++ b/libcli/ldap/ldap_message.c
|
||||
@@ -390,7 +390,7 @@ _PUBLIC_ bool ldap_encode(struct ldap_message *msg,
|
||||
const struct ldap_control_handler *control_handlers,
|
||||
DATA_BLOB *result, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
int i, j;
|
||||
|
||||
if (!data) return false;
|
||||
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
|
||||
index d6c6e8859a6..bf5fc05d785 100644
|
||||
--- a/source3/lib/tldap.c
|
||||
+++ b/source3/lib/tldap.c
|
||||
@@ -632,7 +632,7 @@ static void tldap_msg_received(struct tevent_req *subreq)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- data = asn1_init(talloc_tos());
|
||||
+ data = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
|
||||
if (data == NULL) {
|
||||
status = TLDAP_NO_MEMORY;
|
||||
goto fail;
|
||||
@@ -763,7 +763,7 @@ static struct tevent_req *tldap_req_create(TALLOC_CTX *mem_ctx,
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
- state->out = asn1_init(state);
|
||||
+ state->out = asn1_init(state, ASN1_MAX_TREE_DEPTH);
|
||||
if (state->out == NULL) {
|
||||
goto err;
|
||||
}
|
||||
diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c
|
||||
index 1b86962a32e..168932a8a96 100644
|
||||
--- a/source3/lib/tldap_util.c
|
||||
+++ b/source3/lib/tldap_util.c
|
||||
@@ -644,7 +644,7 @@ static struct tevent_req *tldap_ship_paged_search(
|
||||
struct tldap_control *pgctrl;
|
||||
struct asn1_data *asn1 = NULL;
|
||||
|
||||
- asn1 = asn1_init(state);
|
||||
+ asn1 = asn1_init(state, ASN1_MAX_TREE_DEPTH);
|
||||
if (asn1 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -783,7 +783,7 @@ static void tldap_search_paged_done(struct tevent_req *subreq)
|
||||
|
||||
TALLOC_FREE(state->cookie.data);
|
||||
|
||||
- asn1 = asn1_init(talloc_tos());
|
||||
+ asn1 = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
|
||||
if (tevent_req_nomem(asn1, req)) {
|
||||
return;
|
||||
}
|
||||
diff --git a/source3/libsmb/clispnego.c b/source3/libsmb/clispnego.c
|
||||
index 4a0fbcd73af..1608f6a9960 100644
|
||||
--- a/source3/libsmb/clispnego.c
|
||||
+++ b/source3/libsmb/clispnego.c
|
||||
@@ -50,7 +50,7 @@ bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
|
||||
*secblob = data_blob_null;
|
||||
}
|
||||
|
||||
- data = asn1_init(talloc_tos());
|
||||
+ data = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
|
||||
if (data == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ DATA_BLOB spnego_gen_krb5_wrap(TALLOC_CTX *ctx, const DATA_BLOB ticket, const ui
|
||||
ASN1_DATA *data;
|
||||
DATA_BLOB ret = data_blob_null;
|
||||
|
||||
- data = asn1_init(talloc_tos());
|
||||
+ data = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
|
||||
if (data == NULL) {
|
||||
return data_blob_null;
|
||||
}
|
||||
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
|
||||
index a795e61125f..c4b0a7bc4f9 100644
|
||||
--- a/source3/torture/torture.c
|
||||
+++ b/source3/torture/torture.c
|
||||
@@ -11370,7 +11370,7 @@ tldap_build_extended_control(enum tldap_extended_val val)
|
||||
ZERO_STRUCT(empty_control);
|
||||
|
||||
if (val != EXTENDED_NONE) {
|
||||
- data = asn1_init(talloc_tos());
|
||||
+ data = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) {
|
||||
return NULL;
|
||||
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
|
||||
index 0323da87d29..b735063656a 100644
|
||||
--- a/source4/auth/gensec/gensec_krb5.c
|
||||
+++ b/source4/auth/gensec/gensec_krb5.c
|
||||
@@ -444,7 +444,7 @@ static DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLO
|
||||
struct asn1_data *data;
|
||||
DATA_BLOB ret = data_blob_null;
|
||||
|
||||
- data = asn1_init(mem_ctx);
|
||||
+ data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
if (!data || !ticket->data) {
|
||||
return ret;
|
||||
}
|
||||
@@ -478,7 +478,7 @@ static DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLO
|
||||
static bool gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
|
||||
{
|
||||
bool ret = false;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
int data_remaining;
|
||||
|
||||
if (!data) {
|
||||
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
|
||||
index 709b7bcacfa..6d329329909 100644
|
||||
--- a/source4/ldap_server/ldap_server.c
|
||||
+++ b/source4/ldap_server/ldap_server.c
|
||||
@@ -560,7 +560,7 @@ static void ldapsrv_call_read_done(struct tevent_req *subreq)
|
||||
return;
|
||||
}
|
||||
|
||||
- asn1 = asn1_init(call);
|
||||
+ asn1 = asn1_init(call, ASN1_MAX_TREE_DEPTH);
|
||||
if (asn1 == NULL) {
|
||||
ldapsrv_terminate_connection(conn, "no memory");
|
||||
return;
|
||||
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
|
||||
index da84adc7769..2d75af6af6e 100644
|
||||
--- a/source4/libcli/ldap/ldap_client.c
|
||||
+++ b/source4/libcli/ldap/ldap_client.c
|
||||
@@ -284,7 +284,7 @@ static void ldap_connection_recv_done(struct tevent_req *subreq)
|
||||
return;
|
||||
}
|
||||
|
||||
- asn1 = asn1_init(conn);
|
||||
+ asn1 = asn1_init(conn, ASN1_MAX_TREE_DEPTH);
|
||||
if (asn1 == NULL) {
|
||||
TALLOC_FREE(msg);
|
||||
ldap_error_handler(conn, NT_STATUS_NO_MEMORY);
|
||||
diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c
|
||||
index 716ca148308..df012a158e0 100644
|
||||
--- a/source4/libcli/ldap/ldap_controls.c
|
||||
+++ b/source4/libcli/ldap/ldap_controls.c
|
||||
@@ -32,7 +32,7 @@ static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB attr;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_sort_resp_control *lsrc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -79,7 +79,7 @@ static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB attr;
|
||||
DATA_BLOB rule;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_server_sort_control **lssc;
|
||||
int num;
|
||||
|
||||
@@ -166,7 +166,7 @@ static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
return true;
|
||||
}
|
||||
|
||||
- data = asn1_init(mem_ctx);
|
||||
+ data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
if (!data) return false;
|
||||
|
||||
if (!asn1_load(data, in)) {
|
||||
@@ -198,7 +198,7 @@ static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_sd_flags_control *lsdfc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -232,7 +232,7 @@ static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_search_options_control *lsoc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -267,7 +267,7 @@ static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void *_out
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB cookie;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_paged_control *lprc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -316,7 +316,7 @@ static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB cookie;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_dirsync_control *ldc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -372,7 +372,7 @@ static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB source_attribute;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_asq_control *lac;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -433,7 +433,7 @@ static bool decode_verify_name_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB name;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_verify_name_control *lvnc;
|
||||
int len;
|
||||
|
||||
@@ -485,7 +485,7 @@ static bool decode_verify_name_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
static bool encode_verify_name_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_verify_name_control *lvnc = talloc_get_type(in, struct ldb_verify_name_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
DATA_BLOB gc_utf16;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -528,7 +528,7 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB assertion_value, context_id;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_vlv_req_control *lvrc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -626,7 +626,7 @@ static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
DATA_BLOB context_id;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct ldb_vlv_resp_control *lvrc;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -682,7 +682,7 @@ static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
static bool encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_sort_resp_control *lsrc = talloc_get_type(in, struct ldb_sort_resp_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -716,7 +716,7 @@ static bool encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_server_sort_control **lssc = talloc_get_type(in, struct ldb_server_sort_control *);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
int num;
|
||||
|
||||
if (!data) return false;
|
||||
@@ -782,7 +782,7 @@ static bool encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
return true;
|
||||
}
|
||||
|
||||
- data = asn1_init(mem_ctx);
|
||||
+ data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -810,7 +810,7 @@ static bool encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_sd_flags_control *lsdfc = talloc_get_type(in, struct ldb_sd_flags_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -838,7 +838,7 @@ static bool encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_search_options_control *lsoc = talloc_get_type(in, struct ldb_search_options_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -866,7 +866,7 @@ static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *ou
|
||||
static bool encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_paged_control *lprc = talloc_get_type(in, struct ldb_paged_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -901,7 +901,7 @@ static bool encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out
|
||||
static bool encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_asq_control *lac = talloc_get_type(in, struct ldb_asq_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -936,7 +936,7 @@ static bool encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_dirsync_control *ldc = talloc_get_type(in, struct ldb_dirsync_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -972,7 +972,7 @@ static bool encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_vlv_req_control *lvrc = talloc_get_type(in, struct ldb_vlv_req_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -1040,7 +1040,7 @@ static bool encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct ldb_vlv_resp_control *lvrc = talloc_get_type(in, struct ldb_vlv_resp_control);
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -1083,7 +1083,7 @@ static bool encode_openldap_dereference(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
{
|
||||
struct dsdb_openldap_dereference_control *control = talloc_get_type(in, struct dsdb_openldap_dereference_control);
|
||||
int i,j;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
|
||||
if (!data) return false;
|
||||
|
||||
@@ -1132,7 +1132,7 @@ static bool encode_openldap_dereference(void *mem_ctx, void *in, DATA_BLOB *out)
|
||||
static bool decode_openldap_dereference(void *mem_ctx, DATA_BLOB in, void *_out)
|
||||
{
|
||||
void **out = (void **)_out;
|
||||
- struct asn1_data *data = asn1_init(mem_ctx);
|
||||
+ struct asn1_data *data = asn1_init(mem_ctx, ASN1_MAX_TREE_DEPTH);
|
||||
struct dsdb_openldap_dereference_result_control *control;
|
||||
struct dsdb_openldap_dereference_result **r = NULL;
|
||||
int i = 0;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
Backport of:
|
||||
|
||||
From d3be674c3ffa3541e2ba757e2c6dfb32508db440 Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Wed, 8 Apr 2020 15:30:52 +1200
|
||||
Subject: [PATCH 3/8] CVE-2020-10704: lib util asn1: Check parse tree depth
|
||||
|
||||
Check the current depth of the parse tree and reject the input if the
|
||||
depth exceeds that passed to asn1_init
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
lib/util/asn1.c | 13 +++++++++++++
|
||||
selftest/knownfail.d/ldap_message | 2 --
|
||||
2 files changed, 13 insertions(+), 2 deletions(-)
|
||||
delete mode 100644 selftest/knownfail.d/ldap_message
|
||||
|
||||
--- a/lib/util/asn1.c
|
||||
+++ b/lib/util/asn1.c
|
||||
@@ -647,6 +647,16 @@ bool asn1_start_tag(struct asn1_data *da
|
||||
uint8_t b;
|
||||
struct nesting *nesting;
|
||||
|
||||
+ /*
|
||||
+ * Check the depth of the parse tree and prevent it from growing
|
||||
+ * too large.
|
||||
+ */
|
||||
+ data->depth++;
|
||||
+ if (data->depth > data->max_depth) {
|
||||
+ data->has_error = true;
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
if (!asn1_read_uint8(data, &b))
|
||||
return false;
|
||||
|
||||
@@ -703,6 +713,9 @@ bool asn1_end_tag(struct asn1_data *data
|
||||
{
|
||||
struct nesting *nesting;
|
||||
|
||||
+ if (data->depth > 0) {
|
||||
+ data->depth--;
|
||||
+ }
|
||||
/* make sure we read it all */
|
||||
if (asn1_tag_remaining(data) != 0) {
|
||||
data->has_error = true;
|
||||
@ -1,96 +0,0 @@
|
||||
From 9944df6ef1e421331ea1ca773f7e5652262d5d1b Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Tue, 7 Apr 2020 09:09:01 +1200
|
||||
Subject: [PATCH 5/8] CVE-2020-10704: smb.conf: Add max ldap request sizes
|
||||
|
||||
Add two new smb.conf parameters to control the maximum permitted ldap
|
||||
request size.
|
||||
|
||||
Adds:
|
||||
ldap max anonymous request size default 250Kb
|
||||
ldap max authenticated request size default 16Mb
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
.../smbdotconf/ldap/ldapmaxanonrequest.xml | 18 ++++++++++++++++++
|
||||
.../smbdotconf/ldap/ldapmaxauthrequest.xml | 18 ++++++++++++++++++
|
||||
lib/param/loadparm.c | 5 +++++
|
||||
source3/param/loadparm.c | 3 +++
|
||||
4 files changed, 44 insertions(+)
|
||||
create mode 100644 docs-xml/smbdotconf/ldap/ldapmaxanonrequest.xml
|
||||
create mode 100644 docs-xml/smbdotconf/ldap/ldapmaxauthrequest.xml
|
||||
|
||||
--- /dev/null
|
||||
+++ b/docs-xml/smbdotconf/ldap/ldapmaxanonrequest.xml
|
||||
@@ -0,0 +1,18 @@
|
||||
+<samba:parameter name="ldap max anonymous request size"
|
||||
+ context="G"
|
||||
+ type="integer"
|
||||
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
|
||||
+<description>
|
||||
+ <para>
|
||||
+ This parameter specifies the maximum permitted size (in bytes)
|
||||
+ for an LDAP request received on an anonymous connection.
|
||||
+ </para>
|
||||
+
|
||||
+ <para>
|
||||
+ If the request size exceeds this limit the request will be
|
||||
+ rejected.
|
||||
+ </para>
|
||||
+</description>
|
||||
+<value type="default">256000</value>
|
||||
+<value type="example">500000</value>
|
||||
+</samba:parameter>
|
||||
--- /dev/null
|
||||
+++ b/docs-xml/smbdotconf/ldap/ldapmaxauthrequest.xml
|
||||
@@ -0,0 +1,18 @@
|
||||
+<samba:parameter name="ldap max authenticated request size"
|
||||
+ context="G"
|
||||
+ type="integer"
|
||||
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
|
||||
+<description>
|
||||
+ <para>
|
||||
+ This parameter specifies the maximum permitted size (in bytes)
|
||||
+ for an LDAP request received on an authenticated connection.
|
||||
+ </para>
|
||||
+
|
||||
+ <para>
|
||||
+ If the request size exceeds this limit the request will be
|
||||
+ rejected.
|
||||
+ </para>
|
||||
+</description>
|
||||
+<value type="default">16777216</value>
|
||||
+<value type="example">4194304</value>
|
||||
+</samba:parameter>
|
||||
--- a/lib/param/loadparm.c
|
||||
+++ b/lib/param/loadparm.c
|
||||
@@ -3027,6 +3027,11 @@ struct loadparm_context *loadparm_init(T
|
||||
|
||||
lpcfg_do_global_parameter(lp_ctx, "debug encryption", "no");
|
||||
|
||||
+ lpcfg_do_global_parameter(
|
||||
+ lp_ctx, "ldap max anonymous request size", "256000");
|
||||
+ lpcfg_do_global_parameter(
|
||||
+ lp_ctx, "ldap max authenticated request size", "16777216");
|
||||
+
|
||||
for (i = 0; parm_table[i].label; i++) {
|
||||
if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
|
||||
lp_ctx->flags[i] |= FLAG_DEFAULT;
|
||||
--- a/source3/param/loadparm.c
|
||||
+++ b/source3/param/loadparm.c
|
||||
@@ -956,6 +956,9 @@ static void init_globals(struct loadparm
|
||||
Globals.prefork_backoff_increment = 10;
|
||||
Globals.prefork_maximum_backoff = 120;
|
||||
|
||||
+ Globals.ldap_max_anonymous_request_size = 256000;
|
||||
+ Globals.ldap_max_authenticated_request_size = 16777216;
|
||||
+
|
||||
/* Now put back the settings that were set with lp_set_cmdline() */
|
||||
apply_lp_set_cmdline();
|
||||
}
|
||||
@ -1,163 +0,0 @@
|
||||
Backport of:
|
||||
|
||||
From 85619363d3280346b2253fe44bf67d4881a53ebd Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Wed, 8 Apr 2020 15:32:22 +1200
|
||||
Subject: [PATCH 6/8] CVE-2020-10704: S4 ldap server: Limit request sizes
|
||||
|
||||
Check the size of authenticated and anonymous ldap requests and reject
|
||||
them if they exceed the limits in smb.conf
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
selftest/knownfail.d/ldap_raw | 1 -
|
||||
source4/ldap_server/ldap_server.c | 96 ++++++++++++++++++++++++++++++-
|
||||
2 files changed, 95 insertions(+), 2 deletions(-)
|
||||
delete mode 100644 selftest/knownfail.d/ldap_raw
|
||||
|
||||
--- a/source4/ldap_server/ldap_server.c
|
||||
+++ b/source4/ldap_server/ldap_server.c
|
||||
@@ -441,6 +441,10 @@ static void ldapsrv_accept_tls_done(stru
|
||||
}
|
||||
|
||||
static void ldapsrv_call_read_done(struct tevent_req *subreq);
|
||||
+static NTSTATUS ldapsrv_packet_check(
|
||||
+ void *private_data,
|
||||
+ DATA_BLOB blob,
|
||||
+ size_t *packet_size);
|
||||
|
||||
static bool ldapsrv_call_read_next(struct ldapsrv_connection *conn)
|
||||
{
|
||||
@@ -494,7 +498,7 @@ static bool ldapsrv_call_read_next(struc
|
||||
conn->connection->event.ctx,
|
||||
conn->sockets.active,
|
||||
7, /* initial_read_size */
|
||||
- ldap_full_packet,
|
||||
+ ldapsrv_packet_check,
|
||||
conn);
|
||||
if (subreq == NULL) {
|
||||
ldapsrv_terminate_connection(conn, "ldapsrv_call_read_next: "
|
||||
@@ -520,6 +524,9 @@ static bool ldapsrv_call_read_next(struc
|
||||
}
|
||||
|
||||
static void ldapsrv_call_process_done(struct tevent_req *subreq);
|
||||
+static int ldapsrv_check_packet_size(
|
||||
+ struct ldapsrv_connection *conn,
|
||||
+ size_t size);
|
||||
|
||||
static void ldapsrv_call_read_done(struct tevent_req *subreq)
|
||||
{
|
||||
@@ -530,6 +537,7 @@ static void ldapsrv_call_read_done(struc
|
||||
struct ldapsrv_call *call;
|
||||
struct asn1_data *asn1;
|
||||
DATA_BLOB blob;
|
||||
+ int ret = LDAP_SUCCESS;
|
||||
|
||||
conn->sockets.read_req = NULL;
|
||||
|
||||
@@ -560,6 +568,14 @@ static void ldapsrv_call_read_done(struc
|
||||
return;
|
||||
}
|
||||
|
||||
+ ret = ldapsrv_check_packet_size(conn, blob.length);
|
||||
+ if (ret != LDAP_SUCCESS) {
|
||||
+ ldapsrv_terminate_connection(
|
||||
+ conn,
|
||||
+ "Request packet too large");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
asn1 = asn1_init(call, ASN1_MAX_TREE_DEPTH);
|
||||
if (asn1 == NULL) {
|
||||
ldapsrv_terminate_connection(conn, "no memory");
|
||||
@@ -1362,6 +1378,84 @@ static void ldapsrv_post_fork(struct tas
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Check the size of an ldap request packet.
|
||||
+ *
|
||||
+ * For authenticated connections the maximum packet size is controlled by
|
||||
+ * the smb.conf parameter "ldap max authenticated request size"
|
||||
+ *
|
||||
+ * For anonymous connections the maximum packet size is controlled by
|
||||
+ * the smb.conf parameter "ldap max anonymous request size"
|
||||
+ */
|
||||
+static int ldapsrv_check_packet_size(
|
||||
+ struct ldapsrv_connection *conn,
|
||||
+ size_t size)
|
||||
+{
|
||||
+ bool is_anonymous = false;
|
||||
+ size_t max_size = 0;
|
||||
+
|
||||
+ max_size = lpcfg_ldap_max_anonymous_request_size(conn->lp_ctx);
|
||||
+ if (size <= max_size) {
|
||||
+ return LDAP_SUCCESS;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Request is larger than the maximum unauthenticated request size.
|
||||
+ * As this code is called frequently we avoid calling
|
||||
+ * security_token_is_anonymous if possible
|
||||
+ */
|
||||
+ if (conn->session_info != NULL &&
|
||||
+ conn->session_info->security_token != NULL) {
|
||||
+ is_anonymous = security_token_is_anonymous(
|
||||
+ conn->session_info->security_token);
|
||||
+ }
|
||||
+
|
||||
+ if (is_anonymous) {
|
||||
+ DBG_WARNING(
|
||||
+ "LDAP request size (%zu) exceeds (%zu)\n",
|
||||
+ size,
|
||||
+ max_size);
|
||||
+ return LDAP_UNWILLING_TO_PERFORM;
|
||||
+ }
|
||||
+
|
||||
+ max_size = lpcfg_ldap_max_authenticated_request_size(conn->lp_ctx);
|
||||
+ if (size > max_size) {
|
||||
+ DBG_WARNING(
|
||||
+ "LDAP request size (%zu) exceeds (%zu)\n",
|
||||
+ size,
|
||||
+ max_size);
|
||||
+ return LDAP_UNWILLING_TO_PERFORM;
|
||||
+ }
|
||||
+ return LDAP_SUCCESS;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Check that the blob contains enough data to be a valid packet
|
||||
+ * If there is a packet header check the size to ensure that it does not
|
||||
+ * exceed the maximum sizes.
|
||||
+ *
|
||||
+ */
|
||||
+static NTSTATUS ldapsrv_packet_check(
|
||||
+ void *private_data,
|
||||
+ DATA_BLOB blob,
|
||||
+ size_t *packet_size)
|
||||
+{
|
||||
+ NTSTATUS ret;
|
||||
+ struct ldapsrv_connection *conn = private_data;
|
||||
+ int result = LDB_SUCCESS;
|
||||
+
|
||||
+ ret = ldap_full_packet(private_data, blob, packet_size);
|
||||
+ if (!NT_STATUS_IS_OK(ret)) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+ result = ldapsrv_check_packet_size(conn, *packet_size);
|
||||
+ if (result != LDAP_SUCCESS) {
|
||||
+ return NT_STATUS_LDAP(result);
|
||||
+ }
|
||||
+ return NT_STATUS_OK;
|
||||
+}
|
||||
+
|
||||
NTSTATUS server_service_ldap_init(TALLOC_CTX *ctx)
|
||||
{
|
||||
static const struct service_details details = {
|
||||
@ -1,211 +0,0 @@
|
||||
Backport of:
|
||||
|
||||
From 9be121c7055fde841be15f8d570ff49801b68bff Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Wed, 8 Apr 2020 08:49:23 +1200
|
||||
Subject: [PATCH 7/8] CVE-2020-10704: libcli ldap_message: Add search size
|
||||
limits to ldap_decode
|
||||
|
||||
Add search request size limits to ldap_decode calls.
|
||||
|
||||
The ldap server uses the smb.conf variable
|
||||
"ldap max search request size" which defaults to 250Kb.
|
||||
For cldap the limit is hard coded as 4096.
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
.../smbdotconf/ldap/ldapmaxsearchrequest.xml | 18 ++++++++++++++
|
||||
lib/param/loadparm.c | 2 ++
|
||||
libcli/cldap/cldap.c | 18 +++++++++++---
|
||||
libcli/ldap/ldap_message.c | 1 +
|
||||
libcli/ldap/ldap_message.h | 5 ++++
|
||||
libcli/ldap/tests/ldap_message_test.c | 24 +++++++++++++++----
|
||||
source3/param/loadparm.c | 1 +
|
||||
source4/ldap_server/ldap_server.c | 10 ++++++--
|
||||
source4/libcli/ldap/ldap_client.c | 3 ++-
|
||||
9 files changed, 72 insertions(+), 10 deletions(-)
|
||||
create mode 100644 docs-xml/smbdotconf/ldap/ldapmaxsearchrequest.xml
|
||||
|
||||
--- /dev/null
|
||||
+++ b/docs-xml/smbdotconf/ldap/ldapmaxsearchrequest.xml
|
||||
@@ -0,0 +1,18 @@
|
||||
+<samba:parameter name="ldap max search request size"
|
||||
+ context="G"
|
||||
+ type="integer"
|
||||
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
|
||||
+<description>
|
||||
+ <para>
|
||||
+ This parameter specifies the maximum permitted size (in bytes)
|
||||
+ for an LDAP search request.
|
||||
+ </para>
|
||||
+
|
||||
+ <para>
|
||||
+ If the request size exceeds this limit the request will be
|
||||
+ rejected.
|
||||
+ </para>
|
||||
+</description>
|
||||
+<value type="default">256000</value>
|
||||
+<value type="example">4194304</value>
|
||||
+</samba:parameter>
|
||||
--- a/lib/param/loadparm.c
|
||||
+++ b/lib/param/loadparm.c
|
||||
@@ -3031,6 +3031,8 @@ struct loadparm_context *loadparm_init(T
|
||||
lp_ctx, "ldap max anonymous request size", "256000");
|
||||
lpcfg_do_global_parameter(
|
||||
lp_ctx, "ldap max authenticated request size", "16777216");
|
||||
+ lpcfg_do_global_parameter(
|
||||
+ lp_ctx, "ldap max search request size", "256000");
|
||||
|
||||
for (i = 0; parm_table[i].label; i++) {
|
||||
if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
|
||||
--- a/libcli/cldap/cldap.c
|
||||
+++ b/libcli/cldap/cldap.c
|
||||
@@ -111,6 +111,11 @@ struct cldap_search_state {
|
||||
struct tevent_req *req;
|
||||
};
|
||||
|
||||
+/*
|
||||
+ * For CLDAP we limit the maximum search request size to 4kb
|
||||
+ */
|
||||
+#define MAX_SEARCH_REQUEST 4096
|
||||
+
|
||||
static int cldap_socket_destructor(struct cldap_socket *c)
|
||||
{
|
||||
while (c->searches.list) {
|
||||
@@ -224,6 +229,9 @@ static bool cldap_socket_recv_dgram(stru
|
||||
void *p;
|
||||
struct cldap_search_state *search;
|
||||
NTSTATUS status;
|
||||
+ struct ldap_request_limits limits = {
|
||||
+ .max_search_size = MAX_SEARCH_REQUEST
|
||||
+ };
|
||||
|
||||
if (in->recv_errno != 0) {
|
||||
goto error;
|
||||
@@ -242,7 +250,7 @@ static bool cldap_socket_recv_dgram(stru
|
||||
}
|
||||
|
||||
/* this initial decode is used to find the message id */
|
||||
- status = ldap_decode(asn1, NULL, in->ldap_msg);
|
||||
+ status = ldap_decode(asn1, &limits, NULL, in->ldap_msg);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto nterror;
|
||||
}
|
||||
@@ -770,6 +778,9 @@ NTSTATUS cldap_search_recv(struct tevent
|
||||
struct cldap_search_state);
|
||||
struct ldap_message *ldap_msg;
|
||||
NTSTATUS status;
|
||||
+ struct ldap_request_limits limits = {
|
||||
+ .max_search_size = MAX_SEARCH_REQUEST
|
||||
+ };
|
||||
|
||||
if (tevent_req_is_nterror(req, &status)) {
|
||||
goto failed;
|
||||
@@ -780,7 +791,7 @@ NTSTATUS cldap_search_recv(struct tevent
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
- status = ldap_decode(state->response.asn1, NULL, ldap_msg);
|
||||
+ status = ldap_decode(state->response.asn1, &limits, NULL, ldap_msg);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto failed;
|
||||
}
|
||||
@@ -796,7 +807,8 @@ NTSTATUS cldap_search_recv(struct tevent
|
||||
*io->out.response = ldap_msg->r.SearchResultEntry;
|
||||
|
||||
/* decode the 2nd part */
|
||||
- status = ldap_decode(state->response.asn1, NULL, ldap_msg);
|
||||
+ status = ldap_decode(
|
||||
+ state->response.asn1, &limits, NULL, ldap_msg);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto failed;
|
||||
}
|
||||
--- a/libcli/ldap/ldap_message.c
|
||||
+++ b/libcli/ldap/ldap_message.c
|
||||
@@ -1162,6 +1162,7 @@ static bool ldap_decode_attribs(TALLOC_C
|
||||
/* This routine returns LDAP status codes */
|
||||
|
||||
_PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data,
|
||||
+ const struct ldap_request_limits *limits,
|
||||
const struct ldap_control_handler *control_handlers,
|
||||
struct ldap_message *msg)
|
||||
{
|
||||
--- a/libcli/ldap/ldap_message.h
|
||||
+++ b/libcli/ldap/ldap_message.h
|
||||
@@ -213,10 +213,15 @@ struct ldap_control_handler {
|
||||
bool (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
|
||||
};
|
||||
|
||||
+struct ldap_request_limits {
|
||||
+ unsigned max_search_size;
|
||||
+};
|
||||
+
|
||||
struct asn1_data;
|
||||
|
||||
struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
|
||||
NTSTATUS ldap_decode(struct asn1_data *data,
|
||||
+ const struct ldap_request_limits *limits,
|
||||
const struct ldap_control_handler *control_handlers,
|
||||
struct ldap_message *msg);
|
||||
bool ldap_encode(struct ldap_message *msg,
|
||||
--- a/source3/param/loadparm.c
|
||||
+++ b/source3/param/loadparm.c
|
||||
@@ -958,6 +958,7 @@ static void init_globals(struct loadparm
|
||||
|
||||
Globals.ldap_max_anonymous_request_size = 256000;
|
||||
Globals.ldap_max_authenticated_request_size = 16777216;
|
||||
+ Globals.ldap_max_search_request_size = 256000;
|
||||
|
||||
/* Now put back the settings that were set with lp_set_cmdline() */
|
||||
apply_lp_set_cmdline();
|
||||
--- a/source4/ldap_server/ldap_server.c
|
||||
+++ b/source4/ldap_server/ldap_server.c
|
||||
@@ -538,6 +538,7 @@ static void ldapsrv_call_read_done(struc
|
||||
struct asn1_data *asn1;
|
||||
DATA_BLOB blob;
|
||||
int ret = LDAP_SUCCESS;
|
||||
+ struct ldap_request_limits limits = {0};
|
||||
|
||||
conn->sockets.read_req = NULL;
|
||||
|
||||
@@ -593,8 +594,13 @@ static void ldapsrv_call_read_done(struc
|
||||
return;
|
||||
}
|
||||
|
||||
- status = ldap_decode(asn1, samba_ldap_control_handlers(),
|
||||
- call->request);
|
||||
+ limits.max_search_size =
|
||||
+ lpcfg_ldap_max_search_request_size(conn->lp_ctx);
|
||||
+ status = ldap_decode(
|
||||
+ asn1,
|
||||
+ &limits,
|
||||
+ samba_ldap_control_handlers(),
|
||||
+ call->request);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
ldapsrv_terminate_connection(conn, nt_errstr(status));
|
||||
return;
|
||||
--- a/source4/libcli/ldap/ldap_client.c
|
||||
+++ b/source4/libcli/ldap/ldap_client.c
|
||||
@@ -277,6 +277,7 @@ static void ldap_connection_recv_done(st
|
||||
struct ldap_message *msg;
|
||||
struct asn1_data *asn1;
|
||||
DATA_BLOB blob;
|
||||
+ struct ldap_request_limits limits = {0};
|
||||
|
||||
msg = talloc_zero(conn, struct ldap_message);
|
||||
if (msg == NULL) {
|
||||
@@ -306,7 +307,7 @@ static void ldap_connection_recv_done(st
|
||||
|
||||
asn1_load_nocopy(asn1, blob.data, blob.length);
|
||||
|
||||
- status = ldap_decode(asn1, samba_ldap_control_handlers(), msg);
|
||||
+ status = ldap_decode(asn1, &limits, samba_ldap_control_handlers(), msg);
|
||||
asn1_free(asn1);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(msg);
|
||||
@ -1,66 +0,0 @@
|
||||
From ee3156c76b86c11829f6f3fe1e3c940b45899c56 Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Date: Wed, 8 Apr 2020 10:46:44 +1200
|
||||
Subject: [PATCH 8/8] CVE-2020-10704 libcli ldap: Check search request lengths.
|
||||
|
||||
Check the search request lengths against the limits passed to
|
||||
ldap_decode.
|
||||
|
||||
Credit to OSS-Fuzz
|
||||
|
||||
REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
|
||||
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334
|
||||
|
||||
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
|
||||
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
||||
---
|
||||
lib/util/asn1.c | 7 +++++++
|
||||
lib/util/asn1.h | 1 +
|
||||
libcli/ldap/ldap_message.c | 4 ++++
|
||||
3 files changed, 12 insertions(+)
|
||||
|
||||
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
|
||||
index ee3cff9cb65..32d7981d28f 100644
|
||||
--- a/lib/util/asn1.c
|
||||
+++ b/lib/util/asn1.c
|
||||
@@ -1159,3 +1159,10 @@ int asn1_peek_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size)
|
||||
*packet_size = size;
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+/*
|
||||
+ * Get the length of the ASN.1 data
|
||||
+ */
|
||||
+size_t asn1_get_length(const struct asn1_data *asn1) {
|
||||
+ return asn1->length;
|
||||
+}
|
||||
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
|
||||
index fc365724e93..de92a767f14 100644
|
||||
--- a/lib/util/asn1.h
|
||||
+++ b/lib/util/asn1.h
|
||||
@@ -106,5 +106,6 @@ bool asn1_extract_blob(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *pblob);
|
||||
void asn1_load_nocopy(struct asn1_data *data, uint8_t *buf, size_t len);
|
||||
int asn1_peek_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size);
|
||||
+size_t asn1_get_length(const struct asn1_data *asn1);
|
||||
|
||||
#endif /* _ASN_1_H */
|
||||
diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c
|
||||
index d38fa0b3b61..69a48279532 100644
|
||||
--- a/libcli/ldap/ldap_message.c
|
||||
+++ b/libcli/ldap/ldap_message.c
|
||||
@@ -1259,7 +1259,11 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data,
|
||||
struct ldap_SearchRequest *r = &msg->r.SearchRequest;
|
||||
int sizelimit, timelimit;
|
||||
const char **attrs = NULL;
|
||||
+ size_t request_size = asn1_get_length(data);
|
||||
msg->type = LDAP_TAG_SearchRequest;
|
||||
+ if (request_size > limits->max_search_size) {
|
||||
+ goto prot_err;
|
||||
+ }
|
||||
if (!asn1_start_tag(data, tag)) goto prot_err;
|
||||
if (!asn1_read_OctetString_talloc(msg, data, &r->basedn)) goto prot_err;
|
||||
if (!asn1_read_enumerated(data, (int *)(void *)&(r->scope))) goto prot_err;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iHMEABECADMWIQRS+8C4bZVLCEMyTNxvM5FbZWi36gUCXjALthUcc2FtYmEtYnVn
|
||||
c0BzYW1iYS5vcmcACgkQbzORW2Vot+od+ACgpzREKkVcyLse9EwufX0vS/JMUYIA
|
||||
n2xGjOlyTFJJUD9heWInjmYzy4W0
|
||||
=472O
|
||||
-----END PGP SIGNATURE-----
|
||||
7
samba-4.12.5.tar.asc
Normal file
7
samba-4.12.5.tar.asc
Normal file
@ -0,0 +1,7 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iHMEABECADMWIQRS+8C4bZVLCEMyTNxvM5FbZWi36gUCXv3BXhUcc2FtYmEtYnVn
|
||||
c0BzYW1iYS5vcmcACgkQbzORW2Vot+quPwCcDfpwxTo7ZDrFD768SgWqRmKI/+QA
|
||||
oJqPMNOtzBJYbxVbKY+OyCqwQ2Zl
|
||||
=2OtH
|
||||
-----END PGP SIGNATURE-----
|
||||
Binary file not shown.
1539
samba.spec
1539
samba.spec
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user