From: Stefan Metzmacher Date: Tue, 29 Nov 2022 13:13:36 +0000 (+0100) Subject: CVE-2022-37966 param: Add support for new option "kdc supported enctypes" X-Git-Tag: samba-4.15.13~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18996e9971224210aa50cff9796c805dc594c296;p=thirdparty%2Fsamba.git CVE-2022-37966 param: Add support for new option "kdc supported enctypes" This allows admins to disable enctypes completely if required. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15237 Signed-off-by: Stefan Metzmacher Reviewed-by: Joseph Sutton Reviewed-by: Andrew Bartlett (cherry picked from commit 36d0a495159f72633f1f41deec979095417a1727) --- diff --git a/docs-xml/smbdotconf/security/kdcsupportedenctypes.xml b/docs-xml/smbdotconf/security/kdcsupportedenctypes.xml new file mode 100644 index 00000000000..5e028bbb2be --- /dev/null +++ b/docs-xml/smbdotconf/security/kdcsupportedenctypes.xml @@ -0,0 +1,40 @@ + + + + On an active directory domain controller, this is the list of supported encryption types for local running kdc. + + + + This allows Samba administrators to remove support for weak/unused encryption types, similar + the configuration flexibility provided by the Network security: Configure encryption types allowed for Kerberos + GPO/Local Policies/Security Options Value, which results in the + HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Kerberos\Parameters\SupportedEncryptionTypes Registry Value on Windows. + + + Unlike the Windows registry key (which only takes an base-10 number), in Samba this may also be expressed as hexadecimal or a list of Kerberos encryption type names. + + + Specified values are ORed together bitwise, and those currently supported consist of: + + + arcfour-hmac-md5, rc4-hmac, 0x4, or 4 + Known on Windows as Kerberos RC4 encryption + + + aes128-cts-hmac-sha1-96, aes128-cts, 0x8, or 8 + Known on Windows as Kerberos AES 128 bit encryption + + + aes256-cts-hmac-sha1-96, aes256-cts, 0x10, or 16 + Known on Windows as Kerberos AES 256 bit encryption + + + + + +0maps to what the software supports currently: arcfour-hmac-md5 aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 + diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index d55df1f4f80..44292c3cbbb 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -1778,6 +1778,75 @@ out: return ok; } +bool handle_kdc_supported_enctypes(struct loadparm_context *lp_ctx, + struct loadparm_service *service, + const char *pszParmValue, char **ptr) +{ + char **enctype_list = NULL; + char **enctype = NULL; + uint32_t result = 0; + bool ok = true; + + enctype_list = str_list_make(NULL, pszParmValue, NULL); + if (enctype_list == NULL) { + DBG_ERR("OOM: failed to make string list from %s\n", + pszParmValue); + ok = false; + goto out; + } + + for (enctype = enctype_list; *enctype != NULL; ++enctype) { + if (strwicmp(*enctype, "arcfour-hmac-md5") == 0 || + strwicmp(*enctype, "rc4-hmac") == 0) + { + result |= KERB_ENCTYPE_RC4_HMAC_MD5; + } + else if (strwicmp(*enctype, "aes128-cts-hmac-sha1-96") == 0 || + strwicmp(*enctype, "aes128-cts") == 0) + { + result |= KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96; + } + else if (strwicmp(*enctype, "aes256-cts-hmac-sha1-96") == 0 || + strwicmp(*enctype, "aes256-cts") == 0) + { + result |= KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96; + } + else { + const char *bitstr = *enctype; + int base; + int error; + unsigned long bit; + + /* See if the bit's specified in hexadecimal. */ + if (bitstr[0] == '0' && + (bitstr[1] == 'x' || bitstr[2] == 'X')) + { + base = 16; + bitstr += 2; + } + else { + base = 10; + } + + bit = smb_strtoul(bitstr, NULL, base, &error, SMB_STR_FULL_STR_CONV); + if (error) { + DBG_ERR("WARNING: Ignoring invalid value '%s' " + "for parameter 'kdc default domain supported enctypes'\n", + *enctype); + ok = false; + } else { + result |= bit; + } + } + } + + *(int *)ptr = result; +out: + TALLOC_FREE(enctype_list); + + return ok; +} + static bool set_variable(TALLOC_CTX *mem_ctx, struct loadparm_service *service, int parmnum, void *parm_ptr, const char *pszParmName, const char *pszParmValue,