Sam Hartman [Thu, 30 Apr 2009 00:38:48 +0000 (00:38 +0000)]
Do not return PREAUTH_FAILED on unknown preauth
If the KDC receives unknown pre-authentication data then ignore it.
Do not get into a case where PREAUTH_FAILED is returned because of
unknown pre-authentication. The main AS loop will cause
PREAUTH_REQUIRED to be returned if the preauth_required flag is set
and no valid preauth is found.
If DEBUG_ERROR_LOCATIONS is defined, replace uses of
krb5_set_error_message and krb5int_set_error with calls to the new
_fl variants of those functions, and include filename and line number
information in the calls. Requires C99-style variadic macros if
defined.
Fix handling of RET_SEQUENCE flag in mk_priv/mk_ncred
Regularize the handling of KRB5_AUTH_CONTEXT_RET_SEQUENCE in
krb5_mk_safe, krb5_mk_priv, and krb5_mk_ncred, using krb5_mk_safe as
a baseline. RET_SEQUENCE now implies DO_SEQUENCE for all three
functions, the sequence number is always incremented if it is used,
and outdata->seq is always set if RET_SEQUENCE is passed.
Note that in the corresponding rd_ functions, RET_SEQUENCE and
DO_SEQUENCE are independent flags, which is not consistent with the
above. This compromise is intended to preserve compatibility with
any working code which might exist using the RET_SEQUENCE flag.
Fix a few memory leaks in krb5_mk_ncred. Also tighten up the error
handling of the sequence number, only decreasing it if it was
increased. The handling of DO_SEQUENCE and RET_SEQUENCE may still be
flawed in some cases.
Move KRB5_KDB_OK_AS_DELEGATE from kdb_ext.h to kdb.h. Add kadmin
support for the flag. In the KDC, remove the restriction on returning
the flag on cross-realm TGTs since there is now a defined meaning for
that (it allows ok-as-delegate to be honored on the foreign realm's
service tickets).
Ken Raeburn [Sat, 25 Apr 2009 09:36:11 +0000 (09:36 +0000)]
make installed headers C++-safe
Now that we're installing the kadm5 headers, they should be C++-safe
like the others. Wrap the content in 'extern "C"' if compiling as
C++. New test program to verify.
In krb5_ktfileint_find_slot, don't continue the loop when we find a
final zero-length buffer. This is a minimal fix intended to be pulled
up to the 1.7 branch; a code cleanup commit will follow.
ticket: 6475
status: open
tags: pullup
target_version: 1.7
In krb5_principal_compare_flags, improve clarity slightly by using a
boolean temporary instead of an ordering temporary in the loop over
the elements, since we only care about the boolean result.
In krb5_rcache_externalize, remove a pointless null check of a pointer
we just dereferenced.
Rewrite krb5_rcache_internalize to use the recommended cleanup flow
control, closing a memory leak in the process.
In the cross-realm setup example in the admin documentation, use
"addprinc" instead of "add_princ" since the latter is not a recognized
alias for add_principal.
Change the signature of _make_etype_info_entry to take the canonical
client principal instead of the request structure. Also fixes the salt
we compute for SALTTYPE_NOREALM keys.
Sending an explicit salt for SALTTYPE_NORMAL keys is believed to be
necessary for some preauth scenarios involving aliases.
Will Fiveash [Mon, 13 Apr 2009 22:15:05 +0000 (22:15 +0000)]
Update kdb5_util man page with missing purge_mkeys command
While previously updating the kdb5_util command man page to include
documentation on new subcommands added as a result of the Master Key
Migration project I missed the purge_mkeys command. I've added that
with this commit.
Very little is likely to go wrong inside krb5_mkt_resolve (it just
allocates memory and plays with mutexes), but if anything did, the
handling was almost always wrong. Reorganize the function to handle
errors properly, using a helper create_list_node function to simplify
the task.
In krb5_get_in_tkt, r7002 introduced an unused local variable
"padata". It was accidentally used in r18641 instead of
preauth_to_use when sorting the received padata sequence, causing the
sort to be a no-op. Sort the correct sequence and eliminate the
unused local variable.
doc/definitions.texinfo had, predictably, fallen out of date with
respect to the code. Update a few of the out of date comments and
defaults, particularly the default enctype lists.
mk_safe and mk_priv require the local address to be set in the auth
context; rd_safe and rd_priv require the remote address to be set.
Create error codes for both kinds of missing addresses and stop trying
futilely to handle the cases where they are not set.
When getting initial credentials with a password, try the master if
preauth fails on a slave, since preauth can fail due to an out-of-date
key. This removes a snippet added in r14939 which was considering
only hardware preauth.
Subject k5_utf8s_to_ucs2s could deref NULL pointer..
Based on usage of this static function, this will never happen as
results are always malloced (and checked) by caller. However, the
function is already coded to handle the first argument being null - so
be consistent throughout.
asn1buf_imbed() can perform pointer arithmetic that causes the "bound"
pointer of the subbuffer to be less than the "next" pointer. This can
lead to malloc() failure or crash.
In asn1buf_imbed(), check the length before doing arithmetic to set
subbuf->bound. In asn1buf_remove_octetstring() and
asn1buf_remove_charstring(), check for invalid buffer pointers before
executing an unsigned length check against a (casted to size_t)
negative number.
Tom Yu [Tue, 7 Apr 2009 21:22:17 +0000 (21:22 +0000)]
CVE-2009-0844 SPNEGO can read beyond buffer end
SPNEGO can read beyond the end of a buffer if the claimed DER length
exceeds the number of bytes in the input buffer. This can lead to
crash or information disclosure.
Thanks to Apple for reporting this vulnerability and providing
patches.
Adjust the logic in rule_an_to_ln to avoid a "can't happen" case of
strchr returning null when searching for a character we know is there.
Also properly return ENOMEM if we fail to allocate selstring.
Sam Hartman [Fri, 3 Apr 2009 05:36:25 +0000 (05:36 +0000)]
Handle authdata encrypted in subkey
RFC 4120 requires that if a subkey is present in the TGS request that
authorization data be encrypted in the subkey. Our KDC did not handle
this correctly.
Sam Hartman [Fri, 3 Apr 2009 03:33:01 +0000 (03:33 +0000)]
Unfortunately, pre-1.7 krshd fails to support keyed checksums because
it uses the wrong API and wrong key usage. So, if the auth_context
has an explicit checksum type set, then respect that. kcmd sets such
a checksum type. Also, because other applications may have the same
problem, allow the config file variable if set to override the default
checksum.
* kcmd.c: Force use of rsa_md5
* init_ctx.c: do not default to md5
* mk_req_ext.c: allow auth_context to override
Sam Hartman [Wed, 1 Apr 2009 18:25:02 +0000 (18:25 +0000)]
Use the preferred checksum for non-DES keys in the kdc_req path and
all the time in the ap_req checksum path. This breaks code to support
DCE versions prior to 1.1 but uses the correct checksum for protocol
compatibility.
Greg Hudson [Tue, 24 Mar 2009 17:24:31 +0000 (17:24 +0000)]
Revert r21880 which included k5-int.h in several pkinit source files.
Instead, move the pkinit-specific KRB5_CONF macros to pkinit.h, and
add duplicate definitions of the non-pkinit-specific macros used by
the pkinit code.
Greg Hudson [Fri, 20 Mar 2009 18:09:19 +0000 (18:09 +0000)]
Install kadmin and kdb headers
Add disclaimers to the kadmin and kdb headers about the weaker
stability commitments we make for their APIs, and install them for the
benefit of users who can tolerate such instability. (The kadmin
interface is the real goal here, but the kadmin header includes kdb.h
so we need to install both.)
Sam Hartman [Mon, 16 Mar 2009 16:50:23 +0000 (16:50 +0000)]
Implement test cases for CF2
Implement a simple program to call KRB-FX-CF2 and print the resulting
keys. Add to regression tests. Also, use the PRF testing application
to confirm that CF2 generates consistent keys if called by hand.
Sam Hartman [Mon, 16 Mar 2009 16:50:09 +0000 (16:50 +0000)]
Implement KRB-FX_CF2
Draft-ietf-krb-wg-preauth-framework defines a function KRB-FX-CF2 that
combines two keys of arbitrary enctype. Implement this function as an
exported API.
Greg Hudson [Sun, 15 Mar 2009 04:21:12 +0000 (04:21 +0000)]
Add LDAP back end support for canonical name attribute
Add a krbCanonicalName attribute to the schema. When looking up a
principal, if the canonical name is set and does not match the
requested name, then return the entry only if canonicalization was
requested, and use the entry's canonical name.
Greg Hudson [Sun, 15 Mar 2009 04:15:16 +0000 (04:15 +0000)]
Document alias support in LDAP back end
Add a few paragraphs to the LDAP instructions on creating aliases
through direct manipulation of the LDAP data, and briefly explain when
aliases will be used.
Greg Hudson [Sat, 14 Mar 2009 05:46:18 +0000 (05:46 +0000)]
Improve LDAP admin documentation
Use dc=example,dc=com as the example base DN instead of more archaic
forms. Provide a little more cross-referencing of concepts and
mechanisms. Add additional steps in the OpenLDAP setup instructions
for choosing DNs for the Kerberos container, KDC service, and kadmin
service. Explain a little bit about what the Kerberos container and
realm container are. Be clearer that using separate subtrees from the
realm container for principals is an option, not a necessity, and
don't use the base DN as an example of a separate subtree (it's
confusing).
Tom Yu [Fri, 13 Mar 2009 21:16:14 +0000 (21:16 +0000)]
CVE-2009-0845 SPNEGO can dereference a null pointer
acc_ctx_new() can return an error condition without establishing a
SPNEGO context structure. This can cause a null pointer dereference
in cleanup code in spnego_gss_accept_sec_context().
Greg Hudson [Fri, 13 Mar 2009 03:10:12 +0000 (03:10 +0000)]
Use correct salt for canonicalized principals
In cases where the salt is derived from the client principal, use the
canonicalized principal received from the KDC to determine the salt.
Further changes are probably required for some preauth cases.
Ken Raeburn [Thu, 12 Mar 2009 22:06:35 +0000 (22:06 +0000)]
Better fix: Delay setting 'outbuf' until after the header buffer might
have been allocated locally, and set it in both code paths instead of
just the confidentiality-requested code path.
Greg Hudson [Wed, 11 Mar 2009 22:14:24 +0000 (22:14 +0000)]
Report verbose error messages from KDC
We were losing verbose error messages when logging from the KDC because
the context passed to krb5_klog_init did not match the realm-specific
context used for most library function calls. Introduce a wrapper
function kdc_err which copies the error state from the call context
to the log context. The wrapper function also knows the program name,
which removes the need to pass argv[0] around everywhere or make up
program names.
Greg Hudson [Wed, 11 Mar 2009 22:11:06 +0000 (22:11 +0000)]
Make a working krb5_copy_error_message
The krb5_copy_error_state macro wasn't used, didn't work, and didn't
need to be a macro. Replace it with an exported API function named
krb5_copy_error_message.
Greg Hudson [Tue, 10 Mar 2009 01:28:12 +0000 (01:28 +0000)]
Rename kdb_setup_lib_handle to krb5_db_setup_lib_handle and export it.
Make kdb5_ldap_util work again by calling this function to set up
dal_handle instead of using one with an uninitialized lib_handle.
It is likely that kdb5_ldap_util will only function given a krb5.conf
which specifies a realm with an LDAP database module as the default
realm. Not sure if that was the case before.
Sam Hartman [Fri, 6 Mar 2009 17:26:29 +0000 (17:26 +0000)]
send_as_req re-encodes the request
krb5_get_init_creds calls encode_krb5_as_req to produce an encoding
for the preauth plugins, then passes the unencoded request structure
into the static function send_as_req. That function re-encodes the
request. This is an unnecessary call to the encoder. In addition,
for the FAST project, it is desirable to encapsulate the unencoded
outer request so that krb5_get_init_creds does not need it.
* send_as_req is modified to take an encoded request and realm
* Remove unused logic to fill in request nonce from send_as_req
Sam Hartman [Thu, 26 Feb 2009 20:07:05 +0000 (20:07 +0000)]
Include authenticator and ticket authdata in gss-api
Currently, the GSS-API routines for handling authdata only extract the
authorization data from the ticket, not that from the authenticator.
This is incorrect. Introduce a new function krb5_merge_authadata to
merge two authdata arrays into a newly allocated result array. Use
this function in accept_sec_context.c to include both sets of
authdata.