From c2ab1f4696fa3f52918a126d0b37993a07f68bcb Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Tue, 7 Jun 2022 17:36:43 +1200 Subject: [PATCH] CVE-2022-32743 dsdb/common: Add FORCE_ALLOW_VALIDATED_DNS_HOSTNAME_SPN_WRITE control Passing this control will grant the right to set validated values for dNSHostName and servicePrincipalName, and non-validated values for other attributes. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14833 Signed-off-by: Joseph Sutton Reviewed-by: Douglas Bagnall --- source4/dsdb/common/util.c | 7 +++++++ source4/dsdb/samdb/ldb_modules/util.h | 1 + source4/dsdb/samdb/samdb.h | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 112917544a3..88b05555b96 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -4546,6 +4546,13 @@ int dsdb_request_add_controls(struct ldb_request *req, uint32_t dsdb_flags) } } + if (dsdb_flags & DSDB_FLAG_FORCE_ALLOW_VALIDATED_DNS_HOSTNAME_SPN_WRITE) { + ret = ldb_request_add_control(req, DSDB_CONTROL_FORCE_ALLOW_VALIDATED_DNS_HOSTNAME_SPN_WRITE_OID, true, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } + } + return LDB_SUCCESS; } diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h index 5ecf0eee0d2..937767a9dee 100644 --- a/source4/dsdb/samdb/ldb_modules/util.h +++ b/source4/dsdb/samdb/ldb_modules/util.h @@ -39,3 +39,4 @@ struct netlogon_samlogon_response; #define DSDB_FLAG_TOP_MODULE 0x00800000 #define DSDB_FLAG_TRUSTED 0x01000000 #define DSDB_FLAG_REPLICATED_UPDATE 0x02000000 +#define DSDB_FLAG_FORCE_ALLOW_VALIDATED_DNS_HOSTNAME_SPN_WRITE 0x04000000 diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 286c97f2ea5..3db7704307f 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -226,6 +226,12 @@ struct dsdb_control_transaction_identifier { struct GUID transaction_guid; }; +/* + * passed when we want to allow validated writes to dNSHostName and + * servicePrincipalName. + */ +#define DSDB_CONTROL_FORCE_ALLOW_VALIDATED_DNS_HOSTNAME_SPN_WRITE_OID "1.3.6.1.4.1.7165.4.3.35" + #define DSDB_EXTENDED_REPLICATED_OBJECTS_OID "1.3.6.1.4.1.7165.4.4.1" struct dsdb_extended_replicated_object { struct ldb_message *msg;