Fix spurious clock skew caused by gak_fct delay

In get_in_tkt.c, a time offset is computed between the KDC's auth_time
and the current system time after the reply is decrypted.  Time may
have elapsed between these events because of a gak_fct invocation
which blocks on user input.  The resulting spurious time offset can
cause subsequent TGS-REQs to fail and can also cause the end time of
the next AS request to be in the past (issue #889) in cases where the
old ccache is opened to find the default principal.

Use the system time, without offset, for the request time of an AS
request, for more predictable kinit behavior.  Use this request time,
rather than the current time, when computing the clock skew after the
reply is decrypted.

(cherry picked from commit 37b0e55e21926c7875b7176e24e13005920915a6)

ticket: 7528 (new)
version_fixed: 1.10.4
status: resolved
PKINIT (draft9) null ptr deref [CVE-2012-1016]

Don't check for an agility KDF identifier in the non-draft9 reply
structure when we're building a draft9 reply, because it'll be NULL.

The KDC plugin for PKINIT can dereference a null pointer when handling
a draft9 request, leading to a crash of the KDC process.  An attacker
would need to have a valid PKINIT certificate, or an unauthenticated
attacker could execute the attack if anonymous PKINIT is enabled.

CVSSv2 vector: AV:N/AC:M/Au:N/C:N/I:N/A:P/E:P/RL:O/RC:C

[tlyu@mit.edu: reformat comment and edit log message]

(back ported from commit cd5ff932c9d1439c961b0cf9ccff979356686aff)

ticket: 7527 (new)
version_fixed: 1.10.4
status: resolved
Don't return a host referral to the service realm

A host referral to the same realm we just looked up the principal in
is useless at best and confusing to the client at worst.  Don't
respond with one in the KDC.

(back ported from commit ee0d5eac353a13a194759b72cb44203fda1bf0fa)

ticket: 7536 (new)
version_fixed: 1.10.4
status: resolved
Ensure null termination of AFS salts

Use krb5int_copy_data_contents_add0 when copying a pa-pw-salt or
pa-afs3-salt value in pa_salt().  If it's an afs3-salt, we're going to
throw away the length and use strcspn in krb5int_des_string_to_key,
which isn't safe if the value is unterminated.

(cherry picked from commit f566fee75f2455d6e5e7ee4fcdf5a0d327808639)

ticket: 7537 (new)
version_fixed: 1.10.4
status: resolved
Make verify_init_creds work with existing ccache

As the file ccache implementation currently stands, we don't want to
turn off TC_OPENCLOSE on a file cache we're writing to, or it will be
opened read-only and stores to it will fail.  Reported by Russ
Allbery.

(cherry picked from commit 0ae663d35b7dcbf2c469ad0688a67f4d1c0e425e)

ticket: 7538 (new)
version_fixed: 1.10.4
status: resolved
Fail during configure if unable to find ar

Fail during configure time if the configure script can't locate the
"ar" program, instead of producing a delayed failure during build time
by running the "false" command.  Some Solaris releases have ar in
/usr/ccs/bin, which is not in the default path for some users.

(cherry picked from commit 2c990e6418cd7cee7ca178a3175b07ed6a01ffae)

ticket: 7540 (new)
version_fixed: 1.10.4
status: resolved
Suppress maybe-uninitialized warning in x-deltat.y

Recent versions of gcc can generate a maybe-uninitialized warning from
bison output instead of a regular uninitialized warning.  Suppress
both.  Fix from nalin@redhat.com.

(cherry picked from commit d4f98cdd40559620531622c9c6d988f6aa850bd0)

ticket: 7541 (new)
version_fixed: 1.10.4
status: resolved
Avoid side effects in assert expressions

asserts may be compiled out with -DNDEBUG, so it's wrong to use an
assert expression with an important side effect.

(We also have scores of side-effecting asserts in test programs, but
those are less important and can be dealt with separately.)

(cherry picked from commit 221cd4a23691601a14500bc00146c265b50bdc94)

ticket: 7542 (new)
version_fixed: 1.10.4
status: resolved
Suppress some gcc uninitialized variable warnings

gcc 4.6.2 reportedly finds some spurious maybe-uninitialized warnings.
Suppress them.  Patch from Eray Aslan with some adjustment.

(cherry picked from commit cc2f16af06800bf9882c1589d3d6e9b8f19b6d6f)

ticket: 7543 (new)
version_fixed: 1.10.4
status: resolved
Handle PKINIT DH replies with no certs

If a PKINIT Diffie-Hellman reply contains no certificates in the
SignedData object, that may be because the signer certificate was a
trust anchor as transmitted to the KDC.  Heimdal's KDC, for instance,
filters client trust anchors out of the returned set of certificates.
Match against idctx->trustedCAs and idctx->intermediateCAs to handle
this case.  This fix only works with OpenSSL 1.0 or later; when built
against OpenSSL 0.9.x, the client will still require a cert in the
reply.

Code changes suggested by nalin@redhat.com.

(cherry picked from commit db83abc7dcfe369bd4467c78eebb7028ba0c0e0d)

ticket: 7544 (new)
version_fixed: 1.10.4
status: resolved
Fix various integer issues

In kdc_util.c and spnego_mech.c, error returns from ASN.1 length
functions could be ignored because they were assigned to unsigned
values.  In spnego_mech.c, two buffer size checks could be rewritten
to reduce the likelihood of pointer overflow.  In dump.c and
kdc_preauth.c, calloc() could be used to simplify the code and avoid
multiplication overflow.  In pkinit_clnt.c, the wrong value was
checked for a null result from malloc(), and the code could be
simplified.

Reported by Nickolai Zeldovich <nickolai@csail.mit.edu>.

(cherry picked from commit d3c5450ddf0b20855e86dab41735d56c6860156b)

[tlyu@mit.edu: omitted pkinit and kdb5_util fixes because they're not
conservative]

ticket: 7545 (new)
version_fixed: 1.10.4
status: resolved
Make kprop/kpropd work with RC4 session key

In krb5_auth_con_initivector and mk_priv/rd_priv, stop assuming that
the enctype's block size is the size of the cipher state.  Instead,
make and discard a cipher state to get the size.

(cherry picked from commit 8d01455ec9ed88bd3ccae939961a6e123bb3d45f)

ticket: 7575 (new)
version_fixed: 1.10.4
status: resolved
Convert success in krb5_chpw_result_code_string

Result code 0 used to be converted properly by krb5_set_password,
though not krb5_change_password; this changed in 1.10 when
krb5int_setpw_result_code_string was folded into
krb5_chpw_result_code_string.  Restore the old behavior, and make it
apply to krb5_change_password as well, by making
krb5_chpw_result_code_string convert result code 0.

[ghudson@mit.edu: commit message]

(cherry picked from commit 316bf74b4696058e2b60c95c9d0fc90d6c2c2ffe)

ticket: 7576 (new)
version_fixed: 1.10.4
status: resolved
PKINIT null pointer deref [CVE-2013-1415]

Don't dereference a null pointer when cleaning up.

The KDC plugin for PKINIT can dereference a null pointer when a
malformed packet causes processing to terminate early, leading to
a crash of the KDC process.  An attacker would need to have a valid
PKINIT certificate or have observed a successful PKINIT authentication,
or an unauthenticated attacker could execute the attack if anonymous
PKINIT is enabled.

CVSSv2 vector: AV:N/AC:M/Au:N/C:N/I:N/A:C/E:P/RL:O/RC:C

This is a minimal commit for pullup; style fixes in a followup.
[kaduk@mit.edu: reformat and edit commit message]

(cherry picked from commit c773d3c775e9b2d88bcdff5f8a8ba88d7ec4e8ed)

ticket: 7577 (new)
version_fixed: 1.10.4
status: resolved
Check for negative poll timeout in k5_sendto_kdc

(cherry picked from commit 74bee54227deb64a41c2e79f57dd2a2c5ea010a3)

ticket: 7578 (new)
version_fixed: 1.10.4
status: resolved
Fix gss_str_to_oid for OIDs with zero-valued arcs

gss_str_to_oid wasn't outputting any bytes for a zero-valued arc.  It
should output one byte with value 0.

[ghudson@mit.edu: commit message]

(cherry picked from commit 54fa4433df7412267375240aba40959e97ac4fe2)

ticket: 7579 (new)
version_fixed: 1.10.4
status: resolved
Fix no_host_referral concatention in KDC

If no_host_referral is set in both [kdcdefaults] and the realm
subsection, we're supposed to concatenate their values.  But the logic
in handle_referral_params would overwrite the value with the
non-concatenated realm value.  Similar bugs of this nature were fixed
in 639c9d0f5a7c68dc98a2a452abc05ca32443cddf (r22037) but this one was
missed.

(cherry picked from commit 6338d039cbd0b138642e3b123ac58dc802d1d907)

ticket: 7580 (new)
version_fixed: 1.10.4
status: resolved
Fix kdb5_util dump.c uninitialized warnings

Some versions of clang report an uninitialized variable warning (which
we treat as an error) in process_k5beta_record.  Due to the if-ladder
style of the function, uninitialized tmpint values can be copied
around in certain error cases, although the garbage values would be
ultimately ignored.  As a minimal fix, initialize the tmpint
variables.

(cherry picked from commit 1b7f7eef8a95bda0135159b2c06a168b56d9f42b)

ticket: 7581 (new)
version_fixed: 1.10.4
status: resolved
Fix initial call to svcraw_create

gssrpc raw services could not work because svcraw_create did not set
svcraw_private after allocating memory for it.

[ghudson@mit.edu: commit message, patch splitting]

(cherry picked from commit 5e3bf4ac6cb02601c5f10c5b2804fd5028c80119)

ticket: 7582 (new)
subject: Minor pointer management patches
Fix various result checks

Correct three cases where the wrong expression was checked to see if
an allocation function returned null.

[ghudson@mit.edu: commit message, patch splitting]
[tlyu@mit.edu: omit inapplicable lib/kadm/srv/svr_principal.c change]

(back ported from commit a9ee4a040eeacab1d410ff9e4c862484b531c401)

ticket: 7582
version_fixed: 1.10.4
status: resolved