Commit Graph

34 Commits

Author SHA1 Message Date
Luke Howard
f7964251ff kdc: support for PAC_ATTRIBUTES_INFO
Add PAC_ATTRIBUTES_INFO to the PAC. This info buffer indicates whether the user
explicitly requested a PAC be present or absent.

Note: this changes the windc plugin ABI.
2021-12-22 10:36:26 +11:00
Luke Howard
2087e07c1e kdc: update PAC hooks for Samba
Samba includes the user's long-term credentials (encrypted in the AS reply key)
to allow legacy authentication protocols such as NTLM to work even if the
pre-authentication mechanism replaced the reply key (as PKINIT does).

Samba also needs to know whether the client explicitly requested a PAC be
included (or excluded), in order to defer PAC exclusion until a service ticket
is issued (thereby avoiding a name binding attack if the user is renamed
between TGT and service ticket issuance).

References:

https://bugzilla.samba.org/show_bug.cgi?id=11441
https://bugzilla.samba.org/show_bug.cgi?id=14561

Closes: #864

Original authors:
 - Joseph Sutton <josephsutton@catalyst.net.nz>
 - Andrew Bartlett <abartlet@samba.org>
 - Stefan Metzmacher <metze@samba.org>
2021-12-14 13:51:53 +11:00
Luke Howard
007cc9fdc3 kdc: remove temporary krb5_context variable
Use r->context (from request) instead of a temporary context variable, where
available.
2021-12-14 09:03:42 +11:00
Nicolas Williams
7672ad31db kdc: Fix leak and loss of kdc_check_flags() reason
We were losing and leaking the reason for which kdc_check_flags() was
rejecting any S4U requests, yielding incomplete error messages.

The issue is that kdc_check_flags() wants to check the client and server
principals in the input state structure, but doesn't know about
impersonated principal name, and so we want to pass it a state structure
that has the impersonated instead of the impersonator client name.  This
is a bad design, but I'm ignoring that for now and just fixing this one
leak.
2021-10-11 13:58:15 -05:00
Isaac Boukris
2ffaba9401 kdc: sign ticket using Windows PAC
Split Windows PAC signing and verification logic, as the signing has to be when
the ticket is ready.

Create sign and verify the PAC KDC signature if the plugin did not, allowing
for S4U2Proxy to work, instead of KRB5SignedPath.

Use the header key to verify PAC server signature, as the same key used to
encrypt/decrypt the ticket should be used for PAC server signature, like U2U
tickets are signed witht the tgt session-key and not with the longterm key,
and so krbtgt should be no different and the header key should be used.

Lookup the delegated client in DB instead of passing the delegator DB entry.

Add PAC ticket-signatures and related functions.

Note: due to the change from KRB5SignedPath to PAC, S4U2Proxy requests
against new KDC will not work if the evidence ticket was acquired from
an old KDC, and vide versa.

Closes: #767
2021-09-19 13:25:27 +10: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
Nicolas Williams
ea90ca8666 Move some infra bits of lib/krb5/ to lib/base/ (2)
This is the second of two commits in a series that must be picked together.

This series of two commits moves parts of lib/krb5/ infrastructure
functionality to lib/base/, leaving behind wrappers.

Some parts of libkrb5 are entirely generic or easily made so, and could
be useful in various parts of Heimdal that are not specific to the krb5
API, such as:

 - lib/gssapi/  (especially since the integration of NegoEx)
 - lib/hx509/
 - bx509d       (which should really move out of kdc/)

For the above we need to move these bits of lib/krb5/:

 - lib/krb5/config_file.c   (all of it, leaving forwardings behind)
 - lib/krb5/config_reg.c    (all of it)
 - lib/krb5/plugin.c        (all of it, leaving forwardings behind)
 - lib/krb5/log.c           (all of it, ditto)
 - lib/krb5/heim_err.et     (all of it)

And because of those two, these too must also move:

 - lib/krb5/expand_path.c   (all of it, leaving forwardings behind)
 - lib/krb5/warn.c          (just the warning functions, ditto)

The changes to the moved files are mostly quite straightforward and are
best reviewed with --word-diff=color.

We're also creating a heim_context and a heim API to go with it.  But
it's as thin as possible, with as little state as necessary to enable
this move.  Functions for dealing with error messages use callbacks.

Moving plugin.c does have one knock-on effect on all users of the old
krb5 plugin API (which remains), which is that a global search and
replace of struct krb5_plugin_data to struct heim_plugin_data was
needed, though the layout and size of that structure doesn't change, so
the ABI doesn't either.

As well, we now build lib/vers/ and lib/com_err/ before lib/base/ so as
to be able to move lib/krb5/heim_err.et to lib/base/ so that we can make
use of HEIM_ERR_* in lib/base/, specifically in the files that moved.

Once this is all done we'll be able to use config files and plugins in
lib/hx509/, we'll be able to move bx509d out of kdc/, and so on.

Most if not all of the new functions in lib/base/ are Heimdal-private,
thus calling conventions for them are not declared.

Status:

 - builds and passes CIs (Travis, Appveyor)
 - ran make check-valgrind and no new leaks or other memory errors
 - ready for review

HOW TO REVIEW:

     $ # Review file moves:
     $ git log --stat -n1 HEAD^
     $
     $ # Review changes to moved files using --word-diff=color
     $ git log -p -b -w --word-diff=color HEAD^..HEAD   \
               lib/base/config_file.c                   \
               lib/base/config_reg.c                    \
               lib/base/expand_path.c                   \
               lib/base/warn.c                          \
               lib/krb5/config_file.c                   \
               lib/krb5/config_reg.c                    \
               lib/krb5/expand_path.c                   \
               lib/krb5/warn.c
     $
     $ # Review the whole thing, possibly adding -b and/or -w, and
     $ # maybe --word-diff=color:
     $ git log -p origin/master..HEAD
     $ git log -p -b -w origin/master..HEAD
     $ git log -p -b -w --word-diff=color origin/master..HEAD

TBD (future commits):

 - make lib/gssapi use the new heimbase functions
 - move kx509/bx509d common code to lib/hx509/ or other approp. location
 - move bx509d out of kdc/
2020-03-02 10:56:13 -06:00
Roland C. Dowdeswell
6db323157f Reduce older log messages to level 4 and collect some errors.
We take all of the kdc_log() and _kdc_r_log() calls in AS and TGS
and move their log levels down to debugging on the assumption that
our new log line subsumes the "informational" requirements.  We
collect some additional information in the kv-pair "pe-text" which
is like e-text except it is not returned to the client.
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
Jeffrey Altman
387684aa93 WIN32: fix calling conventions for 32-bit builds
On 32-bit Windows Intel builds the __cdecl and __stdcall calling
conventions are different so labeling the functions that are
exported or assigned to function pointers matters.

Change-Id: I03b6f34baeb9ffb2e683fd979f12f27a5078a4da
2019-01-14 06:12:36 -05:00
Luke Howard
803efebca5 krb5, kadm5: refactor plugin API
Refactor plugin framework to use a single list of loaded plugins; add a new
plugin API where DSOs export a load function that can declare dependencies and
export multiple plugins; refactor kadm5 hook API to use krb5 plugin framework.

More information in krb5-plugin(7).
2019-01-03 20:06:27 -06:00
Nicolas Williams
812b01b4ed Fix KDC segfault with OS X plugins
At least one "windc" plugin provided by OS X lacks a client_access()
entry point and caused the KDC to crash.  The KDC now checks for each
entry point in "windc" plugins and either falls back on alternative
default functionality or fails more gracefully than by crashing.
2016-06-09 01:13:15 -04:00
Love Hornquist Astrand
f53e1e7876 switch to new plugin handler 2013-06-04 00:04:16 -07:00
Love Hornquist Astrand
c1423a8eea redo plugin interface 2013-02-10 22:50:49 -08:00
Love Hornquist Astrand
2f5d801156 change client access message 2011-07-24 20:24:35 -07:00
Stefan Metzmacher
296548d34a kdc: pass down the delegated_proxy_principal to the verify_pac() function
This is needed in order to add the S4U_DELEGATION_INFO to the pac.

metze

Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-23 11:48:11 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Andrew Bartlett
f469fc6d49 heimdal Add support for extracting a particular KVNO from the database
This should allow master key rollover.

(but the real reason is to allow multiple krbtgt accounts, as used by
Active Directory to implement RODC support)

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-11-28 09:52:54 -08:00
Love Hornquist Astrand
75c8250abf Tell if we manged to verify the PAC or not 2010-06-11 09:53:47 -07:00
Love Hornquist Astrand
dde9ae659b drop RCSID 2010-03-16 12:50:09 -07:00
Love Hornquist Astrand
600b435d06 Spelling
From Luke Howard
2009-10-19 09:32:15 -07:00
Matthias Dieter Wallnöfer
8457216616 heimdal kerberos - fix memory leak (free the plugin list always - not only in error cases)
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-10-03 11:13:09 -07:00
Love Hörnquist Åstrand
506b98d110 Patch from Andrew bartlett via heimdal-bugs@h5l.org
kdc Allow a password change when the password is expired

    This requires a rework on Heimdal's windc plugin layer, as we want
    full control over what tickets Heimdal will issue.  (In particular, in
    case our requirements become more complex in future).

    The original problem was that Heimdal's check would permit the ticket,
    but Samba would then deny it, not knowing it was for kadmin/changepw

    Andrew Bartlett

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25294 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-03 03:16:46 +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
7fcd266fdd use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:32:32 +00:00
Love Hörnquist Åstrand
8888b88979 kdc: Provide extended error information in AS-REP error replies.
This change utilizes the addition of the e_data parameter to the
   windc_plugin in the heimdal code to pass extended information back
   to the client.  The extended information is provided in an e-data
   block as part of the kerberos error message, and allows the client
   to determine which specific error condition occurred.

From Andrew Kroeger and Andrew Bartlet


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22693 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-19 08:57:49 +00:00
Love Hörnquist Åstrand
628db42656 rename windc_init to krb5_kdc_windc_init
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20559 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-04-24 16:00:07 +00:00
Love Hörnquist Åstrand
a295015e44 Spelling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19799 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 15:25:09 +00:00
Love Hörnquist Åstrand
5a65ccd573 indent.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19798 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 15:24:51 +00:00
Love Hörnquist Åstrand
634d0ca86d pass down server entry to verify_pac function, from Andrew Bartlett <abartlet@samba.org>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19796 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 14:22:04 +00:00
Love Hörnquist Åstrand
f2b0c0407f Add _kdc_windc_client_access.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19674 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-04 11:10:06 +00:00
Love Hörnquist Åstrand
4dd8ec3489 Rename the init function to windc instead of pac.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19627 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-03 15:35:07 +00:00
Love Hörnquist Åstrand
03adfc4ceb Callbacks specific to emulating a Windows Domain Controller.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19626 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-03 15:34:04 +00:00