From bf3f8c462bf8a33c5bc1e4d3dae3eb4bab792252 Mon Sep 17 00:00:00 2001
From: Joseph Sutton <josephsutton@catalyst.net.nz>
Date: Tue, 22 Nov 2022 11:32:34 +1300
Subject: [PATCH 23/54] CVE-2022-37966 kdc: Assume trust objects support AES by
 default

As part of matching the behaviour of Windows, assume that trust objects
support AES256, but not RC4, if not specified otherwise.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 4bb50c868c8ed14372cb7d27e53cdaba265fc33d)

Conflict: NA
Reference: https://attachments.samba.org/attachment.cgi?id=17695
---
 source4/kdc/db-glue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c
index e8a293633ce8..d1ba6b77840c 100644
--- a/source4/kdc/db-glue.c
+++ b/source4/kdc/db-glue.c
@@ -1597,9 +1597,10 @@ static krb5_error_code samba_kdc_trust_message2entry(krb5_context context,
 	ZERO_STRUCTP(entry);
 
 	if (dsdb_functional_level(kdc_db_ctx->samdb) >= DS_DOMAIN_FUNCTION_2008) {
+		/* If not told otherwise, Windows now assumes that trusts support AES. */
 		supported_enctypes = ldb_msg_find_attr_as_uint(msg,
 					"msDS-SupportedEncryptionTypes",
-					supported_enctypes);
+					ENC_HMAC_SHA1_96_AES256);
 	}
 
 	status = dsdb_trust_parse_tdo_info(mem_ctx, msg, &tdo);
-- 
2.34.1
