Commit Graph

53 Commits

Author SHA1 Message Date
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
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
Luke Howard
7bb00a40ea kdc: fix Windows build 2022-01-04 13:08:35 +11:00
Luke Howard
a1fd5c176d kdc: fix misplaced semi-colons in ASTGS_REQUEST
ASTGS_REQUEST_DESC_COMMON_ELEMENTS should not terminate in a semi-colon;
the consuming structure should include it. This is consistent with
HEIM_SVC_REQUEST_DESC_COMMON_ELEMENTS. This fixes the build on Windows.
2022-01-04 13:07:18 +11:00
Luke Howard
ce58eb9081 kdc: annotate libkdc Windows function annotations
Annotate libkdc APIs with KDC_LIB_{CALL,FUNCTION} to ensure correct calling
convention and optimized DLL importing on Windows.

Ensure Windows and libtool export tables are consistent.
2022-01-04 12:27:43 +11:00
Luke Howard
e3a5169862 kdc: make common astgs_request_t elements public API 2021-12-23 17:49:36 -06:00
Joseph Sutton
b8c58191dc kdc: Optionally require that PAC be be present
This is from Samba's patches for CVE-2020-25719.

This allows Heimdal to match AD behaviour, when configured,
for the behaviour after Microsoft's CVE-2021-42287 when
PacRequestorEnforcement is set to 2.

Samba BUG: https://bugzilla.samba.org/show_bug.cgi?id=14686
REF: https://support.microsoft.com/en-au/topic/kb5008380-authentication-updates-cve-2021-42287-9dafac11-e0d0-4cb8-959a-143bd0201041

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

[abarlet@samba.org based on Samba commit
 756934f14cc87dc1adfd9315672ae5d49cb24d95
 and f7a2fef8f49a86f63c3dc2f6a2d7d979fb53238a]
2021-12-16 14:41:10 +11:00
Nicolas Williams
660f875a34 kdc: Add [kdc] params to control PA-ENC-TIMESTAMP 2021-12-14 17:32:20 +11:00
Luke Howard
49f3f5bd99 kdc: support for GSS-API pre-authentication
Add support for GSS-API pre-authentication to the KDC, using a simplified
variation of draft-perez-krb-wg-gss-preauth-02 that encodes GSS-API context
tokens directly in PADATA, and uses FX-COOKIE for state management.

More information on the protocol and implementation may be found in
lib/gssapi/preauth/README.md.
2021-08-12 17:37:01 +10:00
Andrew Bartlett
d5b6869dc7 Allow KDC to always return the salt in the PA-ETYPE-INFO[2]
This is to match the Windows KDC behaviour, optionally.

Samba will use this mode, as Samba has tests that show
the difference and is keen for bug-for-bug/byte-for-byte
rather than strict RFC compliance where there is a
reasonable choice.

The Samba test (for reference) is
samba.tests.krb5.as_canonicalization_tests

The behaviour was changed in:

commit de1f37a6aa
Author: Luke Howard <lukeh@padl.com>
Date:   Mon Jan 7 15:45:36 2019 +1100

    kdc: omit default salt from PA-ETYPE-INFO[2]

    If the salt for the AS-REP client key matches the default password salt for the
    client principal in the AS-REQ, then it can be omitted from the PA-ETYPE-INFO,
    PA-ETYPE-INFO2 (RFC4120) as the client will assume the default salt in its
    absence.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-08-09 23:20:08 +10:00
Nicolas Williams
00358252d3 kdc: Add synthetic PKINIT principals option 2021-06-29 14:52:07 -05:00
Nicolas Williams
a5e289f4f7 kdc: Add warn_ticket_addresses config option 2021-04-13 23:22:45 -05:00
Nicolas Williams
dc74e9d00c kdc: Add Heimdal cert ext for ticket max_life
This adds support for using a Heimdal-specific PKIX extension to derive
a maximum Kerberos ticket lifetime from a client's PKINIT certificate.

KDC configuration parameters:

 - pkinit_max_life_from_cert_extension
 - pkinit_max_life_bound

If `pkinit_max_life_from_cert_extension` is set to true then the
certificate extension or EKU will be checked.

If `pkinit_max_life_bound` is set to a positive relative time, then that
will be the upper bound of maximum Kerberos ticket lifetime derived from
these extensions.

The KDC config `pkinit_ticket_max_life_from_cert` that was added earlier
has been renamed to `pkinit_max_life_from_cert`.

See lib/hx509 and lib/krb5/krb5.conf.5.
2021-03-24 19:12:00 -05:00
Nicolas Williams
5447b81fb1 hdb: Move virtual principals into HDB layer
This is a large commit that adds several features:

 - Revamps and moves virtual host-based service principal functionality
   from kdc/ to lib/hdb/ so that it may be automatically visible to
   lib/kadm5/, as well as kadmin(1)/kadmind(8) and ktutil(1).

   The changes are backwards-incompatible.

 - Completes support for documenting a service principal's supported
   enctypes in its HDB entry independently of its long-term keys.  This
   will reduce HDB bloat by not requiring that service principals have
   more long-term keys than they need just to document the service's
   supported enctypes.

 - Adds support for storing krb5.conf content in principals' HDB
   entries.  This may eventually be used for causing Heimdal KDC
   services to reconfigure primary/secondary roles automatically by
   discovering the configured primary in an HDB entry for the realm.

   For now this will be used to help reduce the amount of configuration
   needed by clients of an upcoming HTTP binding of the kadmin service.
2020-09-08 00:25:36 -05:00
Nicolas Williams
1d5062b167 kdc: Modernize kx509 logging too 2019-12-11 19:34:36 -06:00
Roland C. Dowdeswell
430e18c074 kdc/process.c: add tracing messages. 2019-12-05 00:05:56 -05:00
Roland C. Dowdeswell
7d353d0557 Generate a single summary audit line for AS/TGS.
We refactor the code a bit to extend kdc_request_t which until now
was only used for the AS.  We make the structure extensible and
start using it for the TGS as well.  We leave digest and kx509
alone for the time being.

We also define the concept of kv-pairs in our audit trail which
allows us to define a rigorous but extensible format:

type error from-addr client server key1=val1 key2=val2 ...
2019-12-05 00:05:56 -05:00
Nicolas Williams
575c67806b Add bx509d 2019-12-04 21:34:44 -06:00
Roland C. Dowdeswell
aa5c525e71 Implement [kdc] derived_keys_maxdots 2019-10-18 14:47:33 -04:00
Roland C. Dowdeswell
366b787917 We provide a "derived key" mechanism to allow wildcard princs
In order to support certain use cases, we implement a mechanism to
allow wildcard principals to be defined and for the KDC to issue
tickets for said principals by deriving a key for them from a
cluster master entry in the HDB.

The way that this works is we defined an entry of the form:

	WELLKNOWN/DERIVED-KEY/KRB5-CRYPTO-PRFPLUS/<hostname>@REALM

When reading from the Kerberos DB, if we can't find an entry for
what looks like a hostbased principal, then we will attempt to
search for a principal of the above form chopping name components
off the front as we search.

If we find an entry, then we derive keys for it by using
krb5_crypto_prfplus() with the entry's key and the principal name
of the request.
2019-09-18 21:20:47 +01:00
Viktor Dukhovni
fae8df3839 Optional backwards-compatible anon-pkinit behaviour
* Anonymous pkinit responses from the KDC where the name
  type is not well-known (as issued by 7.5 KDCs and earlier)
  are accepted by the client.  There is no need for the client
  to strictly enforce the name type.

* With historical_anon_pkinit = true, the kinit(1) client's
  "--anonymous" option only performs anon pkinit, and does
  not require an '@' prefix for the realm argument.

* With historical_anon_realm = true, the KDC issues anon
  pkinit tickets with the legacy pre-7.0 "real" realm.
2019-09-04 18:00:15 -04:00
Nicolas Williams
9e2b696190 Make kdc name type strictness configurable 2016-11-14 21:29:47 -06:00
Roland C. Dowdeswell
352a7e94a3 Make the KDC use a multi-process model.
We now fork(2) a number of separate KDC processes rather than a single
process.  By default, the number is selected by asking how many CPUs
the machine has.  We also have a master process which monitors all
of the children (which do the actual work) and it will restart kids
who die for any reason.  The children will die when the parent dies.

In the case of MacOS X, we also move the bonjour code into another
separate child as it creates threads and this is known to play
rather poorly with fork(2).  We could move this logic into a
designated child at some point in the future.

We slow down the spawning to one every 25ms to prevent instant crashes
and restarts from consuming all available system time.  This approach
may want to be revisited in the future.
2015-11-06 15:39:30 -05:00
Nicolas Williams
c757eb7fb0 Rename and fix as/tgs-use-strongest-key config parameters
Different ticket session key enctype selection options should
    distinguish between target principal type (krbtgt vs. not), not
    between KDC request types.
2011-11-25 17:21:04 -06:00
Nicolas Williams
256cf6ea12 This patch adds support for a use-strongest-server-key krb5.conf kdc parameter that controls how the KDC (AS and TGS) selects a long-term key from a service principal's HDB entry. If TRUE the KDC picks the strongest supported key from the service principal's current keyset. If FALSE the KDC picks the first supported key from the service principal's current keyset.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-06-14 20:35:19 -07:00
Nicolas Williams
481fe133b2 Also added preauth-use-strongest-session-key krb5.conf kdc parameter, similar to {as, tgs}-use-strongest-session-key. The latter two control ticket session key enctype selection in the AS and TGS cases, respectively, while the former controls PA-ETYPE-INFO2 enctype selection in the AS case.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-06-14 20:35:19 -07:00
Nicolas Williams
a7a8a7e95c Initial patch to add as-use-strongest-session-key and same for tgs krb5.conf parameters for the KDC. These control the session key enctype selection algorithm for the AS and TGS respectively: if TRUE then they prefer the strongest enctype supported by the client, the KDC and the target principal, else they prefer the first enctype fromt he client's list that is also supported by the KDC and the target principal.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-06-14 20:35:19 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
657297a738 clean the last bits of KRB4 support in KDC 2011-05-07 11:44:15 -07:00
Jelmer Vernooij
e380769729 kdc.h: Include hdb.h first, so kdc.h can be included standalone.
This makes it a bit easier to find libhdb in e.g. configure tests and
is consistent with the main header files for the other Heimdal
libraries, none of which has any prerequisite other headers.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-02-26 13:06:15 -08:00
Love Hornquist Astrand
847161193c constify pkinit conf 2009-11-22 00:28:33 -08:00
Love Hörnquist Åstrand
1d0eb4dad8 add proxy bit
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24999 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-29 09:04:50 +00:00
Love Hörnquist Åstrand
9ec7eb49c4 force submodules to claim the package
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24531 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-26 01:30:59 +00:00
Love Hörnquist Åstrand
5ca7ee453e drop name
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24529 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-26 01:30:25 +00:00
Love Hörnquist Åstrand
c74df06f20 fix length bits
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24526 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-26 01:19:27 +00:00
Love Hörnquist Åstrand
2437f18d3b add krb5_kdc_service
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24492 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-26 01:08:35 +00:00
Love Hörnquist Åstrand
0c4d8d3a16 Add switch to select friendly_name of the certificate.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24195 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:31:22 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
ced5a6d55f rename pkinit_princ_in_cert and add pkinit_require_binding
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21287 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 14:09:03 +00:00
Love Hörnquist Åstrand
95d9226959 add kx509 config
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19907 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-14 23:10:24 +00:00
Love Hörnquist Åstrand
95207976c0 add enable_kx509
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19549 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-28 21:06:56 +00:00
Love Hörnquist Åstrand
450b14e4e3 add digests_allowed
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19506 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-26 14:24:27 +00:00
Love Hörnquist Åstrand
6e093638af (krb5_kdc_config): Add max_datagram_reply_length.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18382 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-09 15:34:07 +00:00
Love Hörnquist Åstrand
7ae6f1fbd6 (krb5_kdc_configuration): Add enable_digest
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17910 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-08-24 08:51:15 +00:00
Love Hörnquist Åstrand
8e6754870a Add enable_v4_per_principal
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17646 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-06-14 18:26:18 +00:00
Love Hörnquist Åstrand
b5cc2fa7aa (krb5_kdc_configuration): add pkinit_kdc_ocsp_file
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17413 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-03 12:03:29 +00:00
Love Hörnquist Åstrand
2e2d62a9e5 Add pkinit_dh_min_bits to krb5_kdc_configuration.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16208 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-10-21 17:11:21 +00:00
Love Hörnquist Åstrand
7a3fc5e663 Don't pollute namespace, generate public headerfile
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15532 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-30 01:54:49 +00:00