5a96cc
From 97829843013e2f0d81b6ed61d155a04217e40205 Mon Sep 17 00:00:00 2001
5a96cc
From: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Date: Wed, 1 Sep 2021 15:39:19 +1200
5a96cc
Subject: [PATCH 1/6] krb5pac.idl: Add ticket checksum PAC buffer type
5a96cc
5a96cc
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
Reviewed-by: Isaac Boukris <iboukris@samba.org>
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14881
5a96cc
(cherry picked from commit ff2f38fae79220e16765e17671972f9a55eb7cce)
5a96cc
---
5a96cc
 librpc/idl/krb5pac.idl | 4 +++-
5a96cc
 1 file changed, 3 insertions(+), 1 deletion(-)
5a96cc
5a96cc
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
5a96cc
index fb360c1257f..3239d7656b6 100644
5a96cc
--- a/librpc/idl/krb5pac.idl
5a96cc
+++ b/librpc/idl/krb5pac.idl
5a96cc
@@ -112,7 +112,8 @@ interface krb5pac
5a96cc
 		PAC_TYPE_KDC_CHECKSUM = 7,
5a96cc
 		PAC_TYPE_LOGON_NAME = 10,
5a96cc
 		PAC_TYPE_CONSTRAINED_DELEGATION = 11,
5a96cc
-		PAC_TYPE_UPN_DNS_INFO = 12
5a96cc
+		PAC_TYPE_UPN_DNS_INFO = 12,
5a96cc
+		PAC_TYPE_TICKET_CHECKSUM = 16
5a96cc
 	} PAC_TYPE;
5a96cc
 
5a96cc
 	typedef struct {
5a96cc
@@ -128,6 +129,7 @@ interface krb5pac
5a96cc
 		[case(PAC_TYPE_CONSTRAINED_DELEGATION)][subcontext(0xFFFFFC01)]
5a96cc
 			PAC_CONSTRAINED_DELEGATION_CTR constrained_delegation;
5a96cc
 		[case(PAC_TYPE_UPN_DNS_INFO)]	PAC_UPN_DNS_INFO upn_dns_info;
5a96cc
+		[case(PAC_TYPE_TICKET_CHECKSUM)]	PAC_SIGNATURE_DATA ticket_checksum;
5a96cc
 		/* when new PAC info types are added they are supposed to be done
5a96cc
 		   in such a way that they are backwards compatible with existing
5a96cc
 		   servers. This makes it safe to just use a [default] for
5a96cc
-- 
5a96cc
2.33.1
5a96cc
5a96cc
5a96cc
From 99cc0e06e5fe2776371b808432af39de00f76cdf Mon Sep 17 00:00:00 2001
5a96cc
From: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Date: Wed, 1 Sep 2021 15:40:59 +1200
5a96cc
Subject: [PATCH 2/6] security.idl: Add well-known SIDs for FAST
5a96cc
5a96cc
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
Reviewed-by: Isaac Boukris <iboukris@samba.org>
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14881
5a96cc
(cherry picked from commit 0092b4a3ed58b2c256d4dd9117cce927a3edde12)
5a96cc
---
5a96cc
 librpc/idl/security.idl | 3 +++
5a96cc
 1 file changed, 3 insertions(+)
5a96cc
5a96cc
diff --git a/librpc/idl/security.idl b/librpc/idl/security.idl
5a96cc
index 06bf7449a70..3df96dedbdd 100644
5a96cc
--- a/librpc/idl/security.idl
5a96cc
+++ b/librpc/idl/security.idl
5a96cc
@@ -295,6 +295,9 @@ interface security
5a96cc
 	const string SID_AUTHENTICATION_AUTHORITY_ASSERTED_IDENTITY = "S-1-18-1";
5a96cc
 	const string SID_SERVICE_ASSERTED_IDENTITY = "S-1-18-2";
5a96cc
 
5a96cc
+	const string SID_COMPOUNDED_AUTHENTICATION = "S-1-5-21-0-0-0-496";
5a96cc
+	const string SID_CLAIMS_VALID = "S-1-5-21-0-0-0-497";
5a96cc
+
5a96cc
 	/*
5a96cc
 	 * http://technet.microsoft.com/en-us/library/hh509017(v=ws.10).aspx
5a96cc
 	 */
5a96cc
-- 
5a96cc
2.33.1
5a96cc
5a96cc
5a96cc
From 693bcdb2f9b64af390d619c9b39293c581900151 Mon Sep 17 00:00:00 2001
5a96cc
From: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Date: Wed, 29 Sep 2021 16:15:26 +1300
5a96cc
Subject: [PATCH 3/6] krb5pac.idl: Add missing buffer type values
5a96cc
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642
5a96cc
5a96cc
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
Backported-by: Andreas Schneider <asn@samba.org>
5a96cc
---
5a96cc
 librpc/idl/krb5pac.idl | 3 +++
5a96cc
 1 file changed, 3 insertions(+)
5a96cc
5a96cc
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
5a96cc
index 3239d7656b6..515150ab9cd 100644
5a96cc
--- a/librpc/idl/krb5pac.idl
5a96cc
+++ b/librpc/idl/krb5pac.idl
5a96cc
@@ -113,6 +113,9 @@ interface krb5pac
5a96cc
 		PAC_TYPE_LOGON_NAME = 10,
5a96cc
 		PAC_TYPE_CONSTRAINED_DELEGATION = 11,
5a96cc
 		PAC_TYPE_UPN_DNS_INFO = 12,
5a96cc
+		PAC_TYPE_CLIENT_CLAIMS_INFO = 13,
5a96cc
+		PAC_TYPE_DEVICE_INFO = 14,
5a96cc
+		PAC_TYPE_DEVICE_CLAIMS_INFO = 15,
5a96cc
 		PAC_TYPE_TICKET_CHECKSUM = 16
5a96cc
 	} PAC_TYPE;
5a96cc
 
5a96cc
-- 
5a96cc
2.33.1
5a96cc
5a96cc
5a96cc
From 97323751c1b6b97e72eb80b8b99485d94696b30b Mon Sep 17 00:00:00 2001
5a96cc
From: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Date: Tue, 26 Oct 2021 20:33:38 +1300
5a96cc
Subject: [PATCH 4/6] CVE-2020-25719 krb5pac.idl: Add PAC_ATTRIBUTES_INFO PAC
5a96cc
 buffer type
5a96cc
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561
5a96cc
5a96cc
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
---
5a96cc
 librpc/idl/krb5pac.idl | 14 +++++++++++++-
5a96cc
 1 file changed, 13 insertions(+), 1 deletion(-)
5a96cc
5a96cc
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
5a96cc
index 515150ab9cd..7a8d16464eb 100644
5a96cc
--- a/librpc/idl/krb5pac.idl
5a96cc
+++ b/librpc/idl/krb5pac.idl
5a96cc
@@ -97,6 +97,16 @@ interface krb5pac
5a96cc
 		PAC_UPN_DNS_FLAGS flags;
5a96cc
 	} PAC_UPN_DNS_INFO;
5a96cc
 
5a96cc
+	typedef [bitmap32bit] bitmap {
5a96cc
+		PAC_ATTRIBUTE_FLAG_PAC_WAS_REQUESTED = 0x00000001,
5a96cc
+		PAC_ATTRIBUTE_FLAG_PAC_WAS_GIVEN_IMPLICITLY = 0x00000002
5a96cc
+	} PAC_ATTRIBUTE_INFO_FLAGS;
5a96cc
+
5a96cc
+	typedef struct {
5a96cc
+		uint32 flags_length; /* length in bits */
5a96cc
+		PAC_ATTRIBUTE_INFO_FLAGS flags;
5a96cc
+	} PAC_ATTRIBUTES_INFO;
5a96cc
+
5a96cc
 	typedef [public] struct {
5a96cc
 		PAC_LOGON_INFO *info;
5a96cc
 	} PAC_LOGON_INFO_CTR;
5a96cc
@@ -116,7 +126,8 @@ interface krb5pac
5a96cc
 		PAC_TYPE_CLIENT_CLAIMS_INFO = 13,
5a96cc
 		PAC_TYPE_DEVICE_INFO = 14,
5a96cc
 		PAC_TYPE_DEVICE_CLAIMS_INFO = 15,
5a96cc
-		PAC_TYPE_TICKET_CHECKSUM = 16
5a96cc
+		PAC_TYPE_TICKET_CHECKSUM = 16,
5a96cc
+		PAC_TYPE_ATTRIBUTES_INFO = 17
5a96cc
 	} PAC_TYPE;
5a96cc
 
5a96cc
 	typedef struct {
5a96cc
@@ -133,6 +144,7 @@ interface krb5pac
5a96cc
 			PAC_CONSTRAINED_DELEGATION_CTR constrained_delegation;
5a96cc
 		[case(PAC_TYPE_UPN_DNS_INFO)]	PAC_UPN_DNS_INFO upn_dns_info;
5a96cc
 		[case(PAC_TYPE_TICKET_CHECKSUM)]	PAC_SIGNATURE_DATA ticket_checksum;
5a96cc
+		[case(PAC_TYPE_ATTRIBUTES_INFO)]	PAC_ATTRIBUTES_INFO attributes_info;
5a96cc
 		/* when new PAC info types are added they are supposed to be done
5a96cc
 		   in such a way that they are backwards compatible with existing
5a96cc
 		   servers. This makes it safe to just use a [default] for
5a96cc
-- 
5a96cc
2.33.1
5a96cc
5a96cc
5a96cc
From 9867beabf3b0be026d900e26ac91af655fb50cfe Mon Sep 17 00:00:00 2001
5a96cc
From: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Date: Tue, 26 Oct 2021 20:33:49 +1300
5a96cc
Subject: [PATCH 5/6] CVE-2020-25719 krb5pac.idl: Add PAC_REQUESTER_SID PAC
5a96cc
 buffer type
5a96cc
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561
5a96cc
5a96cc
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
---
5a96cc
 librpc/idl/krb5pac.idl | 8 +++++++-
5a96cc
 1 file changed, 7 insertions(+), 1 deletion(-)
5a96cc
5a96cc
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
5a96cc
index 7a8d16464eb..52fb40c4bbb 100644
5a96cc
--- a/librpc/idl/krb5pac.idl
5a96cc
+++ b/librpc/idl/krb5pac.idl
5a96cc
@@ -107,6 +107,10 @@ interface krb5pac
5a96cc
 		PAC_ATTRIBUTE_INFO_FLAGS flags;
5a96cc
 	} PAC_ATTRIBUTES_INFO;
5a96cc
 
5a96cc
+	typedef struct {
5a96cc
+		dom_sid sid;
5a96cc
+	} PAC_REQUESTER_SID;
5a96cc
+
5a96cc
 	typedef [public] struct {
5a96cc
 		PAC_LOGON_INFO *info;
5a96cc
 	} PAC_LOGON_INFO_CTR;
5a96cc
@@ -127,7 +131,8 @@ interface krb5pac
5a96cc
 		PAC_TYPE_DEVICE_INFO = 14,
5a96cc
 		PAC_TYPE_DEVICE_CLAIMS_INFO = 15,
5a96cc
 		PAC_TYPE_TICKET_CHECKSUM = 16,
5a96cc
-		PAC_TYPE_ATTRIBUTES_INFO = 17
5a96cc
+		PAC_TYPE_ATTRIBUTES_INFO = 17,
5a96cc
+		PAC_TYPE_REQUESTER_SID = 18
5a96cc
 	} PAC_TYPE;
5a96cc
 
5a96cc
 	typedef struct {
5a96cc
@@ -145,6 +150,7 @@ interface krb5pac
5a96cc
 		[case(PAC_TYPE_UPN_DNS_INFO)]	PAC_UPN_DNS_INFO upn_dns_info;
5a96cc
 		[case(PAC_TYPE_TICKET_CHECKSUM)]	PAC_SIGNATURE_DATA ticket_checksum;
5a96cc
 		[case(PAC_TYPE_ATTRIBUTES_INFO)]	PAC_ATTRIBUTES_INFO attributes_info;
5a96cc
+		[case(PAC_TYPE_REQUESTER_SID)]	PAC_REQUESTER_SID requester_sid;
5a96cc
 		/* when new PAC info types are added they are supposed to be done
5a96cc
 		   in such a way that they are backwards compatible with existing
5a96cc
 		   servers. This makes it safe to just use a [default] for
5a96cc
-- 
5a96cc
2.33.1
5a96cc
5a96cc
5a96cc
From fb92457cfd11745be73660eb90519b625f6a5d97 Mon Sep 17 00:00:00 2001
5a96cc
From: Andrew Bartlett <abartlet@samba.org>
5a96cc
Date: Mon, 27 Sep 2021 11:20:19 +1300
5a96cc
Subject: [PATCH 6/6] CVE-2020-25721 krb5pac: Add new buffers for
5a96cc
 samAccountName and objectSID
5a96cc
5a96cc
These appear when PAC_UPN_DNS_FLAG_HAS_SAM_NAME_AND_SID is set.
5a96cc
5a96cc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14835
5a96cc
5a96cc
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
5a96cc
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
5a96cc
---
5a96cc
 librpc/idl/krb5pac.idl   | 18 ++++++++++++++++--
5a96cc
 librpc/ndr/ndr_krb5pac.c |  4 ++--
5a96cc
 2 files changed, 18 insertions(+), 4 deletions(-)
5a96cc
5a96cc
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
5a96cc
index 52fb40c4bbb..bbe4a253e3a 100644
5a96cc
--- a/librpc/idl/krb5pac.idl
5a96cc
+++ b/librpc/idl/krb5pac.idl
5a96cc
@@ -86,15 +86,29 @@ interface krb5pac
5a96cc
 	} PAC_CONSTRAINED_DELEGATION;
5a96cc
 
5a96cc
 	typedef [bitmap32bit] bitmap {
5a96cc
-		PAC_UPN_DNS_FLAG_CONSTRUCTED = 0x00000001
5a96cc
+		PAC_UPN_DNS_FLAG_CONSTRUCTED = 0x00000001,
5a96cc
+		PAC_UPN_DNS_FLAG_HAS_SAM_NAME_AND_SID = 0x00000002
5a96cc
 	} PAC_UPN_DNS_FLAGS;
5a96cc
 
5a96cc
+	typedef struct {
5a96cc
+		[value(2*strlen_m(samaccountname))] uint16 samaccountname_size;
5a96cc
+		[relative_short,subcontext(0),subcontext_size(samaccountname_size),flag(NDR_ALIGN8|STR_NOTERM|NDR_REMAINING)] string *samaccountname;
5a96cc
+		[value(ndr_size_dom_sid(objectsid, ndr->flags))] uint16 objectsid_size;
5a96cc
+		[relative_short,subcontext(0),subcontext_size(objectsid_size)] dom_sid *objectsid;
5a96cc
+	} PAC_UPN_DNS_INFO_SAM_NAME_AND_SID;
5a96cc
+
5a96cc
+	typedef [nodiscriminant] union {
5a96cc
+		[case(PAC_UPN_DNS_FLAG_HAS_SAM_NAME_AND_SID)] PAC_UPN_DNS_INFO_SAM_NAME_AND_SID sam_name_and_sid;
5a96cc
+		[default];
5a96cc
+	} PAC_UPN_DNS_INFO_EX;
5a96cc
+
5a96cc
 	typedef struct {
5a96cc
 		[value(2*strlen_m(upn_name))] uint16 upn_name_size;
5a96cc
 		[relative_short,subcontext(0),subcontext_size(upn_name_size),flag(NDR_ALIGN8|STR_NOTERM|NDR_REMAINING)] string *upn_name;
5a96cc
 		[value(2*strlen_m(dns_domain_name))] uint16 dns_domain_name_size;
5a96cc
 		[relative_short,subcontext(0),subcontext_size(dns_domain_name_size),flag(NDR_ALIGN8|STR_NOTERM|NDR_REMAINING)] string *dns_domain_name;
5a96cc
 		PAC_UPN_DNS_FLAGS flags;
5a96cc
+		[switch_is(flags & PAC_UPN_DNS_FLAG_HAS_SAM_NAME_AND_SID)] PAC_UPN_DNS_INFO_EX ex;
5a96cc
 	} PAC_UPN_DNS_INFO;
5a96cc
 
5a96cc
 	typedef [bitmap32bit] bitmap {
5a96cc
@@ -160,7 +174,7 @@ interface krb5pac
5a96cc
 
5a96cc
 	typedef [public,nopush,nopull] struct {
5a96cc
 		PAC_TYPE type;
5a96cc
-		[value(_ndr_size_PAC_INFO(info, type, 0))] uint32 _ndr_size;
5a96cc
+		[value(_ndr_size_PAC_INFO(info, type, LIBNDR_FLAG_ALIGN8))] uint32 _ndr_size;
5a96cc
 		/*
5a96cc
 		 * We need to have two subcontexts to get the padding right,
5a96cc
 		 * the outer subcontext uses NDR_ROUND(_ndr_size, 8), while
5a96cc
diff --git a/librpc/ndr/ndr_krb5pac.c b/librpc/ndr/ndr_krb5pac.c
5a96cc
index a9ae2c4a789..57b28df9e52 100644
5a96cc
--- a/librpc/ndr/ndr_krb5pac.c
5a96cc
+++ b/librpc/ndr/ndr_krb5pac.c
5a96cc
@@ -41,7 +41,7 @@ enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const
5a96cc
 	if (ndr_flags & NDR_SCALARS) {
5a96cc
 		NDR_CHECK(ndr_push_align(ndr, 4));
5a96cc
 		NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
5a96cc
-		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0)));
5a96cc
+		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,LIBNDR_FLAG_ALIGN8)));
5a96cc
 		{
5a96cc
 			uint32_t _flags_save_PAC_INFO = ndr->flags;
5a96cc
 			ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
5a96cc
@@ -59,7 +59,7 @@ enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const
5a96cc
 				{
5a96cc
 					struct ndr_push *_ndr_info_pad;
5a96cc
 					struct ndr_push *_ndr_info;
5a96cc
-					size_t _ndr_size = _ndr_size_PAC_INFO(r->info, r->type, 0);
5a96cc
+					size_t _ndr_size = _ndr_size_PAC_INFO(r->info, r->type, LIBNDR_FLAG_ALIGN8);
5a96cc
 					NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
5a96cc
 					NDR_CHECK(ndr_push_subcontext_start(_ndr_info_pad, &_ndr_info, 0, _ndr_size));
5a96cc
 					NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
5a96cc
-- 
5a96cc
2.33.1
5a96cc