Commit Graph

97 Commits

Author SHA1 Message Date
Nicolas Williams
6b45c3512e kadmin: LIST interrupt message needs no reply
The online LIST interrupt message is a NOP, but it's expected to not
have a reply (the server doesn't send one if it receives it before the
LIST finishes).

However, if the interrupt message arrives after the LIST finished, then
it does get a reply, and this causes the client to get out of step with
the server.

Fixes include:

1) flavor the interrupt NOP to make sure it never gets a reply,
2) introduce a new kadm_list_interrtupt message that is like a NOP that
   produces no reply
3) always consume -after the LIST ends- a reply to any list interrupt
   NOP on the client side.

This implements (1).
2022-03-22 17:07:34 -05:00
Nicolas Williams
b92a02edda kadmind: Online LIST using kadm5_iter_principals()
Implement a variation on the op for listing principals where if the
client indicates support for the new variation then we stream the list
instead of collecting it into one reply.  This is the server-side
version of the associated, preceding commit:

    kadm5: Add online kadm5_iter_principals()
2022-03-20 18:30:21 -05:00
Nicolas Williams
14ce7bbaca kadmind: Send error code back... on error!
Seeing "End of file" errors from kadm5 client calls which were the
result of not sending back errors in many error paths in
kadmin/server.c:kadmind_dispatch().
2022-03-20 18:23:17 -05:00
Nicolas Williams
7556a114e1 kadmind: Fix typos leading to reply failures 2022-03-20 18:20:53 -05:00
Jeffrey Altman
02bd267fbd kadmin: kadmind_dispatch fix broken commit
124b8d0f78 ("kadmin: kadmind_dispatch
do not write NULL 'rsp' to 'out'") was committed with an
unintentional source code removal.

Change-Id: I3de21e3624d713a9b5a1e89d147a5db5f1f55ab1
2022-01-21 09:24:34 -05:00
Jeffrey Altman
124b8d0f78 kadmin: kadmind_dispatch do not write NULL 'rsp' to 'out'
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

      krb5_storage_to_data(rsp, out);

This change was unsafe because krb5_unparse_name_fixed() failure
would skip the allocation of the 'rsp' and 'sp' krb5_storage
objects.

This change allocates the krb5_storage objects prior to performing
any work.  If either of them fail, kadmin_dispatch() immediately
returns ENOMEM.

Change-Id: I14fd96afe029a4e74bb769605286ca0e17d25043
2022-01-21 09:16:35 -05:00
Jeffrey Altman
251cbf05c2 Revert "kadmin: kadmind_dispatch do not write to 'out' on error"
This reverts commit fb52fd1c53.

The change caused tests/kdc/check-kadmin to fail.
2022-01-21 09:04:31 -05:00
Jeffrey Altman
fb52fd1c53 kadmin: kadmind_dispatch do not write to 'out' on error
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

  krb5_storage_to_data(rsp, out);

Previously kadmin_dispatch() only wrote to 'out' on success.
Doing so is important because 'rsp' might be NULL on error.

Change-Id: I2688a5c47db0f94d955971e785037c578d3f3fa4
2022-01-21 00:25:15 -05:00
Jeffrey Altman
4ffd190b08 kadmin: kadmind_dispatch fix handling of HEIM_ERR_EOF error
1b213c1082 ("kadmind: Add missing
error checks") altered the scope of the

   if (ret == HEIM_ERR_EOF)
      ret = 0;

treatment of HEIM_ERR_EOF as a success code.  Prior to that
commit HEIM_ERR_EOF meant success only when reading the 'keepold'
value.  It indicated a premature failure if returned when reading
'princ' or 'n_key_data'.

This change corrects the scope of HEIM_ERR_EOF indicating success.

Change-Id: If5463b47dc3eabee6fa2f8e717147f02adc1586c
2022-01-20 23:43:06 -05:00
Nicolas Williams
1b213c1082 kadmind: Add missing error checks 2022-01-19 16:33:37 -06:00
Jeffrey Altman
63f9fc172c kadmin: kadmind_dispatch free 'ks_tuple' before overwriting
Change-Id: I8719c610a34ca128cc8a0b3d7f94dafc26b21e01
2022-01-17 00:16:27 -05:00
Nicolas Williams
b7bf5ca6e8 kadmin: Fix warnings 2022-01-14 14:59:02 -06:00
Nicolas Williams
ea83f068e9 kadm5/kadmin: Add read-only mode
Now we can have read-only kadmind instances.
2020-09-08 00:25:40 -05:00
Nicolas Williams
03a08825d0 kadmin: fix leak 2020-04-24 16:02:35 -05: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
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
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
Radoslav Bodo
f3f06fcba9 kadmin selective prune of historic key for principal 2018-12-31 14:17:10 -06: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
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
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
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
Jeffrey Altman
34bf7ae162 kadmind: don't send bogus keys to ext_keytab et al
The Heimdal kadmind sends bogus keys when the client has 'get'
but not 'get-keys' permission.  For some kadmin commands this is
dangerous.  For example, ext_keytab could happily write bogus
keys to a keytab when real keys are expected, causing eventual
breakage.  Sending bogus keys is important for the kadmin get
command: so it can list the keysets that a principal has.

This patch implements a heuristic detection of kadmin get vs.
ext_keytab, add_enctype, del_enctype, and check commands.  If the
client principal lacks 'get-keys' permission, then the server
will fail requests that appear to be from those kadmin commands,
but will continue to serve bogus keys to kadmin get commands.

Thanks to Nico Williams for the idea behind this implementation.
2015-03-16 11:03:58 -05:00
Jeffrey Altman
6043cc8c88 kadmind: check for KADM5_PRIV_GET when op GET
When performing a permission check for a GET operation the
KADM5_PRIV_GET_KEYS privilege should not be assumed to be a pure
superset of KADM5_PRIV_GET.  If the "get" permission is denied the
user cannot get an entry with or without key data.
2015-03-16 10:47:16 -05:00
Love Hörnquist Åstrand
63672067ea add nob for [kadmin]allow_self_change_password 2011-07-30 12:34:40 -07:00
Nicolas Williams
11c54cd6c8 Protect against negative n_ks_tuple values and against randkey returning negative n_keys 2011-07-24 11:08:58 -05:00
Nicolas Williams
0d90e0c4d0 Complete --keepold support and fix crasher in kadmin cpw -r --keepold. 2011-07-22 16:07:06 -05:00
Nicolas Williams
2510d2d8fc Oops, reverse sense of get-keys check... 2011-07-22 16:07:06 -05:00
Nicolas Williams
f15745c60c Forgot to save edits to kadmin/server.c to use the new get-keys authorization. 2011-07-22 16:07:06 -05:00
Nicolas Williams
e8e314bbb1 Beginning of another new kadm5 function. Need to switch branches for a bit. 2011-07-22 16:04:52 -05:00
Nicolas Williams
6e04b05e9d Initial support for kadm5_randkey_principal_3(), needed by krb5_admin.
NOT TESTED YET.
2011-07-22 16:04:52 -05:00
Love Hörnquist Åstrand
277bec06e7 simplify error printing, context contains error 2011-06-14 07:11:43 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
433b1d5073 drop RCSID 2010-03-16 12:52:58 -07:00
Love Hornquist Astrand
be73fa4687 use krb5_socket_t 2009-12-23 14:12:38 +01:00
Asanka Herath
a1942c1bad Use SOCKET data type instead of ints for sockets in kadmin
Also use the new mini_inetd() API
2009-11-24 10:17:51 -08:00
Love Hornquist Astrand
57faf165a0 [HEIMDAL-646] malloc(0) checks for AIX 2009-10-11 18:03:22 -07:00
Love Hornquist Astrand
8490e8fd34 make compile 2009-07-30 13:04:30 +02:00
Love Hornquist Astrand
3af78ea3fb out of memory [CID-63] 2009-07-30 12:53:50 +02:00
Love Hornquist Astrand
330fd7645d Always ask for principal (KADM5_PRINCIPAL)
The protocol for "get principal" does not support not sending
principal, so when the caller doesn't add KADM5_PRINCIPAL to the mask,
lets add it for them.

Reported by Henry.B.Hotz@jpl.nasa.gov in [HEIMDAL-588]
2009-07-19 21:01:20 -07:00
Love Hörnquist Åstrand
e147d3fba4 use kadm5_s_init_with_password_ctx
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24548 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-30 16:48:46 +00:00
Love Hörnquist Åstrand
8d16bb0b68 add support for add,get,delete,chrand for the MIT kadmin protocol
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24240 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-11 21:42:02 +00:00