Commit Graph

968 Commits

Author SHA1 Message Date
Jeffrey Altman
28b9283709 kadmin: enable keepalive mode on incoming sockets
Change-Id: I07d0e0c866f1081002b3e20ca9198055f98fe7d1
2020-07-24 01:32:34 -04:00
Nicolas Williams
03a08825d0 kadmin: fix leak 2020-04-24 16:02:35 -05:00
Nicolas Williams
dd762e53d1 kadmin: Improve ext_keytab usage 2019-12-06 18:32:15 -06:00
Nicolas Williams
1ae941af9b roken_detach_prep() should return fd 2019-10-03 13:09:18 -05:00
Nicolas Williams
5859bc3bdf kadmin: add --hdb / -H argument
Makes it possible to

 $ kadmin -l -H /tmp/hdb init FOO.EXAMPLE

rather than being able to only init /var/heimdal/heimdal.
2019-10-03 13:09:18 -05: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
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
Nicolas Williams
c2b106def5 Fix wrong keepold default in kadmin and ktutil 2019-01-09 00:14:11 -06:00
Jeffrey Altman
b025f20eb4 kadmin: kadmind_dispatch incompatible pointer warning
warning: incompatible pointer types passing 'int *' to parameter
  of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]

Change-Id: Id75b1b1c9b46b63ab61134f4f91b7c2909d87077
2019-01-04 01:47:11 -05:00
Jeffrey Altman
750cfc092c fix 00c590e4ff
Change-Id: I73623d71842086374ae58c6e751395fd6925a704
2019-01-04 01:41:23 -05:00
Jeffrey Altman
9119136967 fix memory leaks
Change-Id: I18ad15dc802842324b3712f3f7833953434b1cf1
2019-01-04 01:22:20 -05:00
Jeffrey Altman
00c590e4ff fix null pointer dereference errors
Change-Id: I82a849afe9f432a1084ad2505ce88b1fe4d3d3af
2019-01-04 01:02:59 -05:00
Nicolas Williams
d5536d4dd3 Fix wrong context bugs in kadmin randkey 2019-01-03 22:26:31 -06:00
Jeffrey Altman
e787bd1bc1 kadmin: kadmin_dispatch free krb5_principals at function exit
Change-Id: Ic50a17abf10c7055574de2236cdf1d1469375d8b
2019-01-02 20:19:23 -06:00
Jeffrey Altman
092cd5e838 kadmin: kadmin_dispatch out of memory handling
Coverity determined that a NULL pointer segmentation fault could occur
if krb5_storage_emem() fails.  Use krb5_enomem() to set an error message
on the context and do not perform further krb5_storage operations.

Change-Id: I9587208e46c184bb061443a44581a32dd722de33
2019-01-02 20:19:23 -06:00
Nicolas Williams
ff7a969c32 Begin documenting [password_quality] configuration 2019-01-02 17:29:08 -06:00
Nicolas Williams
d8394c65b7 Add new kadmin/ktutil --keep* and --enctypes opts
- Add --keepold/keepallold/pruneall options to various kadmin/ktutil
   commands.  Default behavior to "prune old keys".

 - When setting keys for a service, we need to specify enctypes for it:

    - Always use kadm5_randkey_principal_3() instead of the older
      kadm5_randkey_principal().

    - Add krb5_string_to_keysalts2(), like MIT's krb5_string_to_keysalts(),
      but with a context, and simpler.

    - Add --enctypes options to various kadmin/ktutil commands.

    - Add [libdefaults] supported_enctypes param with enctype[:salttype]
      list.

    - Add [realms] realm supported_enctypes param with enctype[:salttype]
      list.

      Default to aes128-cts-hmac-sha1-96:normal.
2019-01-02 17:29:08 -06:00
Nicolas Williams
43a911eedc Fix bug in kadmin check warning message 2019-01-02 13:56:04 -05:00
Radoslav Bodo
f3f06fcba9 kadmin selective prune of historic key for principal 2018-12-31 14:17:10 -06:00
Luke Howard
014f16883c libhcrypto: UI_UTIL_FLAG_VERIFY_SILENT 2018-12-30 15:39:49 -06:00
Luke Howard
410d96f480 kadmin: do not assign passwords at realm initialization
Since c6bf100b password quality checks have been moved out of kadmindd and into
libkadm5. This means that all password changes are subject to quality checks,
if enforce_on_admin_set is true (the default). In rare instances it could be
possible for realm initialization to fail because the randomly generated
passwords do not pass the password quality test. Fix this by creating
principals with no password or key, rather than with a random password.

Random *keys* continue to be set immediately after the principal is created,
and before DISALLOW_ALL_TIX is unset, so there should be no functionality or
security implications from this change. It is safe to call a server-side API
such as kadm5_s_create_principal_with_key() as local_flag is asserted to be
true.
2018-12-27 17:11:27 +11:00
Luke Howard
be3836d4ca Revert "kadmin: do not assign passwords at realm initialization"
This reverts commit 83def5bc18. Not passing all
tests, will resubmit as pull request.
2018-12-27 16:42:36 +11:00
Luke Howard
83def5bc18 kadmin: do not assign passwords at realm initialization
Since c6bf100b password quality checks have been moved out of kadmindd and into
libkadm5. This means that all password changes are subject to quality checks,
if enforce_on_admin_set is true (the default). In rare instances it could be
possible for realm initialization to fail because the randomly generated
passwords do not pass the password quality test. Fix this by creating
principals with no password or key, rather than with a random password.

Random *keys* continue to be set immediately after the principal is created,
and before DISALLOW_ALL_TIX is unset, so there should be no functionality or
security implications from this change. It is safe to call a server-side API
such as kadm5_s_create_principal_with_key() as local_flag is asserted to be
true.
2018-12-27 16:27:16 +11:00
Luke Howard
c6bf100b43 kadm5: move password quality checks out of daemons and into libkadm5
Note that this has a slight behavior change to c89d3f3b in order to continue
allow kadmin in local mode to bypass password quality checks. Password quality
checks are always bypassed if the *client* kadmin principal is kadmin/admin,
i.e. that of the kadmin service itself. This is the case when running kadmin in
local mode. As this is the equivalent of a superuser account, one would
anticipate that deployments would use specific administrator instances for
appropriate ACLs for day-to-day administration; operations by these will be
subject to password quality checks if enforce_on_admin_set is TRUE, or if the
user is changing their own password.
2018-12-26 11:04:05 -06:00
Luke Howard
c89d3f3b8c kadmin: allow enforcing password quality on admin password change
This patch adds the "enforce_on_admin_set" configuration knob in the
[password_quality] section. When this is enabled, administrative password
changes via the kadmin or kpasswd protocols will be subject to password quality
checks. (An administrative password change is one where the authenticating
principal is different to the principal whose password is being changed.)

Note that kadmin running in local mode (-l) is unaffected by this patch.
2018-12-26 15:38:48 +11:00
Nicolas Williams
620862049e Use roken_get_*() instead of getpwuuid()
Using non-reentrant getpwuid() (or getpwnam(), or getspnam())  can be
dangerous.  We had a report of a login application / PAM that calls
those, and Heimdal, by calling them too, clobbered the cached struct
passwd used by the login app / PAM.
2018-12-25 22:11:19 -06:00
Luke Howard
def6e4fc79 kadmin: honour pw-expiration-time when adding principal (#360)
Adding a principal with a random key or password did not respect non-default
password expiration times, because the act of setting the key or password would
clobber it with the default. As we update the principal anyway after setting
the keys, use this opportunity to restore the requested password expiration
time. (There are other ways to solve this, but this is the least intrusive.)
2018-12-23 17:34:42 +11:00
CUI Hao (Lab)
0f7fc0fba6 Correct "princial" typos. 2018-10-08 08:46:37 -04:00
Viktor Dukhovni
bac9c1fe94 Use correct ret value in load error messages 2017-12-06 21:18:47 -05:00
Viktor Dukhovni
d2130e3312 Handle long lines in dump files 2017-10-11 17:13:07 -05:00
Roland Hopferwieser
bcfe538228 kadmin/cpw: Add error code on password missmatch 2017-10-10 23:22:59 -04:00
Nicolas Williams
7d5f8bb051 Disable sync during kadmin load 2017-10-10 14:29:09 -05:00
Jeffrey Altman
029d32580a fix calls to memset_s
In random_password() and DES3_string_to_key(), do not call
memset_s() with the sizeof a pointer.

Change-Id: I7dd49b9f717e1cb5c262f2d375d2b85be82cd2db
2017-04-29 13:55:24 -04:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Nicolas Williams
e5126ab924 Fix warnings 2016-11-28 17:34:44 -06:00
Nicolas Williams
f38089257b Misc fixes (coverity) 2016-11-20 17:43:51 -06:00
Jeffrey Altman
bdfc24e9c0 kadmind: kadmin_dispatch leaks memory
Change-Id: I8bc332c4c9b7a8dc1d63494a82ec7af89c0ec7ca
2016-11-19 07:43:39 -05:00
Jeffrey Altman
04f17a5bae kadmin: stash() do not leak 'mkey' if early exit
Change-Id: I4d9f847e833a895933dcd69cc1e7aed80d85aea5
2016-11-19 02:16:19 -05:00
Jeffrey Altman
11d1c81c27 kadmin: add_users leaks 'words'
Change-Id: I2607c8f0d774dd31d3b7f2341a65f4d43867548f
2016-11-19 00:21:42 -05:00
Jeffrey Altman
89d87ab66a kadmin: do_mod_entry copy and paste error
when testing hist_kvno_diff_svc_integer do not use
hist_kvno_diff_clnt_integer.

Change-Id: Ib1d0224cdb1bab95ef0b104026f854cbfd8f736f
2016-11-18 21:18:55 -05:00
Nicolas Williams
7fa85e6d6d Round #3 of scan-build warnings cleanup 2016-11-16 23:27:27 -06:00
Viktor Dukhovni
ffd0dda237 Fix iprop against legacy master with full log
When the master's log has all entries from version 1 to now, and no
uber entry (legacy master), then new slaves will not pull version 1,
because their uber record has version 1.

The fix is to force the uber version to 0 always, and avoid adding a
truncate nop when doing a full prop.  The uber record now records the
database version even in the absence of any other log entries so that
we know what to pull going forward.
2016-06-09 01:03:10 -04:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Nicolas Williams
30299a4ee7 kadmind: don't leak ks_tuple 2016-02-29 19:13:13 -06:00
Nicolas Williams
e193671854 kadmind: fix pw leak from CVE-2016-2400 fix 2016-02-29 19:13:12 -06:00
Nicolas Williams
644b45939e kadmind: fix leak 2016-02-29 19:13:12 -06:00
Nicolas Williams
7442787f03 Fix leak in check_aliases() 2016-02-26 21:29:05 -06:00
Nicolas Williams
8343733562 kadmind: check ACLs for aliases CVE-2016-2400
CVE-2016-2400

kadmind(8) was not checking for 'add' permission to aliases added via
kadm5_modify_principal().  This is a security vulnerability.  The impact
of this vulnerability is mostly minor because most sites that use
kadmind(8) generally grant roughly the same level of permissions to all
administrators.  However, the impact will be higher for sites that grant
modify privileges to large numbers of less-privileged users.

From what we know of existing deployments of Heimdal, it seems very
likely that the impact of this vulnerability will be minor for most
sites.
2016-02-26 01:04:32 -06:00
Nicolas Williams
20df2c8706 Two-phase HDB commit via iprop log, + GC for log
We used to update the iprop log and HDB in different orders depending on
the kadm5 operation, which then led to various race conditions.

The iprop log now functions as a two-phase commit (with roll forward)
log for HDB changes.  The log is auto-truncated, keeping the latest
entries that fit in a configurable maximum number of bytes (defaults to
50MB).  See the log-max-size parameter description in krb5.conf(5).

The iprop log format and the protocol remain backwards-compatible with
earlier versions of Heimdal.  This is NOT a flag-day; there is NO need
to update all the slaves at once with the master, though it is advisable
in general.  Rolling upgrades and downgrades should work.

The sequence of updates is now (with HDB and log open and locked):

a) check that the HDB operation will succeed if attempted,
b) append to iprop log and fsync() it,
c) write to HDB (which should fsync()),
d) mark last log record committed (no fsync in this case).

Every kadm5 write operation recover transactions not yet confirmed as
committed, thus there can be at most one unconfirmed commit on a master
KDC.

Reads via kadm5_get_principal() also attempt to lock the log, and if
successful, recover unconfirmed transactions; readers must have write
access and must win any race to lock the iprop log.

The ipropd-master daemon also attempts to recover unconfirmed
transactions when idle.

The log now starts with a nop record whose payload records the offset of
the logical end of the log: the end of the last confirmed committed
transaction.  This is kown as the "uber record".  Its purpose is
two-fold: act as the confirmation of committed transactions, and provide
an O(1) method of finding the end of the log (i.e., without having to
traverse the entire log front to back).

Two-phase commit makes all kadm5 writes single-operation atomic
transactions (though some kadm5 operations, such as renames of
principals, and changes to principals' aliases, use multiple low-level
HDB write operations, but still all in one transaction).  One can still
hold a lock on the HDB across many operations (e.g., by using the lock
command in a kadmin -l or calling kadm5_lock()) in order to push
multiple transactions in sequence, but this sequence will not be atomic
if the process or host crashes in the middle.

As before, HDB writes which do not go through the kadm5 API are excluded
from all of this, but there should be no such writes.

Lastly, the iprop-log(1) command is enhanced as follows:

 - The dump, last-version, truncate, and replay sub-commands now have an
   option to not lock the log.  This is useful for inspecting a running
   system's log file, especially on slave KDCs.

 - The dump, last-version, truncate, and replay sub-commands now take an
   optional iprop log file positional argument, so that they may be used
   to inspect log files other than the running system's
   configured/default log file.

Extensive code review and some re-writing for clarity by Viktor Dukhovni.
2016-02-26 00:55:33 -06:00