Commit Graph

2022 Commits

Author SHA1 Message Date
Nicolas Williams
b349b4add0 kdc: Fix recent dangling ptr; move more into r
As we move more and more state into astgs_request_t we need to be
careful not to leave locals and function arguments aliasing objects from
the astgs_request_t.
2022-01-18 15:32:05 -06:00
Nicolas Williams
f155150969 kdc: Rewrite get_pa_etype_info and set_salt_padata
We weren't checking for errors, and we weren't using the convience
SEQUENCE OF add_METHOD_DATA() and add_ETYPE_INFO() functions generated
by the ASN.1 compiler.  Using those utilities made get_pa_etype_info()
and make_etype_info_entry() sufficiently simpler that merging the two
makes for simpler, more readable code.
2022-01-18 09:14:29 -05:00
Nicolas Williams
a1481f1f05 kdc: Check krb5_ret_uint32() in connect loop 2022-01-18 00:42:11 -06:00
Nicolas Williams
fcba7a9fd1 kdc: Check errors from krb5_auth_con_getauthenticator() 2022-01-18 00:32:51 -06:00
Nicolas Williams
1a08b3b47f kdc: Make --kdc-request-log-file concrrency-safe
Build the entry to write to the log file in memory, the write it with
O_APPEND.  This should make writes to the request log file safer in
multi-process KDC configurations.

Also, check results of krb5_store_*() functions (coverity alerted to
this).
2022-01-18 00:19:15 -06:00
Nicolas Williams
d41467dcde kdc: Explicitly ignore setsockopt() result 2022-01-18 00:16:09 -06:00
Luke Howard
bc37bf1afd kdc: use public audit API in altsecid authorizer plugin
Regression fix for 94ed961d02 when building
altsecid_gss_preauth_authorizer.
2022-01-18 16:27:05 +11:00
Luke Howard
94ed961d02 kdc: make auditing API public
Samba plugins will need to use auditing API without including krb5-private.h,
so make the auditing APIs public.
2022-01-18 16:09:50 +11:00
Luke Howard
4befd3e355 kdc: remove krb5_ prefix for KDC attribute functions
We will use the kdc_ rather than krb5_kdc_ prefix for new public APIs exported
from libkdc. Amend the recently introduced
request_{get,set,copy,delete}_attribute APIs to conform.
2022-01-17 23:50:04 -05:00
Jeffrey Altman
238fd7c6c6 kdc: kdc_issue_certificate remove dead code
'ret' cannot equal EACCES after setting it to KRB5KDC_ERR_POLICY.

Change-Id: I2fbb0c91f6fdc541813685fde26229833fa56e42
2022-01-17 22:41:33 -05:00
Jeffrey Altman
2cd3f7089e kdc: cmd_append fix broken commit
4101280459
("kdc: cmd_append do not forget va_end()")

Change-Id: Ief8b8b4a5c85a38c799e2aa554e845728a92b1fd
2022-01-17 22:36:29 -05:00
Jeffrey Altman
4101280459 kdc: cmd_append do not forget va_end()
If va_start() is called then va_end() must be called before
returning.

Change-Id: I5312cf9b6ff238fc76bea248472302d5094bbc2b
2022-01-17 22:05:36 -05:00
Jeffrey Altman
d0e2467120 kdc: _kdc_do_kx509 prevent use of NULL cprincipal
If the return code is non-zero do not call krb5_unparse_name()
as cprincipal will be NULL.

Change-Id: I901b3f5dcdbc186f89257aef935b91e1d207119c
2022-01-17 21:57:07 -05:00
Jeffrey Altman
4b6fb5ab1a kdc: _kdc_find_etype prevent NULL dereference
If use_strongest_session_key and no keys are found the return
code will be set to KRB5KDC_ERR_ETYPE_NOSUPP.  However, before
exiting if the principal is a weak exception then the return
code will be set to success and a NULL key pointer will be
dereferenced.   Skip the weak exception check if the return
code is non-zero.

Change-Id: I36d0e1b179b3392171ad6767c75111d59c3f2f7d
2022-01-17 21:51:57 -05:00
Nicolas Williams
7cfab00e37 kdc: One more memcmp() implicit comparison to 0 2022-01-17 15:17:33 -06:00
Joseph Sutton
9a0372d992 kdc: Still prefer encryption types with "not default" salts except for des-cbc-crc
Samba clients are often machine accounts with non-default salts that
will fail if they can't use the AES encryption type they know the KDC
supports.  The problem is that arcfour-hmac-md5 has no salt so was
being used in preference.

Samba started to fail when

kdc_config->preauth_use_strongest_session_key = true;

was forced into the KDC configuration.

The history here is an attempt to avoid Kerberos v4 salts in des-cbc-crc
keys, but this instead broke Samba clients with AES-keys on machine accounts
as these have a non-default salt by default.  These accounts were incorrectly
restricted to arcfour-hmac-md5 and they didn't like that.

A broader fix than Samba commit 8e1efd8bd3bf698dc0b6ed2081919f49b1412b53

REF: https://lists.samba.org/archive/samba/2021-October/237844.html

Samba BUG: https://bugzilla.samba.org/show_bug.cgi?id=14864

Change-Id: Ia8908a5a2eef107e6b133d7f0e4343c1988c18bb
2022-01-17 15:42:03 -05:00
Nicolas Williams
bf243c1f41 kdc: Fix ENOMEM path null deref (synthetic princs) 2022-01-17 12:20:15 -06:00
Nicolas Williams
04b07ff8b6 kdc: Quiet a coverity warning (TGS) 2022-01-17 11:05:05 -06:00
Nicolas Williams
3e51a0b84a kdc: Quiet a coverity warning 2022-01-17 11:04:21 -06:00
Nicolas Williams
4d5c5c6737 kdc: Add missing encryption retval check 2022-01-17 10:47:41 -06:00
Nicolas Williams
3d9333cefa kdc: Fix build 2022-01-16 23:08:49 -06:00
Jeffrey Altman
1383677642 kdc: update_csr do not leak error messages
Change-Id: I478bf001ebf555dce067916e7198053ef3a0bd08
2022-01-16 23:28:13 -05:00
Jeffrey Altman
423acdfe77 kdc: check_authz free 'cprinc' on success
Change-Id: I1823a4d74c7c2823f2148f694bff1fc064d834ed
2022-01-16 23:25:06 -05:00
Jeffrey Altman
708d9b4042 hx509_request_get_san can return an output string on failure
Tighten up all of the call sites of hx509_request_get_san()
to free the output string returned upon failure.

Use frees(&s) instead of free(s); s = NULL;.

Change-Id: I71035d7c1d2330a1a3a1b3b730cdd6ba1e6b7da3
2022-01-16 21:49:10 -05:00
Luke Howard
0a59cbca51 kdc: use memset rather than {0} to initialize fxreq 2022-01-17 10:05:59 +11:00
Jeffrey Altman
65276af7f6 kdc: fast_unwrap_request use memset to init fastreq
Change-Id: I4e872126f5c1deb48d36f5bdac22da7c0df3c8a1
warning: missing braces around initializer [-Wmissing-braces]
warning: (near initialization for 'fastreq.fast_options') [-Wmissing-braces]
warning: missing initializer for field 'padata' of 'struct KrbFastReq' [-Wmissing-field-initializers]
2022-01-16 16:00:40 -05:00
Nicolas Williams
b889942340 bx509d: Add missing check of result of key2SPKI() 2022-01-16 13:12:22 -06:00
Jeffrey Altman
1685c34b0d remove (krb5_enctype) cast for ETYPE_xxx
Now that ETYPE_xxx names are macros to the KRB5_ENCTYPE_xxx
symbols there is no longer a need to cast to (krb5_enctype).

Change-Id: Ib561f6e45346abac7a53eb1db0bfef60ee3bcb74
2022-01-15 22:05:50 -05:00
Luke Howard
0e8c4ccc6e hdb: eliminate hdb_entry_ex
Remove hdb_entry_ex and revert to the original design of hdb_entry (except with
an additional context member in hdb_entry which is managed by the free_entry
method in HDB).
2022-01-15 18:54:57 +11:00
Luke Howard
c5551775e2 hdb: decorate HDB_entry with context member
Decorate HDB_entry with context and move free_entry callback into HDB structure
itself. Requires updating hdb_free_entry() signature to include HDB parameter.
A follow-up commit will consolidate hdb_entry_ex (which has a single hdb_entry
member) into hdb_entry.
2022-01-15 18:54:57 +11:00
Nicolas Williams
f076ed57cc Fix make dist 2022-01-14 20:10:19 -06:00
Nicolas Williams
cf2bab411d kdc: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
5a3706db5b httpkadmind: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
5dcad4635b bx509d: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
23190a3f5e hpropd: Fix warning 2022-01-14 17:54:55 -06:00
Nicolas Williams
3c1c48c68f kstash: Fix warning 2022-01-14 17:54:55 -06:00
Nicolas Williams
05e8c0ede6 Check HMAC_Init_ex() return value 2022-01-14 12:48:32 -06:00
Nicolas Williams
581ca3d44f httpkadmind: Build with older libmicrohttpd (fix GH CI) 2022-01-13 15:33:04 -06:00
Nicolas Williams
aa8eb19b8e bx509d: Build with older libmicrohttpd (fix GH CI) 2022-01-13 15:33:04 -06:00
Nicolas Williams
0c7b06f9ca cf: Check cc support of -Werror=enum-conversion 2022-01-13 15:33:04 -06:00
Luke Howard
6530021f09 kdc: move auth event definitions into KDC header
Move KDC auth event macro definitions out of hdb.h and into a new KDC header,
kdc-audit.h.
2022-01-13 14:51:31 +11:00
Nicolas Williams
6ee1554f3e Ignore enum-conversion errors
This is not a very good fix, though the warnings remain.  Such errors
can in principle be a problem because in C there is no standard enum
sizing.

In this case we have two enums with the same elements and so the same
size, so it's clearly not a problem.
2022-01-11 17:15:59 -06:00
Luke Howard
10fc7730d0 kdc: send request, not TGS, server name in TGS errors
Return the request server principal name in TGS errors rather than the TGS
server name.
2022-01-10 15:29:49 +11:00
Luke Howard
40e4a4df09 kdc: use astgs_request_t for client/server name (TGS)
Store the client and server principal name from the TGT and request
(respectively) in the astgs_request_t rather than using local variables.
2022-01-10 15:29:49 +11:00
Luke Howard
1dd5aa2f5d kdc: don't leak etype/error message in pa_enc_ts_validate()
Recent auditing changes (b1dcc1a4) introduced a leak into pa_enc_ts_validate()
where the encryption type name and error message could be leaked.

This patch fixes a compile error in the original commit.
2022-01-08 14:12:26 +11:00
Luke Howard
6f0727fa00 Revert "kdc: don't leak etype/error message in pa_enc_ts_validate()"
This reverts commit ed2579e8af.
2022-01-08 14:12:06 +11:00
Luke Howard
ed2579e8af kdc: don't leak etype/error message in pa_enc_ts_validate()
Recent auditing changes (b1dcc1a4) introduced a leak into pa_enc_ts_validate()
where the encryption type name and error message could be leaked.
2022-01-08 14:10:51 +11:00
Luke Howard
7cc4b7a9e6 kdc: KDC plugin API contract notes
Add some notes about the KDC plugin API contract, and require plugins to
explicitly indicate which version of the API they support (remove the macro
alias for the current version).
2022-01-05 13:08:11 +11:00
Luke Howard
78ad37ee47 kdc: use r->canon_client_princ field in AS
r->canon_client_princ is always an alias to r->client->entry.principal in the
AS, but use it for consistency with the TGS. (In the TGS, it may also come from
te PAC.)
2022-01-05 13:01:06 +11:00
Luke Howard
0287558838 kdc: move Services for User implementation out of krb5tgs.c
Move the Services for User (SFU/S4U) implementation -- protocol transition and
constrained delegation -- into its own compilation unit, with an interface that
only takes an astgs_request_t, so it can be easily factored out into a plugin
module in the future.

This refactoring is also careful to update all client names in the request
structure after the SFU/S4U validation has successfully completed.
2022-01-05 13:01:06 +11:00