Commit Graph

2052 Commits

Author SHA1 Message Date
Nicolas Williams
4c71d1bf06 bx509: Fix typos in commentary 2022-08-07 18:59:28 -05:00
Joseph Sutton
b19633f9b9 Use constant-time memcmp when comparing sensitive buffers
This helps to avoid timing attacks.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-04-30 13:35:52 -04:00
Nicolas Williams
d93f0d103d httpkadmind: Clarify namespace in man page 2022-04-26 17:54:12 -05:00
Nicolas Williams
a5271cd765 httpkadmind: Enable materialization 2022-04-25 22:24:52 -05:00
Nicolas Williams
18f44e7e90 httpkadmind: Make get_keys_max_spns configurable 2022-04-25 22:24:51 -05:00
Nicolas Williams
a5273d18cd httpkadmind: Support ok-as-delegate and such
Add support for configuring the attributes of new principals created via
httpkadmind.  This can be done via virtual host-based service
namespaces, which will provide default attributes even if disabled (but
the created principals will not be disabled, naturally), or via
krb5.conf.
2022-04-25 22:24:51 -05:00
Nicolas Williams
dcef1341d3 kdc: Add error symbols for error logging
Having "KRB5KRB_AP_ERR_ILL_CR_TKT" in log messages is much better than
"UNKNOWN--1765328341".
2022-03-16 15:04:10 -05:00
Joseph Sutton
d5ad04a7f3 kdc: Add function to add encrypted padata
Since plugins no longer have a way of accessing the 'ek' member of the
request structure, this function provides a way for a plugin to add
encrypted padata to the response.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-03-08 18:58:17 +11:00
Luke Howard
df655cecd1 kdc: allow audit plugins to influence return code
Honor the return code of _kdc_audit_request(), propagating if non-zero. Note
that this is principally intended to allow the audit plugin to return
HDB_ERR_NOT_FOUND_HERE, which influences whether the KDC sends an error reply
or not. If the audit plugin also wishes to rewrite r->error_code, it must do so
separately.

Closes: #964
2022-03-03 10:10:37 +11:00
Stefan Metzmacher
8495f63bc3 kdc: provide kdc_request_get_explicit_armor_{clientdb,client,pac}()
_kdc_fast_check_armor_pac() already checks the PAC of the armor,
but it should also remember it if it's an TGS-REQ with explicit armor.

This will allow the kdc pac hooks to generate a compound identity PAC
with PAC_TYPE_DEVICE_INFO.

Signed-off-by: Stefan Metzmacher <metze@samba.org>

Closes: #967
2022-03-03 10:10:29 +11:00
Stefan Metzmacher
11d8a053f5 kdc-plugin: also pass astgs_request_t to the pac related functions
This is more consistent and allows the pac hooks to be more flexible.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-03 09:58:48 +11:00
Nicolas Williams
419610aa14 kdc: HDB max_life/max_renew == 0 -> unlimited 2022-02-15 20:16:29 -06:00
Nicolas Williams
e7e2c7a145 kdc: Honor "unlimited" max_life/max_renew 2022-02-15 16:56:27 -06:00
Nicolas Williams
2c8a078bcf bx509d: Do not leak temp ccaches 2022-02-14 21:07:47 -06:00
Luke Howard
69973757ce gss: remove gss_get_instance() 2022-01-30 14:20:05 -05:00
Jeffrey Altman
543b94637f more dealloc functions require HEIM_CALLCONV
Change-Id: I68168a387c088b45e2572d5c982d33dfe0aa38a8
2022-01-29 00:15:59 -05:00
Luke Howard
87e96b97bd kdc: fix warning in kdc_array_iterate()
Do not call return in a function returning void.
2022-01-29 10:26:54 +11:00
Luke Howard
144caf67fa kdc: add wrappers for heimbase object accessors
Add libkdc wrappers for heimbase object accessors so plugins can use audit and
request attribute APIs without consuming libheimbase. Exposed API surface is
minimal and is limited to reading array collections, and reading/creating base
and custom types.
2022-01-28 17:24:57 -06:00
Luke Howard
5a579901fd kdc: fix warning in GSS pre-authentication support
Do not read an int32_t directly into a CKSUMTYPE enum.
2022-01-29 10:23:09 +11:00
Jeffrey Altman
eb08f2ecdd kdc: _kdc_find_etype if is_preauth must use long term keys
is_preauth (KFE_IS_PREAUTH is set) might require replying with
PA-ETYPE-INFO[2] which requires use of the long-term keys.
Without this change is_default_salt_p() can be called with 'key'
eq NULL.

Change-Id: I513fa768680225d4501d8b390e349a011666d90c
2022-01-24 10:41:51 -05:00
Jeffrey Altman
d80a1b9556 kdc: hprop propagate_database do not leak 'server'
Change-Id: I0b2b6343134603ecffb6cd827d0828463378cff4
2022-01-23 22:25:43 -05:00
Jeffrey Altman
a3f4a0bf0b kdc: hprop check return code if local realm
If 'local_realm' is true, must protect against failure
of krb5_get_default_realm() and krb5_principal_set_realm().
Otherwise, the wrong realm might be used.

Change-Id: Ib7a92559da1ac062c71228c5530106a13d836d53
2022-01-23 21:59:13 -05:00
Luke Howard
366878c230 kdc: kdc_request_add_pac_buffer() make pactype unsigned
The pactype argument to kdc_request_add_pac_buffer() should be unsigned,
matching krb5_pac_add_buffer(). Reindent.
2022-01-22 11:43:38 +11:00
Luke Howard
fce4d19953 kdc: declare calling/linkage conventions for accessors
Decorate generated accessors with KDC_LIB_FUNCTION/KDC_LIB_CALL for correct
linkage on Windows.
2022-01-21 08:22:07 +11:00
Nicolas Williams
588e49a1bc kdc: Fix copy_Principal_ptr() bug (plugin acc.) 2022-01-20 13:32:31 -06:00
Luke Howard
e32f7a4387 kdc: add _nocopy setter for use by mssfu
Add an internal-use setter accessor for use by mssfu.c when principal names are
replaced. This also fixes a leak where r->client_princ was not freed before
being replaced with the impersonated client name.
2022-01-20 17:23:24 +11:00
Luke Howard
ec24edf700 kdc: add accessor functions for KDC request structure
Add accessor functions for use by Samba and other plugin developers.
Documentation is in kdc/kdc-accessors.h.
2022-01-20 17:23:24 +11:00
Luke Howard
ed4fe65794 base: change ret fieldname to error_code in request struct 2022-01-20 17:23:24 +11:00
Nicolas Williams
302250026c kdc: Do not announce via Bonjour when testing
Let's see if this fixes the GitHub Actions OS X CI.
2022-01-20 00:20:30 -06:00
Nicolas Williams
c650e37321 kdc: Fix leak caused by a1481f1f0 2022-01-19 17:32:16 -06:00
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