Commit Graph

29060 Commits

Author SHA1 Message Date
Nicolas Williams
c9b5a4df90 Use roken_get_loginname() when we want getlogin_r() 2019-09-25 23:09:20 -05:00
Nicolas Williams
d02277b45f List token expansions in krb5.conf.5 2019-09-25 23:09:20 -05:00
Nicolas Williams
0fdda02b61 Add loginname, ruid, and LOCALSTATEDIR expansions
%{loginname} is for getlogin_r().

Now %{username} uses only the $USER and $LOGNAME environment variables
(if the caller is not set-uid), or if absent or the caller is set-uid,
then getpwuid_r().

The intent is to allow kadmin(1) to use the loginname instead of the
username for the construction of the kadmin client principal name.  This
is helpful when the user runs kadmin as root via sudo and/or su.
2019-09-25 23:09:20 -05:00
Nicolas Williams
141289f14b roken: add roken_get_loginname() 2019-09-25 23:09:20 -05: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
Roland C. Dowdeswell
d6337ebdce Export krb5_crypto_prfplus() from libkrb5 2019-09-18 21:20:47 +01:00
Viktor Dukhovni
20557e2255 Don't send diffs to slaves with not yet know version 2019-09-16 17:28:49 -05:00
Viktor Dukhovni
7680c92047 Don't stutter in send_diffs
When the master sees a burst of updates (perhaps sustained), the
slaves "I_HAVE" messages can fall behind the version we've already
sent, and the unpatched code would retransmit already sent diffs!

This can result in substantial amplification (in a local test, 3000
ops turned into 427,000 ops).  Though the number of *messages* sent
was actually somewhat smaller, the ever growing message size
ultimately leads to failure.
2019-09-14 23:40:46 -05:00
Nicolas Williams
2709f28a1b Make gss_store_cred*() work
krb5_cc_cache_match() searches all ccache collections for a ccache that
has credentials for a given principal name.  This includes MEMORY
ccaches, which means it can find the same ccache as is referenced by a
GSS cred handle given to gss_store_cred(), which means that
gss_store_cred() can fail.

For now we work around this by including a private variant of
krb5_cc_cache_match() that only searches the default ccache, not all
collections.  Eventually we should ensure that krb5_cc_default() also
searches all collection-type (other than MEMORY) ccaches for a default
credential, then we can go back to using krb5_cc_cache_match() (though
we'll need to make sure that MEMORY is searched last or not at all).
2019-09-05 09:52:49 -05: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
f40d393c83 tests/kdc/check-authz still fails
I couldn't figure out why this fails in Travis, so I'm nuking it.
2019-07-09 15:47:12 -05:00
Nicolas Williams
4edcbd6597 Fix Travis after_failure 2019-07-09 15:47:12 -05:00
Nicolas Williams
9c51900238 Declare kdc log functions to be printf-like
And add a kdc_vlog() function.
2019-07-09 13:17:06 -05:00
Nicolas Williams
7fc90ce1c8 Remove references to Kerberos v4 from kdc/kdc.8 2019-07-09 12:38:08 -05:00
Nicolas Williams
32bc4083c4 libhx509: export some missing symbols 2019-07-09 12:34:26 -05:00
Nicolas Williams
dd226b6f9a Token "username" should be multi-platform 2019-07-09 12:34:26 -05:00
Nicolas Williams
8bc5d5af10 hcrypto: fix off-by-one set-bit counting 2019-07-09 12:34:26 -05:00
Nicolas Williams
51aed5d820 krb5_data_copy() should use memcpy() 2019-07-09 12:34:26 -05:00
Nicolas Williams
889617883d Make note in test_cc of how to keyctl new_session 2019-07-09 12:34:26 -05:00
Nicolas Williams
1af64c5de5 Do not use real $HOME in tests/kdc/check-authz
This test would fail if ~/.k5login has incorrect permissions.

Now we set $HOME to $objdir and use a canned .k5login.
2019-07-09 12:27:16 -05:00
Roland C. Dowdeswell
f2bd714e69 Fix build for out-of-source objdir 2019-06-21 11:32:03 -04:00
Roland C. Dowdeswell
9aa573c9ce kdc: no error if req is fwdable on non-fwdable princ
Instead of returning an error if the client asks for
a forwardable ticket where it isn't allowed, we simply
return one that isn't forwardable.
2019-06-21 10:11:58 -04:00
Roland C. Dowdeswell
fcd57af8e1 Implement KRB5_TRACE using existing logging framework 2019-06-16 21:23:51 -04:00
Jeffrey Altman
15ae5f06a9 Update SECURITY.md
This is a new PGP key for heimdal-security@heimdal.team
2019-06-09 13:43:47 -04:00
Jeffrey Altman
4a4971a496 Create SECURITY.md 2019-06-09 13:43:47 -04:00
Jeffrey Altman
7d8a72dbe6 .gitignore
RimStar state file (rs_state.ini)

Change-Id: I110de7d64e23d644d70f8b37f4f5d7c2e3d087a4
2019-06-07 22:12:54 -04:00
Jeffrey Altman
4519757881 .gitignore
ignore Visual Studio Code directory (.vscode)

Change-Id: I4760ef5382cec6ef1c1c178fe477967132d73aed
2019-06-07 22:10:34 -04:00
Jeffrey Altman
4921975b62 Create GitHub issue templates 2019-06-07 22:08:39 -04:00
Jeffrey Altman
63b3f4cb37 Create CODE_OF_CONDUCT.md 2019-06-07 22:03:05 -04:00
Jeffrey Altman
4331f4c7d4 kdc: history of request_anonymous vs cname-in-addl-tkt confusion
Drafts 0 through 10 of the Kerberos anonymity internet draft,
https://tools.ietf.org/html/draft-ietf-krb-wg-anon, specified the
TicketFlags.anonymous flag as bit 14 and the KDCOptions.anonymous
flag as bit 14.  These were changed to bit 16 by MIT after it was
discovered that Microsoft used KDCOptions bit 14 for S4U2Proxy
cname-in-addl-tkt.

(Feb 2007) Heimdal added constrained delegation support prior to
1.0 but named the KDCOptions flag constrained_delegation instead of
cname-in-addl-tkt as per MS-SFU.  It also assigned bit 16 instead
of bit 14.  Perhaps this was done in the hope that the conflict
with Microsoft would be resolved in favor of the IETF internet
draft instead of the proprietary protocol extension.

adf9121822 ("Add PA-ClientCanonicalized
and friends.") introduced the KDCOptions.constrained_delegation flag
as bit 16.

(June 2007) In order to make Heimdal's constrained delegation work
with Microsoft's implementation Heimdal began to set both KDCOptions
bits 14 and 16 when requesting constrained delegation.

d5bb7a7c56 ("(krb5_get_creds): if
KRB5_GC_CONSTRAINED_DELEGATION is set, set both") set both the
anonymous and constrained_delegation TicketFlags when issuing a
S4U2Proxy request.

(June 2010) MIT reassigned the KDCOption.anonymous and
TicketFlags.anonymous flags to bit 16.  draft-ietf-krb-anon-11
was published with this change.

(July 2014) After the release of Heimdal 1.5.0 and prior to 1.5.1
it was noticed that Heimdal's anonymous TGT support did not
interoperate with MIT.

86554f5a7f ("Use correct value for
anonymous flags") swapped the bit assignments for request_anonymous
and constrained_delegation but failed to remove the setting of
KDCOptions bit 16 ("anonymous") when requesting constrained
delegation.

(May 2019) Prior to the 7.6 release many corrections to Heimdal's
anonymity support were introduced to bring it into compliance
with RFC8062.  This included support for requesting anonymous
tickets via the TGS service.  Because not all KDC can satisfy
anonymous requests the client must verify if the response was
anonymized.  This check wasn't added until after 7.6 was
released.

014e318d6b ("krb5: check KDC
supports anonymous if requested").

The combination of setting KDCOption.anonymous when requesting
constrained delegation and the anonymized ticket validation
broke S4U2Proxy requests to Windows KDCs.  Windows KDCs ignore
the KDCOption.anonymous flag when processing a TGS request
with KDCOption.cname-in-addl-tkt set.

ea7615ade3 ("Do not set
anonymous flag in S4U2Proxy request") removed the behavior
of setting the KDCOption.anonymous flag that should have
been removed in July 2014.

(June 2019) The Heimdal KDC includes fallback logic to handle
Heimdal clients from 1.0 to 1.5.0, inclusive, that set the
KDCOptions.anonymous flag as bit 14.  Prior to the 7.7 release
this logic only handled AS request but failed to handle the
constrained delegation request case where both bits 14 and 16
were set in the TGS request.

cdd0b70d37 ("kdc: don't misidentify
constrained delegation requests as anonymous") added the TGS
request validation to distinguish anonymous requests from
constrained delegation requests.

This change documents the history in the commit message and
updates some in-tree comments.

Change-Id: I625cd012e2e6c263c71948c6021cc2fad4d2e53a
2019-06-04 09:35:17 +10:00
Luke Howard
cdd0b70d37 kdc: don't misidentify constrained delegation requests as anonymous
Earlier (pre-7.6) Heimdal clients would send both the request-anonymous and
cname-in-addl-tkt flags for constrained delegation requests. A true anonymous
TGS request will only have the former flag set. Do not treat TGS requests with
both flags set as anonymous requests.
2019-06-03 14:36:36 +10:00
Luke Howard
27c6cf7a9f kdc: refactor anonymous checks in KDC
_kdc_is_anon_request() is only used by the AS, so make it static.

Centralize anonymous poilcy checks shared between AS and TGS into a shared
function, _kdc_check_anon_policy().

When issuing an anonymous ticket, set the ticket flag early and test that
rather than re-testing the request.
2019-06-03 12:33:28 +10:00
Luke Howard
7381a280c8 kdc: check for cname-in-addl-tkt flag in constrained delegation
Before accepting an additional ticket for use with constrained delegation,
verify the cname-in-addl-tkt flag was set. If not, ignore the request.
2019-06-03 11:55:54 +10:00
Luke Howard
cf940e15f4 krb5: rename constrained-delegatiom to cname-in-addl-tkt
For consistency with [MS-SFU] rename the constrained-delegation KDC option to
cname-in-addl-tkt (client name in additional ticket).
2019-06-02 14:44:11 +10:00
Isaac Boukris
ea7615ade3 Do not set anonymous flag in S4U2Proxy request
It is not specified in MS-SFU, Apple dropped it as well and
it now breaks master branch.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2019-06-01 11:14:27 -04:00
Quanah Gibson-Mount
290d7e75f2 Fixes #536 - Note that this can cause unexpected behavior with certain
backends

When running with verify-password-quality and a back-end that stores
history (such as heimdal-history) this command can cause an update to
the database meaning the password can no longer be used with this
principal in the future
2019-05-30 20:11:58 -04:00
Quanah Gibson-Mount
9de4da0dcc Fixes #532 - Note that all does not include get-keys
Update the kadmind(8) man page to note that the "all" option for ACLs
does not include the "get-keys" option.
2019-05-30 20:11:03 -04:00
Quanah Gibson-Mount
68f74fbaf1 Fixes #550 - Note that encrypt is the default option
There are two options to hprop.  It's important to note that the default
behavior is to transmit the database with encrypted keys.
2019-05-30 20:10:25 -04:00
Quanah Gibson-Mount
4371af9e75 Fixes issue#535 - verify-password-quality
At one point in time, the configuration option was named
"password-quality" but this was later changed to
"verify-password-quality".  Update the kadmin(1) man page to reflect
this change.
2019-05-30 20:09:53 -04:00
Jeffrey Altman
dc46b1f82d solaris: Define _STDC_C11_BCI for memset_s prototype
On Solaris, the memset_s() prototype is only visible if _STDC_C11_BCI
is defined.

93518bfab4 ("use memset_s")
introduced warnings on Solaris

  warning: implicit declaration of function ‘memset_s’;
  did you mean ‘memset’? [-Wimplicit-function-declaration]

Change-Id: Ia02db5e96021a26fb30aa1a593ef6a2b3e3a5b5f
2019-05-23 19:04:42 -04:00
Rod Widdowson
e143639400 Windows: Windows CRT doesn't support %k as format for strftime
The fix involves:
  - Removing HAVE_STRFTIME from config.h.w32
  - Adding strftime.c to the makefile
  - Defining timezone and tzname to their windows equivalent
    for the compile of this module
2019-05-22 09:47:59 -04:00
Luke Howard
eacfcd5ce1 kuser: use anon_pkinit_realm instead of anon-pkinit-realm
MIT prefers underscores in ccache configuration file keys, so in the interest
of future interoperability use anon_pkinit_realm instead of anon-pkinit-realm
when storing the anonymous PKINIT TGS realm.
2019-05-22 14:42:55 +10:00
Luke Howard
3138c1836c kuser: plug leak in kinit anonymous PKINIT renew
Do not leak the result of krb5_cc_get_config() when determining anonymous
PKINIT start realm.
2019-05-22 14:04:22 +10:00
Jeffrey Altman
b276d139ef lib/krb5: add plugin headers to Makefiles
Change-Id: I6701035da2e7ff3f83feee6cbb4921e5bd5dfd75
2019-05-21 22:20:14 -04:00
Jeffrey Altman
434b34d71c lib/krb5: prevent build failures of krb5_plugin_common on Windows
The Microsoft compiler cannot handle multiple const modifiers
for the same type.    It is also unhappy with the output pointer
parameter being declared const.

This change introduces new typedefs and cast of the dlsym() return
type to prevent warnings.

Change-Id: Ia92645efab8d2ec6745339a6f47c690782ae730a
2019-05-21 22:20:14 -04:00
Jeffrey Altman
ac6fa4cadc lib/krb5: prepare to make common plugins public
Rename common_plugin_ftable to krb5_plugin_common_ftable.

Create lib/krb5/common_plugin.h to include the structure and typedef.

The common_plugin.h header is now included by ccache_plugin.h
along with a prototype for the required ccache_ops_plugin_load()
function.

Change-Id: I2b27d6d0f5cf0544482c3f01784fef945e12e8d8
2019-05-21 22:20:14 -04:00
Jeffrey Altman
df78c88cc0 lib/krb5: common_plugin_ftable_desc funcs KRB5_LIB_CALL
As with the krb5plugin_an2ln_ftable_desc, krb5plugin_db_ftable_desc,
and krb5plugin_kuserok_ftable_desc the function pointers in
common_plugin_ftable_desc must be annotated with KRB5_LIB_CALL.

Change-Id: Ia7ea78743ee9eb8c7f6b648063852ca91a360d2c
2019-05-21 22:20:14 -04:00
Jeffrey Altman
32fe791c2e lib/krb5: common plugin only fallback if load_fn() fails
Only fallback to loading the plugin function table directly if
if the initialization function is not exported.  Failing a
consistency check should not permit falling back to a potentially
incompatible function table.

Change-Id: Ic753ed9a090aef6073853f7309f0f8f0f29d0aa9
2019-05-21 22:20:14 -04:00
Jeffrey Altman
cc2070dbc8 lib/krb5: fix krb5_get_instance_func_t prototype
KRB5_LIB_CALL not KRB5_CALLCONV

Change-Id: I31b8750d63849c2f5cce49642a63fd66e7fa1a32
2019-05-21 22:20:14 -04:00
Jeffrey Altman
22cf04fdaf lib/krb5: krb5.h missing KRB5_LIB_CALL definition
KRB5_LIB_CALL must be defined for out of tree users.

Change-Id: I10a02fdca3ed64093fabd8d391761448b9c480a5
2019-05-21 22:20:14 -04:00