]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
9 years agoFix leak in gss_acquire_cred_with_password
Greg Hudson [Fri, 19 Jun 2015 21:16:52 +0000 (17:16 -0400)] 
Fix leak in gss_acquire_cred_with_password

The target_mechs array needs to be freed on successful return.

(cherry picked from commit 02a85d73c4548d27dcbc1c1681b4bf1370b03632)

ticket: 8304 (new)
version_fixed: 1.12.5
status: resolved

9 years agoTolerate null oid pointer in gss_release_oid()
Greg Hudson [Wed, 10 Jun 2015 23:48:51 +0000 (19:48 -0400)] 
Tolerate null oid pointer in gss_release_oid()

Under some circumstances, gss_inquire_name() can call
gss_release_oid() with a null oid pointer, which currently causes a
null dereference.  The least invasive fix is for gss_release_oid() to
check for the invalid null pointer and return an error, like other
GSS-API functions do.

(cherry picked from commit 4676e823e6ee9a5731872b31c5588c1b5932e0a3)

ticket: 8303 (new)
version_fixed: 1.12.5
status: resolved

9 years agoDocument multi-component profile paths
Greg Hudson [Thu, 23 Oct 2014 19:06:13 +0000 (15:06 -0400)] 
Document multi-component profile paths

In env_variables.rst and krb5_conf.rst, document that KRB5_CONFIG can
contain multiple colon-separated pathnames.

(cherry picked from commit 28dc817d2a065f5e0ab73377350a0529b2f4aa48)

ticket: 8302 (new)
version_fixed: 1.12.5
status: resolved

10 years agoUpdate for krb5-1.12.4-postrelease
Tom Yu [Fri, 29 May 2015 22:49:22 +0000 (18:49 -0400)] 
Update for krb5-1.12.4-postrelease

10 years agoUpdates for krb5-1.12.4 krb5-1.12.4-final
Tom Yu [Fri, 29 May 2015 19:15:55 +0000 (15:15 -0400)] 
Updates for krb5-1.12.4

10 years agomake update-po
Tom Yu [Fri, 22 May 2015 19:19:55 +0000 (15:19 -0400)] 
make update-po

10 years agoUpdate manpages
Tom Yu [Thu, 21 May 2015 22:02:55 +0000 (18:02 -0400)] 
Update manpages

10 years agoFix minor documentation errors
Michael Mattioli [Thu, 23 Apr 2015 05:39:37 +0000 (01:39 -0400)] 
Fix minor documentation errors

Fix typos, remove excess header underlines, and remove trailing
whitespace.

[ghudson@mit.edu: squashed several commits, summarized commit
messages]

(cherry picked from commit 4ad099d28437b542b76053f44f18f763bdcd5152)
(cherry picked from commit 2c31abee54d193a007d2f170d6b6746ce277146f)

ticket: 8195 (new)
version_fixed: 1.12.4
status: resolved

10 years agoPrevent requires_preauth bypass [CVE-2015-2694]
Greg Hudson [Tue, 24 Mar 2015 16:02:37 +0000 (12:02 -0400)] 
Prevent requires_preauth bypass [CVE-2015-2694]

In the OTP kdcpreauth module, don't set the TKT_FLG_PRE_AUTH bit until
the request is successfully verified.  In the PKINIT kdcpreauth
module, don't respond with code 0 on empty input or an unconfigured
realm.  Together these bugs could cause the KDC preauth framework to
erroneously treat a request as pre-authenticated.

CVE-2015-2694:

In MIT krb5 1.12 and later, when the KDC is configured with PKINIT
support, an unauthenticated remote attacker can bypass the
requires_preauth flag on a client principal and obtain a ciphertext
encrypted in the principal's long-term key.  This ciphertext could be
used to conduct an off-line dictionary attack against the user's
password.

    CVSSv2 Vector: AV:N/AC:M/Au:N/C:P/I:P/A:N/E:POC/RL:OF/RC:C

(cherry picked from commit e3b5a5e5267818c97750b266df50b6a3d4649604)
(cherry picked from commit df8afc60d970a7176a55ffe7ce21cfd57ba423cd)

ticket: 8194 (new)
version_fixed: 1.12.4
status: resolved

10 years agoFix LDAP ticket policies on big-endian LP64
Greg Hudson [Mon, 13 Apr 2015 17:09:20 +0000 (13:09 -0400)] 
Fix LDAP ticket policies on big-endian LP64

krb5_ldap_get_value() takes a pointer to int, and should not be passed
a pointer to any integral type which might have a different width.
Use an intermediate variable for each call.

The erroneous calls in ldap_misc.c were passing pointers to int32_t,
which is harmless on all common platforms.  The calls in
ldap_tkt_policy.c were passing pointers to long; on big-endian LP64
platforms, the result would be written to the high 32 bits of the long
value.

(cherry picked from commit 7fbc092107298bded216fbce4cff6592275bff03)
(back ported from commit 50913c7372c5c13a1270d6823f914e07ce0563ba)

ticket: 8193 (new)
version_fixed: 1.12.4
status: resolved

10 years agoDisable principal renames for LDAP
Greg Hudson [Thu, 26 Mar 2015 16:47:06 +0000 (12:47 -0400)] 
Disable principal renames for LDAP

The current principal rename procedure does not work with the LDAP KDB
module, instead having the effect of deleting the principal.  The fix
is not easy and requires amending the DAL (see issue #8065).  For now,
detect LDAP and error out when a rename operation is attempted.

(cherry picked from commit 8483243664a289fea142d8a9de61eba30d713871)
(cherry picked from commit 338cf20b3df6d30a8fe4c4d8c8e3b718edbf35a4)

ticket: 8186 (new)
version_fixed: 1.12.4
status: resolved

10 years agoLog invalid restrictions strings
Greg Hudson [Fri, 13 Mar 2015 17:30:49 +0000 (13:30 -0400)] 
Log invalid restrictions strings

In kadm5int_acl_parse_restrictions(), output a log message if we break
out of the parsing loop with an error.  The current structure of the
loop makes it difficult to pinpoint the bad restrictions field, so
just output the whole string.

(cherry picked from commit e9eaafeab12b2b62595f4dff2fca3345b2d95b4a)
(cherry picked from commit 1ff2ecc7890ae4b843c77c2ba68f5a152806bf05)

ticket: 8185 (new)
version_fixed: 1.12.4
status: resolved

10 years agoDocument correct flag names for kadm5.acl
Greg Hudson [Fri, 13 Mar 2015 16:45:27 +0000 (12:45 -0400)] 
Document correct flag names for kadm5.acl

kadm5.acl entries can include restrictions which can force flag values
on or off.  These flag values are parsed with krb5_string_to_flags(),
which means the flag names are the ones for default_principal_flags,
not the ones for kadmin addprinc/modprinc.

(cherry picked from commit ef21069070c1eb2ab1ade1d1406f5cd3920c83a9)
(cherry picked from commit 185114aa35508e46c90354d8ddea76f65fe556d8)

ticket: 8184 (new)
version_fixed: 1.12.4
status: resolved

10 years agoFix scope of kadmind ACL wildcard back-references
Greg Hudson [Thu, 12 Mar 2015 20:36:33 +0000 (16:36 -0400)] 
Fix scope of kadmind ACL wildcard back-references

In kadm5int_acl_find_entry(), clear the wildcard back-references list
for each acl entry.  Otherwise the wildcards we process can affect
back-references for later entries.

(cherry picked from commit d3d18b8d8d7a47766fd4e9667d045035f43d90ef)
(cherry picked from commit 8e67dce9379c0f50bdccc12619fecad423aa5384)

ticket: 8183
version_fixed: 1.12.4
status: resolved

10 years agoAdd another kadmin ACL test for backreferences
Greg Hudson [Thu, 21 Nov 2013 21:18:27 +0000 (16:18 -0500)] 
Add another kadmin ACL test for backreferences

Add a test using backreferences which don't correspond directly to
principal components, to verify that *N refers to the Nth wildcard and
not the Nth component.

(cherry picked from commit 119281156097a9da659ce5a7c06f0d517994781c)

ticket: 8183 (new)
version_fixed: 1.12.4

10 years agoImport names immediately with COMPOSITE_EXPORT
Solly Ross [Thu, 5 Mar 2015 18:22:58 +0000 (13:22 -0500)] 
Import names immediately with COMPOSITE_EXPORT

RFC 6680 specifies that GSS_Export_name_composite() "outputs a token that
"can be imported with GSS_Import_name(), using GSS_C_NT_COMPOSITE_EXPORT
as the name type...".  Therefore, in the gss_import_name mechglue, we
should perform the import process imediately when either
GSS_C_NT_COMPOSITE_EXPORT or GSS_C_NT_EXPORT_NAME are used (not just
for the later, as is the current functionality).

The naming extension test was also updated to display the result
of importing with GSS_C_NT_COMPOSITE_EXPORT in addition to
GSS_C_NT_EXPORT_NAME.

[ghudson@mit.edu: minor style changes]

(cherry picked from commit 29dec110c43ae9cebdcd935906a3131ca9ac0c99)
(cherry picked from commit f2302383dd3a32bf22f437c4e1d10533323db5dc)

ticket: 8182 (new)
version_fixed: 1.12.4
status: resolved

10 years agoAdd formats section to documentation
Greg Hudson [Fri, 20 Feb 2015 17:56:17 +0000 (12:56 -0500)] 
Add formats section to documentation

Add a new "formats" section to the RST documentation and populate it
with documentation of the credential cache and keytab file formats.

(cherry picked from commit 68ac7ac1f1a1d2939a2c99fa49cecd734614d16d)
(cherry picked from commit 37c02e7fc50a9633b639cbf3daeaeaf1c9c75724)

ticket: 8181 (new)
version_fixed: 1.12.4
status: resolved

10 years agoFix krb5_read_message handling [CVE-2014-5355]
Greg Hudson [Tue, 9 Dec 2014 17:37:44 +0000 (12:37 -0500)] 
Fix krb5_read_message handling [CVE-2014-5355]

In recvauth_common, do not use strcmp against the data fields of
krb5_data objects populated by krb5_read_message(), as there is no
guarantee that they are C strings.  Instead, create an expected
krb5_data value and use data_eq().

In the sample user-to-user server application, check that the received
client principal name is null-terminated before using it with printf
and krb5_parse_name.

CVE-2014-5355:

In MIT krb5, when a server process uses the krb5_recvauth function, an
unauthenticated remote attacker can cause a NULL dereference by
sending a zero-byte version string, or a read beyond the end of
allocated storage by sending a non-null-terminated version string.
The example user-to-user server application (uuserver) is similarly
vulnerable to a zero-length or non-null-terminated principal name
string.

The krb5_recvauth function reads two version strings from the client
using krb5_read_message(), which produces a krb5_data structure
containing a length and a pointer to an octet sequence.  krb5_recvauth
assumes that the data pointer is a valid C string and passes it to
strcmp() to verify the versions.  If the client sends an empty octet
sequence, the data pointer will be NULL and strcmp() will dereference
a NULL pointer, causing the process to crash.  If the client sends a
non-null-terminated octet sequence, strcmp() will read beyond the end
of the allocated storage, possibly causing the process to crash.

uuserver similarly uses krb5_read_message() to read a client principal
name, and then passes it to printf() and krb5_parse_name() without
verifying that it is a valid C string.

The krb5_recvauth function is used by kpropd and the Kerberized
versions of the BSD rlogin and rsh daemons.  These daemons are usually
run out of inetd or in a mode which forks before processing incoming
connections, so a process crash will generally not result in a
complete denial of service.

Thanks to Tim Uglow for discovering this issue.

CVSSv2: AV:N/AC:L/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C

[tlyu@mit.edu: CVSS score]

(cherry picked from commit 102bb6ebf20f9174130c85c3b052ae104e5073ec)
(cherry picked from commit 21e4e653d8258d525f4b6ca87797d42a8bccc282)

ticket: 8180 (new)
version_fixed: 1.12.4
status: resolved

10 years agoUpdate for krb5-1.12.3-postrelease
Tom Yu [Wed, 18 Feb 2015 23:11:18 +0000 (18:11 -0500)] 
Update for krb5-1.12.3-postrelease

10 years agoUpdates for krb5-1.12.3 krb5-1.12.3-final
Tom Yu [Wed, 18 Feb 2015 21:23:49 +0000 (16:23 -0500)] 
Updates for krb5-1.12.3

10 years agomake update-po
Tom Yu [Tue, 17 Feb 2015 21:20:49 +0000 (16:20 -0500)] 
make update-po

10 years agoUpdate manpages
Tom Yu [Tue, 17 Feb 2015 21:20:25 +0000 (16:20 -0500)] 
Update manpages

10 years agomake depend
Tom Yu [Tue, 17 Feb 2015 21:19:50 +0000 (16:19 -0500)] 
make depend

10 years agoSupport keyless principals in LDAP [CVE-2014-5354]
Ben Kaduk [Wed, 19 Nov 2014 17:04:46 +0000 (12:04 -0500)] 
Support keyless principals in LDAP [CVE-2014-5354]

Operations like "kadmin -q 'addprinc -nokey foo'" or
"kadmin -q 'purgekeys -all foo'" result in principal entries with
no keys present, so krb5_encode_krbsecretkey() would just return
NULL, which then got unconditionally dereferenced in
krb5_add_ber_mem_ldap_mod().

Apply some fixes to krb5_encode_krbsecretkey() to handle zero-key
principals better, correct the test for an allocation failure, and
slightly restructure the cleanup handler to be shorter and more
appropriate for the usage.  Once it no longer short-circuits when
n_key_data is zero, it will produce an array of length two with both
entries NULL, which is treated as an empty list by the LDAP library,
the correct behavior for a keyless principal.

However, attributes with empty values are only handled by the LDAP
library for Modify operations, not Add operations (which only get
a sequence of Attribute, with no operation field).  Therefore, only
add an empty krbprincipalkey to the modlist when we will be performing a
Modify, and not when we will be performing an Add, which is conditional
on the (misspelled) create_standalone_prinicipal boolean.

CVE-2014-5354:

In MIT krb5, when kadmind is configured to use LDAP for the KDC
database, an authenticated remote attacker can cause a NULL
dereference by inserting into the database a principal entry which
contains no long-term keys.

In order for the LDAP KDC backend to translate a principal entry
from the database abstraction layer into the form expected by the
LDAP schema, the principal's keys are encoded into a
NULL-terminated array of length-value entries to be stored in the
LDAP database.  However, the subroutine which produced this array
did not correctly handle the case where no keys were present,
returning NULL instead of an empty array, and the array was
unconditionally dereferenced while adding to the list of LDAP
operations to perform.

Versions of MIT krb5 prior to 1.12 did not expose a way for
principal entries to have no long-term key material, and
therefore are not vulnerable.

    CVSSv2 Vector: AV:N/AC:M/Au:S/C:N/I:N/A:P/E:H/RL:OF/RC:C

(cherry picked from commit 04038bf3633c4b909b5ded3072dc88c8c419bf16)

ticket: 8138 (new)
version_fixed: 1.12.3
subject: kadmind with ldap backend crashes when putting keyless entries [CVE-2014-5354]
status: resolved

10 years agoAdd tests for LDAP ticket/policy name misuse
Greg Hudson [Fri, 5 Dec 2014 19:02:04 +0000 (14:02 -0500)] 
Add tests for LDAP ticket/policy name misuse

(cherry picked from commit e8df0458673071e56346730fa843c83aca88631f)

ticket: 8137
version_fixed: 1.12.3
status: resolved

10 years agoFix LDAP misused policy name crash [CVE-2014-5353]
Greg Hudson [Fri, 5 Dec 2014 19:01:39 +0000 (14:01 -0500)] 
Fix LDAP misused policy name crash [CVE-2014-5353]

In krb5_ldap_get_password_policy_from_dn, if LDAP_SEARCH returns
successfully with no results, return KRB5_KDB_NOENTRY instead of
returning success with a zeroed-out policy object.  This fixes a null
dereference when an admin attempts to use an LDAP ticket policy name
as a password policy name.

CVE-2014-5353:

In MIT krb5, when kadmind is configured to use LDAP for the KDC
database, an authenticated remote attacker can cause a NULL dereference
by attempting to use a named ticket policy object as a password policy
for a principal.  The attacker needs to be authenticated as a user who
has the elevated privilege for setting password policy by adding or
modifying principals.

Queries to LDAP scoped to the krbPwdPolicy object class will correctly
not return entries of other classes, such as ticket policy objects, but
may return success with no returned elements if an object with the
requested DN exists in a different object class.  In this case, the
routine to retrieve a password policy returned success with a password
policy object that consisted entirely of zeroed memory.  In particular,
accesses to the policy name will dereference a NULL pointer.  KDC
operation does not access the policy name field, but most kadmin
operations involving the principal with incorrect password policy
will trigger the crash.

Thanks to Patrik Kis for reporting this problem.

CVSSv2 Vector: AV:N/AC:M/Au:S/C:N/I:N/A:C/E:H/RL:OF/RC:C

[kaduk@mit.edu: CVE description and CVSS score]

(cherry picked from commit d1f707024f1d0af6e54a18885322d70fa15ec4d3)

ticket: 8137 (new)
version_fixed: 1.12.3
status: resolved

10 years agoUpdate example enctypes in kdc_conf.rst
Tom Yu [Wed, 5 Nov 2014 20:57:51 +0000 (15:57 -0500)] 
Update example enctypes in kdc_conf.rst

Use modern enctypes for values of master_key_type and
supported_enctypes in the example kdc.conf in kdc_conf.rst.

(cherry picked from commit 3eeb1a7eaa6757502d73944b7694405cdd571e1c)

ticket: 8136 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix input race condition in t_skew.py
Greg Hudson [Wed, 5 Nov 2014 19:12:35 +0000 (14:12 -0500)] 
Fix input race condition in t_skew.py

In two of the kinit tests run by t_skew.py, we expect kinit to exit
before reading the password.  If we supply a password input for those
commands, we can fail with a broken pipe exception if the master
process tries to write the password after the slave process exits.

Also correctly check the output of the last kinit invocation.

(cherry picked from commit 2457bf66c466321dd36cd3c76bc36bb589d31587)

ticket: 8135 (new)
version_fixed: 1.12.3
status: resolved

10 years agoRemove length limit on PKINIT PKCS#12 prompt
Greg Hudson [Wed, 29 Oct 2014 16:16:40 +0000 (12:16 -0400)] 
Remove length limit on PKINIT PKCS#12 prompt

Long pathnames can trigger the 128-byte prompt length limit in
pkinit_get_certs_pkcs12.  Use asprintf instead of snprintf.  Also
check the result of the prompter invocation.

(cherry picked from commit 3c330ea5846ca02da36a0cb5a5c879364d28a267)

ticket: 8134 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix cursor leak in krb5_verify_init_creds
Greg Hudson [Mon, 20 Oct 2014 17:19:26 +0000 (13:19 -0400)] 
Fix cursor leak in krb5_verify_init_creds

In copy_creds_except, call krb5_cc_end_seq_get so we don't leak the
ccache cursor.

(cherry picked from commit 62894f854daa8251554376b6b6810fd0e9fecb7f)

ticket: 8133 (new)
version_fixed: 1.12.3
status: resolved

10 years agoReport output ccache errors getting initial creds
Greg Hudson [Mon, 20 Oct 2014 16:52:45 +0000 (12:52 -0400)] 
Report output ccache errors getting initial creds

In init_creds_step_reply, if we get an error storing output
credentials, do set ctx->complete (since retrieving creds or times
will work at this point) but don't suppress the error code.

(cherry picked from commit feeddfb78ca5de066a509b6be8551d036e0f2c8a)

ticket: 8132 (new)
version_fixed: 1.12.3
status: resolved

10 years agoParse "ktadd -norandkey" in remote kadmin client
Tom Yu [Thu, 16 Oct 2014 19:40:33 +0000 (15:40 -0400)] 
Parse "ktadd -norandkey" in remote kadmin client

The remote kadmin client would not parse the "-norandkey" option to
the ktadd subcommand, terminating option parsing and possibly causing
options to be interpreted as principal names.

(cherry picked from commit 13e9694b17945d43d0cfc203b2645204f2d87086)

ticket: 8131 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix typo in doc for krb5_get_init_creds_keytab()
Tom Yu [Tue, 14 Oct 2014 18:40:34 +0000 (14:40 -0400)] 
Fix typo in doc for krb5_get_init_creds_keytab()

(cherry picked from commit 49f8ec5975df3cb5f204444df2a284b2e662df85)

ticket: 8130 (new)
version_fixed: 1.12.3
status: resolved

10 years agoUse gssalloc_malloc for GSS error tokens
Greg Hudson [Wed, 8 Oct 2014 00:22:52 +0000 (20:22 -0400)] 
Use gssalloc_malloc for GSS error tokens

In kg_accept_krb5, use gssalloc_malloc when allocating space for the
error token, since it will be freed with gssalloc_free.  Using malloc
can cause heap corruption on Windows.  This bug was masked by #1445
before 1.12.

(cherry picked from commit 68cfc8b4e6338b78dce5a960ce47974a73906fac)

ticket: 8129 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix OTP tests with pyrad 2.x
Greg Hudson [Mon, 22 Dec 2014 23:37:36 +0000 (18:37 -0500)] 
Fix OTP tests with pyrad 2.x

Declare User-Password as having type "octets" instead of "string" or
pyrad 2.x will throw a decoding error when retrieving it.

(cherry picked from commit 57dc24093015d292189ef23313ef8ff2a81431e4)

ticket: 8128 (new)
version_fixed: 1.12.3
status: resolved

10 years agoCheck for null *iter_p in profile_iterator()
Greg Hudson [Wed, 14 Jan 2015 18:10:39 +0000 (13:10 -0500)] 
Check for null *iter_p in profile_iterator()

In profile_iterator(), return PROF_MAGIC_ITERATOR if *iter_p is NULL,
instead of dereferencing a null pointer, as we did prior to 1.10.
Correct calling code will not trigger this case, but incorrect code
has been reported in the field.

(cherry picked from commit 9a343200d305e7c8df6e556d63afaee42194175f)

ticket: 8127 (new)
version_fixed: 1.12.3
status: resolved

10 years agoExport function gss_add_cred_with_password
Robbie Harwood (frozencemetery) [Tue, 20 Jan 2015 20:43:40 +0000 (15:43 -0500)] 
Export function gss_add_cred_with_password

This function is already present in gssapi_ext.h, but without
exporting it, a link error will be produced every time it is used.

(cherry picked from commit 266cce14ee39f6d11b186ee988cffd0c2a119f3d)

ticket: 8126 (new)
version_fixed: 1.12.3
status: resolved

10 years agoAdd test for kinit -C WRONG_REALM response
Greg Hudson [Fri, 23 Jan 2015 17:52:31 +0000 (12:52 -0500)] 
Add test for kinit -C WRONG_REALM response

(cherry picked from commit c0778ab2252ece4c3510788d9b72f7f5e3bb05dd)

ticket: 8125
version_fixed: 1.12.3
status: resolved

10 years agoDo not loop on principal unknown errors
Simo Sorce [Tue, 20 Jan 2015 18:48:34 +0000 (13:48 -0500)] 
Do not loop on principal unknown errors

If the canonicalize flag is set, the MIT KDC always return the client
principal when KRB5_KDC_ERR_C_PRICIPAL_UNKNOWN is returned.

Check that this is really a referral by testing that the returned
client realm differs from the requested one.

[ghudson@mit.edu: simplified and narrowed is_referral() contract.
Note that a WRONG_REALM response with e-data or FAST error padata
could now be passed through k5_preauth_tryagain() if it has an empty
crealm or a crealm equal to the requested client realm.  Such a
response is unexpected in practice and there is nothing dangerous
about handling it this way.]

(cherry picked from commit d5755694b620570defeecee772def90a2733c6cc)

ticket: 8125 (new)
version_fixed: 1.12.3
status: resolved

10 years agoAdd missing salt from enctype in t_kdb.py test
Patrik Kis [Fri, 24 Oct 2014 14:15:05 +0000 (16:15 +0200)] 
Add missing salt from enctype in t_kdb.py test

In commit 78a7f2a02b82bf297817cd717f092ead40b575b2, which added a test
for bug #7980, some command invocations used new syntax that omitted
salt types from the keysalt list.  This omission of salt types is not
supported on krb5-1.12, resulting in test failures.  Update to use the
valid (old) key salt syntax.

[tlyu@mit.edu: commit message]

ticket: 8071 (new)
version_fixed: 1.12.3
status: resolved

10 years agoAdd test program for gss_process_context_token
Tom Yu [Wed, 4 Feb 2015 21:14:04 +0000 (16:14 -0500)] 
Add test program for gss_process_context_token

Add a new test program t_pcontok to exercise
gss_process_context_token, and run it from t_gssapi.py.

(back ported from commit bfb472ff67c00da2f2b0d0ada1af57a2c4493a11)

ticket: 8067
version_fixed: 1.12.3
status: resolved

10 years agoFix gssrpc data leakage [CVE-2014-9423]
Greg Hudson [Mon, 29 Dec 2014 18:17:56 +0000 (13:17 -0500)] 
Fix gssrpc data leakage [CVE-2014-9423]

[MITKRB5-SA-2015-001] In svcauth_gss_accept_sec_context(), do not copy
bytes from the union context into the handle field we send to the
client.  We do not use this handle field, so just supply a fixed
string of "xxxx".

In gss_union_ctx_id_struct, remove the unused "interposer" field which
was causing part of the union context to remain uninitialized.

(cherry picked from commit 5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c)

ticket: 8070 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix kadmind server validation [CVE-2014-9422]
Greg Hudson [Mon, 29 Dec 2014 18:27:42 +0000 (13:27 -0500)] 
Fix kadmind server validation [CVE-2014-9422]

[MITKRB5-SA-2015-001] In kadmind's check_rpcsec_auth(), use
data_eq_string() instead of strncmp() to check components of the
server principal, so that we don't erroneously match left substrings
of "kadmin", "history", or the realm.

(cherry picked from commit 6609658db0799053fbef0d7d0aa2f1fd68ef32d8)

ticket: 8069 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix kadm5/gssrpc XDR double free [CVE-2014-9421]
Greg Hudson [Sat, 27 Dec 2014 19:16:13 +0000 (14:16 -0500)] 
Fix kadm5/gssrpc XDR double free [CVE-2014-9421]

[MITKRB5-SA-2015-001] In auth_gssapi_unwrap_data(), do not free
partial deserialization results upon failure to deserialize.  This
responsibility belongs to the callers, svctcp_getargs() and
svcudp_getargs(); doing it in the unwrap function results in freeing
the results twice.

In xdr_krb5_tl_data() and xdr_krb5_principal(), null out the pointers
we are freeing, as other XDR functions such as xdr_bytes() and
xdr_string().

(cherry picked from commit a197e92349a4aa2141b5dff12e9dd44c2a2166e3)

ticket: 8068 (new)
version_fixed: 1.12.3
status: resolved

10 years agoFix gss_process_context_token() [CVE-2014-5352]
Tom Yu [Wed, 4 Feb 2015 21:09:16 +0000 (16:09 -0500)] 
Fix gss_process_context_token() [CVE-2014-5352]

[MITKRB5-SA-2015-001] The krb5 gss_process_context_token() should not
actually delete the context; that leaves the caller with a dangling
pointer and no way to know that it is invalid.  Instead, mark the
context as terminated, and check for terminated contexts in the GSS
functions which expect established contexts.  Also add checks in
export_sec_context and pseudo_random, and adjust t_prf.c for the
pseudo_random check.

(back ported from commit 82dc33da50338ac84c7b4102dc6513d897d0506a)

ticket: 8067 (new)
version_fixed: 1.12.3
status: resolved

10 years agoUpdate copyright years
Tom Yu [Wed, 4 Feb 2015 21:07:31 +0000 (16:07 -0500)] 
Update copyright years

10 years agoRemove rtm_type_name()
Ben Kaduk [Fri, 1 Nov 2013 19:12:33 +0000 (15:12 -0400)] 
Remove rtm_type_name()

It has been unused since 2009 when Ken decided that the routing log
messages were too verbose (commit 91fc077c96926dd60).

(back ported from bcc91c8d8b3d5b775cfde1ee461d7e0394070852)

ticket: 8036 (new)
version_fixed: 1.12.3

10 years agoLet libgssapi see TGTs in the MSLSA cache
Ben Kaduk [Thu, 21 Aug 2014 22:56:24 +0000 (18:56 -0400)] 
Let libgssapi see TGTs in the MSLSA cache

When the current user is a local administrator of a windows machine
where User Account Control (UAC) is enabled, the Windows LSA will
return a block of zeros as the session key for any TGT entry in the
MSLSA: cache.  The lcc_retrieve() implementation checks for such
"null" session keys and prevents them from escaping to callers (as
attempts to use them would encounger strange errors).  However,
when the TGT is the only entry in the cache, this filtering prevents
scan_ccache() from detecting that the cache contains non-expired
credentials (and that there is a TGT present).

Since scan_ccache() is only looking at metadata in the cache entries,
and does not need to actually use any tickets or session keys, set
the KRB5_TC_NOTICKET flag on the ccache before scanning it.  This
will allow the MSLSA implementation to return a cred for the TGT
entry and cause the GSSAPI credential selection algorithm to function
properly.

(cherry picked from commit 0794746f8d8e6b8ce3748d442d2bc1faecf960ce)

ticket: 8013 (new)
version_fixed: 1.12.3
subject: gssapi.dll fails to detect TGTs in the MSLSA cache when UAC is enabled
status: resolved

10 years agoAdd some KDC entries to the registry via WiX
Ben Kaduk [Thu, 21 Aug 2014 21:33:11 +0000 (17:33 -0400)] 
Add some KDC entries to the registry via WiX

Though our library happily uses DNS, I can't get Windows to
successfully contact KDCs found through the SRV records.
So, we do need to stay in the business of shipping around
KDC entries, after all.

(cherry picked from commit d2b76e1ba0f4bb0ec7e560a9a681d938f45f950c)

ticket: 7999

10 years agoTry to scan_ccache() after leash picks a cache
Ben Kaduk [Thu, 21 Aug 2014 16:48:39 +0000 (12:48 -0400)] 
Try to scan_ccache() after leash picks a cache

We need to call scan_ccache() in order to notice that there
are credentials and read their expire time.

The call to scan_ccache() in the Leash case was inadvertently
removed as part of commit 8651f3339ccc5a623172a8edfb9cf522883acacd.

(cherry picked from commit 674f7d7abe2d4f8bc3fe791e4347a332e3ccfd41)

ticket: 8012 (new)
version_fixed: 1.12.3
subject: gssapi.dll tries to get initial creds even when some are present
status: resolved

11 years agokrb5-1.12.2-postrelease
Tom Yu [Mon, 11 Aug 2014 22:24:45 +0000 (18:24 -0400)] 
krb5-1.12.2-postrelease

11 years agoUpdates for krb5-1.12.2 krb5-1.12.2-final
Tom Yu [Mon, 11 Aug 2014 20:58:08 +0000 (16:58 -0400)] 
Updates for krb5-1.12.2

11 years agoMake tcl_kadm5.c work with Tcl 8.6
Greg Hudson [Wed, 28 May 2014 22:06:59 +0000 (18:06 -0400)] 
Make tcl_kadm5.c work with Tcl 8.6

Directly accessing the result field of Tcl_Interp has been deprecated
for a long time, requires a special define in Tcl 8.6, and will be
impossible in Tcl 9.  Use Tcl_SetResult instead.  The new error
messages are less helpful than the old ones, but this is just support
infrastructure for old tests, so it isn't important.

(cherry picked from commit b63496d7b44f090ea5d300dc09b4fc043138ae38)

ticket: 7924
version_fixed: 1.12.2
status: resolved

11 years agoAdd regression test for LDAP key fencepost bug
Greg Hudson [Sat, 2 Aug 2014 02:10:35 +0000 (22:10 -0400)] 
Add regression test for LDAP key fencepost bug

(cherry picked from commit 0d78da225612e13d0b1cf515987305535d2f9dce)

ticket: 7980
status: resolved

11 years agoFix LDAP key data segmentation [CVE-2014-4345]
Tomas Kuthan [Fri, 1 Aug 2014 13:25:50 +0000 (15:25 +0200)] 
Fix LDAP key data segmentation [CVE-2014-4345]

For principal entries having keys with multiple kvnos (due to use of
-keepold), the LDAP KDB module makes an attempt to store all the keys
having the same kvno into a single krbPrincipalKey attribute value.
There is a fencepost error in the loop, causing currkvno to be set to
the just-processed value instead of the next kvno.  As a result, the
second and all following groups of multiple keys by kvno are each
stored in two krbPrincipalKey attribute values.  Fix the loop to use
the correct kvno value.

CVE-2014-4345:

In MIT krb5, when kadmind is configured to use LDAP for the KDC
database, an authenticated remote attacker can cause it to perform an
out-of-bounds write (buffer overrun) by performing multiple cpw
-keepold operations.  An off-by-one error while copying key
information to the new database entry results in keys sharing a common
kvno being written to different array buckets, in an array whose size
is determined by the number of kvnos present.  After sufficient
iterations, the extra writes extend past the end of the
(NULL-terminated) array.  The NULL terminator is always written after
the end of the loop, so no out-of-bounds data is read, it is only
written.

Historically, it has been possible to convert an out-of-bounds write
into remote code execution in some cases, though the necessary
exploits must be tailored to the individual application and are
usually quite complicated.  Depending on the allocated length of the
array, an out-of-bounds write may also cause a segmentation fault
and/or application crash.

    CVSSv2 Vector: AV:N/AC:M/Au:S/C:C/I:C/A:C/E:POC/RL:OF/RC:C

[ghudson@mit.edu: clarified commit message]
[kaduk@mit.edu: CVE summary, CVSSv2 vector]

(cherry picked from commit 81c332e29f10887c6b9deb065f81ba259f4c7e03)

ticket: 7980
version_fixed: 1.12.2
status: resolved

11 years agoUse zapfree in krb5_decrypt_tkt_part
Andreas Schneider [Wed, 6 Aug 2014 14:06:54 +0000 (16:06 +0200)] 
Use zapfree in krb5_decrypt_tkt_part

(cherry picked from commit 18333f731b8cb3b4610b1d623caef9347c785f7b)

ticket: 7982
version_fixed: 1.12.2
status: resolved

11 years agoFix creation/rename of top-level profile sections
Greg Hudson [Wed, 16 Jul 2014 20:30:26 +0000 (16:30 -0400)] 
Fix creation/rename of top-level profile sections

profile_rename_section should demand only one name.

profile_add_relation should demand only one name if it is creating a
new section.  It aso needs to reset state before calling
profile_find_node for the section, in case it didn't look up any
parent sections previously.

(cherry picked from commit 590df2f41f84e0f9492e08f7dbd26fbcd3118ea0)

ticket: 7972
version_fixed: 1.12.2
status: resolved

11 years agoFix deleted node handling in libprofile
Greg Hudson [Wed, 16 Jul 2014 20:02:21 +0000 (16:02 -0400)] 
Fix deleted node handling in libprofile

In profile_find_node, skip deleted nodes when finding the second
match.  Otherwise, profile_clear_nodes could return an error if a node
has some values to clear but the last one is deleted.

In profile_node_iterator, skip deleted nodes when looking up the
section names.  Otherwise we could iterate over a deleted section
and/or ignore its replacement.

(cherry picked from commit e7f50a1c11845ba73ce4ffa4729d10113563a247)

ticket: 7971
version_fixed: 1.12.2
status: resolved

11 years agoUse system dictionary for db2 tests again
Greg Hudson [Tue, 18 Feb 2014 06:14:01 +0000 (01:14 -0500)] 
Use system dictionary for db2 tests again

The built-in word list is not long enough for all of the libdb2 tests
to run properly.  Revert d21a86e47a7cda29225013e08d060095b94b2ee7 and
go back to using the system dictionary if we find one.  However, omit
any lines from the chosen word list which contain non-alphabetical
characters.

(cherry picked from commit dba768e873d3ae34cfb2ff9d9c2d3644981f23a5)

ticket: 7860
version_fixed: 1.12.2
status: resolved

11 years agoUse TAILQ macros instead of CIRCLEQ in libdb2
Greg Hudson [Mon, 17 Feb 2014 05:18:41 +0000 (00:18 -0500)] 
Use TAILQ macros instead of CIRCLEQ in libdb2

The optimizer in gcc 4.8.1 (but not the current gcc head revision)
breaks the queue.h CIRCLEQ macros, apparently due to an overzealous
strict aliasing deduction.  Use TAILQ macros in the libdb2 mpool code
instead.

(cherry picked from commit 26d874412983c4c9979a9f5e7bec51834ad4cda5)

ticket: 7860
version_fixed: 1.12.2
status: resolved

11 years agoRemove indent workaround in man page RST sources
Greg Hudson [Thu, 12 Jun 2014 18:34:26 +0000 (14:34 -0400)] 
Remove indent workaround in man page RST sources

docutils 0.10 properly adds indentation to example blocks in man
pages, so we do not need to force an extra indentation level.  Get rid
of the workaround wherever we use it.

(back ported from 4bd50f73c80a86852ec0879abdf52202be40892b)

ticket: 7954
version_fixed: 1.12.2
status: resolved

11 years agoFix null deref in SPNEGO acceptor [CVE-2014-4344]
Greg Hudson [Tue, 15 Jul 2014 16:56:01 +0000 (12:56 -0400)] 
Fix null deref in SPNEGO acceptor [CVE-2014-4344]

When processing a continuation token, acc_ctx_cont was dereferencing
the initial byte of the token without checking the length.  This could
result in a null dereference.

CVE-2014-4344:

In MIT krb5 1.5 and newer, an unauthenticated or partially
authenticated remote attacker can cause a NULL dereference and
application crash during a SPNEGO negotiation by sending an empty
token as the second or later context token from initiator to acceptor.
The attacker must provide at least one valid context token in the
security context negotiation before sending the empty token.  This can
be done by an unauthenticated attacker by forcing SPNEGO to
renegotiate the underlying mechanism, or by using IAKERB to wrap an
unauthenticated AS-REQ as the first token.

    CVSSv2 Vector: AV:N/AC:L/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C

[kaduk@mit.edu: CVE summary, CVSSv2 vector]

(cherry picked from commit 524688ce87a15fc75f87efc8c039ba4c7d5c197b)

ticket: 7970
version_fixed: 1.12.2
status: resolved

11 years agoFix double-free in SPNEGO [CVE-2014-4343]
David Woodhouse [Tue, 15 Jul 2014 16:54:15 +0000 (12:54 -0400)] 
Fix double-free in SPNEGO [CVE-2014-4343]

In commit cd7d6b08 ("Verify acceptor's mech in SPNEGO initiator") the
pointer sc->internal_mech became an alias into sc->mech_set->elements,
which should be considered constant for the duration of the SPNEGO
context.  So don't free it.

CVE-2014-4343:

In MIT krb5 releases 1.10 and newer, an unauthenticated remote
attacker with the ability to spoof packets appearing to be from a
GSSAPI acceptor can cause a double-free condition in GSSAPI initiators
(clients) which are using the SPNEGO mechanism, by returning a
different underlying mechanism than was proposed by the initiator.  At
this stage of the negotiation, the acceptor is unauthenticated, and
the acceptor's response could be spoofed by an attacker with the
ability to inject traffic to the initiator.

Historically, some double-free vulnerabilities can be translated into
remote code execution, though the necessary exploits must be tailored
to the individual application and are usually quite
complicated. Double-frees can also be exploited to cause an
application crash, for a denial of service.  However, most GSSAPI
client applications are not vulnerable, as the SPNEGO mechanism is not
used by default (when GSS_C_NO_OID is passed as the mech_type argument
to gss_init_sec_context()).  The most common use of SPNEGO is for
HTTP-Negotiate, used in web browsers and other web clients.  Most such
clients are believed to not offer HTTP-Negotiate by default, instead
requiring a whitelist of sites for which it may be used to be
configured.  If the whitelist is configured to only allow
HTTP-Negotiate over TLS connections ("https://"), a successful
attacker must also spoof the web server's SSL certificate, due to the
way the WWW-Authenticate header is sent in a 401 (Unauthorized)
response message.  Unfortunately, many instructions for enabling
HTTP-Negotiate in common web browsers do not include a TLS
requirement.

    CVSSv2 Vector: AV:N/AC:H/Au:N/C:C/I:C/A:C/E:POC/RL:OF/RC:C

[kaduk@mit.edu: CVE summary and CVSSv2 vector]

(cherry picked from commit f18ddf5d82de0ab7591a36e465bc24225776940f)

ticket: 7969
version_fixed: 1.12.2
status: resolved

11 years agoFix leak on GSS module symbol resolution error
Simo Sorce [Thu, 10 Jul 2014 14:04:06 +0000 (10:04 -0400)] 
Fix leak on GSS module symbol resolution error

If krb5int_get_plugin_func fails, errinfo may contain an allocated
error message.  Free it on error when loading GSS modules.

[ghudson@mit.edu: also fix GSS_ADD_DYNAMIC_METHOD; clarify commit
message]

(cherry picked from commit 53362ba69fb5a60386dd358c3450bfcf4f6b7346)

ticket: 7966
version_fixed: 1.12.2
status: resolved

11 years agoFix calloc check in krb5_authdata_context_init
Greg Hudson [Fri, 18 Jul 2014 18:51:13 +0000 (14:51 -0400)] 
Fix calloc check in krb5_authdata_context_init

(cherry picked from commit 4abfd7bc3819a66f77a1cf121b7608af624ecb6e)

ticket: 7973
version_fixed: 1.12.2
status: resolved

11 years agoFix race in util/profile/Makefile.in
Greg Hudson [Thu, 17 Oct 2013 18:02:14 +0000 (14:02 -0400)] 
Fix race in util/profile/Makefile.in

$(BUILDTOP)/include/profile.h was being updated by two different
rules, which could collide with make -j.  Use a dependency from
includes instead of a redundant rule.

(cherry picked from commit 4d3827ac1b0e9e6447a132c57f3e2d74d3dfe8a9)

ticket: 7967
version_fixed: 1.12.2
status: resolved

11 years agoFix several memory leaks in LDAP KDB modules
Greg Hudson [Wed, 11 Jun 2014 03:53:31 +0000 (23:53 -0400)] 
Fix several memory leaks in LDAP KDB modules

Fix memory leaks discovered by running valgrind over kdbtest, and some
related leaks.  Many of them result from not calling ldap_msgfree
after an unsuccessful search (as the OpenLDAP documentation requires)
or after an exception following a search, so many of the fixes move or
add ldap_msgfree calls to cleanup labels.

ldap_osa_free_princ_ent was not used, and could not be used because it
frees the container while krb5_lookup_tl_kadm_data uses a
caller-allocated container.  Change it to leave the container alone,
but to correctly destroy xdrs.  Use it in krb5_ldap_put_principal
where princ_ent was leaked.

In krb5_ldap_put_principal, subtreelist is declared twice in interior
scopes and not properly freed; move it to function scope and free it
up in the cleanup label.  Also in krb5_ldap_put_principal, avoiding
decoding multiple KBR5_TL_KADM_DATA values (which we don't expect to
see) as later decodes would cause earlier decodes to leak.

In krb5_encode_krbsecretkey, fix a leak of the krb5_data container and
also add an error check when calling asn1_encode_sequence_of_keys;
otherwise we would dereference a null pointer if we run out of memory
encoding keys (very unlikely).

(cherry picked from commit bfd2a69193ddc1b324d48a7da6455cfbda54fc09)

ticket: 7941
version_fixed: 1.12.2
status: resolved

11 years agoFix build on systems without RTM_OLD*
Ben Kaduk [Thu, 3 Jul 2014 14:42:21 +0000 (10:42 -0400)] 
Fix build on systems without RTM_OLD*

For example, FreeBSD has removed RTM_OLDADD and RTM_OLDDEL from its API
in March 2014, with the message:
Garbage collect long time obsoleted (or never used) stuff from routing API

Only attempt to define behavior for these cases if they are defined.

(cherry picked from commit fd352d41a79013114708e99510b6be3836200237)

ticket: 7955
version_fixed: 1.12.2
status: resolved

11 years agoFix unlikely null dereference in TGS client code
Neng Xue [Mon, 30 Jun 2014 21:04:56 +0000 (14:04 -0700)] 
Fix unlikely null dereference in TGS client code

If krb5_get_tgs_ktypes fails (due to an out-of-memory condition or an
error re-reading the profile), k5_make_tgs_req will dereference a null
pointer.  Check the return value before dereferencing defenctypes.

[ghudson@mit.edu: clarified commit message]

(cherry picked from commit 81e503c09ad9aef4a0afc6bf66a0269cde2151f3)

ticket: 7952
version_fixed: 1.12.2
status: resolved

11 years agoFix KDC worker process argument parsing
Greg Hudson [Wed, 18 Jun 2014 16:58:39 +0000 (12:58 -0400)] 
Fix KDC worker process argument parsing

To create worker processes, the KDC shuts down realms, forks off the
worker processes, then reinitializes realms in each child.
Reinitializing realms requires making a second pass over the
command-line arguments.  To do this with getopt, optind must be
reinitialized to 1 for each pass; otherwise, no options will be seen
the second time around.

(cherry picked from commit 1776fd19120d230115527febbd22979eb64ee1ff)

ticket: 7945
version_fixed: 1.12.2
status: resolved

11 years agoHandle invalid RFC 1964 tokens [CVE-2014-4341...]
Greg Hudson [Thu, 19 Jun 2014 17:49:16 +0000 (13:49 -0400)] 
Handle invalid RFC 1964 tokens [CVE-2014-4341...]

Detect the following cases which would otherwise cause invalid memory
accesses and/or integer underflow:

* An RFC 1964 token being processed by an RFC 4121-only context
  [CVE-2014-4342]

* A header with fewer than 22 bytes after the token ID or an
  incomplete checksum [CVE-2014-4341 CVE-2014-4342]

* A ciphertext shorter than the confounder [CVE-2014-4341]

* A declared padding length longer than the plaintext [CVE-2014-4341]

If we detect a bad pad byte, continue on to compute the checksum to
avoid creating a padding oracle, but treat the checksum as invalid
even if it compares equal.

CVE-2014-4341:

In MIT krb5, an unauthenticated remote attacker with the ability to
inject packets into a legitimately established GSSAPI application
session can cause a program crash due to invalid memory references
when attempting to read beyond the end of a buffer.

    CVSSv2 Vector: AV:N/AC:M/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C

CVE-2014-4342:

In MIT krb5 releases krb5-1.7 and later, an unauthenticated remote
attacker with the ability to inject packets into a legitimately
established GSSAPI application session can cause a program crash due
to invalid memory references when reading beyond the end of a buffer
or by causing a null pointer dereference.

    CVSSv2 Vector: AV:N/AC:M/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C

[tlyu@mit.edu: CVE summaries, CVSS]

(cherry picked from commit fb99962cbd063ac04c9a9d2cc7c75eab73f3533d)

ticket: 7949
version_fixed: 1.12.2
status: resolved

11 years agoFix unlikely null dereference in mk_cred()
Nalin Dahyabhai [Wed, 25 Jun 2014 16:56:42 +0000 (12:56 -0400)] 
Fix unlikely null dereference in mk_cred()

If krb5_encrypt_keyhelper() returns an error, the ciphertext structure
may contain a non-zero length, but it will already have freed the
pointer to its data, making encrypt_credencpart()'s subsequent attempt
to clear and free the memory fail.  Remove that logic.

Based on a patch from Jatin Nansi.

(cherry picked from commit 476284de8dc9a52b5544445cb1b316a417ae88f0)

ticket: 7948
version_fixed: 1.12.2
status: resolved

11 years agoFix error checking in PKINIT authdata creation
Greg Hudson [Sat, 14 Jun 2014 15:23:08 +0000 (11:23 -0400)] 
Fix error checking in PKINIT authdata creation

In create_identifiers_from_stack: check for allocation errors from
PKCS7_ISSUER_AND_SERIAL_new and M_ASN1_INTEGER_dup.  Use
PKCS7_ISSUER_AND_SERIAL_free to more concisely clean up the OpenSSL
issuer variable, and make sure that any partially processed value is
cleaned up on error.  Use calloc to allocate krb5_cas so that all of
its pointers are initially nulled, so that
free_krb5_external_principal_identifier can operate on it safely in
case of error.  Eliminate the retval variable as it was not used
safely.  Rename the error label from "cleanup" to "oom" and separate
it from the successful return path (which has nothing to clean up).

(back ported from commit 09246e64e20f079bef6163e9e1d0ecda7917b8c2)

ticket: 7943
version_fixed: 1.12.2
status: resolved

11 years agoConsolidate DB option documentation
Greg Hudson [Mon, 16 Jun 2014 19:46:09 +0000 (15:46 -0400)] 
Consolidate DB option documentation

Document DB options in the kadmin/kadmin.local man page, in their own
section.  Refer to that section from the documentation of the -x
parameter of each other command which supports DB options.  Add
documentation for the "dbname" DB2 option.

(cherry picked from commit 1cddc360c25386a55dc2f2d44056c88721784dd6)

ticket: 7946
version_fixed: 1.12.2
status: resolved

11 years agoImprove PKINIT certificate documentation
Greg Hudson [Fri, 6 Jun 2014 21:41:51 +0000 (17:41 -0400)] 
Improve PKINIT certificate documentation

Describe how to use a commercially-issued server certificate for
anonymous PKINIT.  Separate the KDC and client configuration
instructions so that the steps necessary for anonymous PKINIT are not
combined with the additional steps necessary for regular PKINIT.
Describe kpServerAuth as the EKU used in commercially issued server
certificates, not as the value used by Microsoft (which does not
appear to be true according to [MS-PKCA]).

(cherry picked from commit 677c7753923e5efa078074611d4474fbcc10f6a1)

ticket: 7931
version_fixed: 1.12.2
status: resolved

11 years agoDo not document pkinit_win2k
Greg Hudson [Fri, 6 Jun 2014 21:57:40 +0000 (17:57 -0400)] 
Do not document pkinit_win2k

This variable was never used in the PKINIT code as it was contributed;
there was only code to read its value.

(cherry picked from commit e161636590429aa78a3f04a8bbe0a36dda48a8ab)

ticket: 7932
version_fixed: 1.12.2
status: resolved

11 years agoAdd missing profile functions to libkrb5 exports
Greg Hudson [Wed, 4 Jun 2014 20:18:21 +0000 (16:18 -0400)] 
Add missing profile functions to libkrb5 exports

profile_flush_to_buffer, profile_flush_to_file, profile_free_buffer,
profile_init_flags, and profile_init_vtable are all public profile
functions, but are inaccessible to libkrb5 applications on some
platforms because they were never added to the export list.  Add them
now.

(libprofile functions have never been part of the Windows DLL export
list, so do not change krb5_32.def at this time.)

(cherry picked from commit dc1a76ccc5d3a6972d0f21d38389ff39e54f283a)

ticket: 7930
version_fixed: 1.12.2
status: resolved

11 years agoDo not loop on add_cred_from and other new methods
Sam Hartman [Wed, 4 Jun 2014 16:06:27 +0000 (12:06 -0400)] 
Do not loop on add_cred_from and other new methods

Several new GSS-API methods were added but GSSAPI_ADD_METHOD was
called to add them rather than GSSAPI_ADD_METHOD_NOLOOP.  This means
that the implementation from the GSS-API mechglue would be used if the
mechanism had no implementation.  As a result, the mechglue will call
into itself exhausting the call stack in an endless loop when one of
these methods is called.

(cherry picked from commit 41d38531043b99e8daa334f2b6ddf376adf1e878)

ticket: 7926
version_fixed: 1.12.2
status: resolved

11 years agoTreat LDAP KrbKey salt field as optional
Greg Hudson [Fri, 23 May 2014 23:58:41 +0000 (19:58 -0400)] 
Treat LDAP KrbKey salt field as optional

Per the ASN.1 definition, the KrbKey salt field is optional.  Since
1.7, we have been treating it as mandatory in the encoder; since 1.11,
we have been treating it as mandatory in the decoder.  Mostly by luck,
we have been encoding a salt type of 0 when key_data_ver is 1, but we
really should not be looking at key_data_type[1] or key_data_length[1]
in this situation.  Treat the salt field as optional in the encoder
and decoder.  Although the previous commit ensures that we continue to
always encode a salt (without any dangerous assumptions about
krb5_key_data constructors), this change will allow us to decode key
data encoded by 1.6 without salt fields.

This also fixes issue #7918, by properly setting key_data_ver to 2 if
a salt type but no salt value is present.  It is difficult to get the
decoder to actually assign 2 to key_data_ver just because the salt
field is there, so take care of that in asn1_decode_sequence_of_keys.

Adjust kdbtest.c to match the new behavior by setting key_data_ver to
2 in both test keys.

(cherry picked from commit fb5cd8df0dbd04dac4f610e68cba5b80a3cb8d48)

ticket: 7919
version_fixed: 1.12.2
status: resolved

11 years agoAlways include salt in LDAP KrbKey encoding
Greg Hudson [Sun, 25 May 2014 02:58:26 +0000 (22:58 -0400)] 
Always include salt in LDAP KrbKey encoding

In the LDAP KDB module, ensure that every krb5_key_data we pass to
asn1_encode_sequence_of_keys includes a salt type, for compatibility
with the decoder in unpatched krb5 1.11 and 1.12.

This is not a behavior change by itself; since 1.7 the encoder has
always included a KrbKey salt field because it erroneously treats that
field as non-optional.  (Luckily, the encoded salt always happens to
have salt type 0 because krb5_key_data constructors start with zeroed
memory.)  The next commit will fix the encoder and decoder to properly
treat the KrbKey salt field as optional, so we need this change to
ensure that our encodings remain compatible.

Also fix the ASN.1 tests to set key_data_ver correctly for the sample
test key data.

(cherry picked from commit 1825455ede7e61ab934b16262fb5b12b78a52f1a)

ticket: 7919
version_fixed: 1.12.2
status: resolved

11 years agoDo not document pkinit_mapping_file
Greg Hudson [Sun, 1 Jun 2014 14:41:27 +0000 (10:41 -0400)] 
Do not document pkinit_mapping_file

This feature was never implemented in the PKINIT code as it was
contributed; there was only stub support for reading the filename.

(cherry picked from commit 8da21b0ec18cf9306a8c1b3410d5c6ab36acdd21)

ticket: 7928
version_fixed: 1.12.2
status: resolved

11 years agoChange example module name in host_config.rst
Greg Hudson [Tue, 27 May 2014 17:01:49 +0000 (13:01 -0400)] 
Change example module name in host_config.rst

Don't use "otp" as the example clpreauth module name in
host_config.rst, since we now ship an effectively built-in otp
clpreauth module.  Instead use "mypreauth".

(cherry picked from commit 26a43afbc214e8d24cf261f245007192eccb7ed5)

ticket: 7920
version_fixed: 1.12.2
status: resolved

11 years agoProperly handle PKCS11 label in PKINIT
Greg Hudson [Fri, 23 May 2014 02:31:26 +0000 (22:31 -0400)] 
Properly handle PKCS11 label in PKINIT

The CK_TOKEN_INFO label field is defined to be zero-filled, but it may
not be zero-terminated if all bytes of the field are used.  Use only
length-counted operations to process it.  Also avoid underrunning the
buffer pointer if the label is empty or contains only whitespace.

(cherry picked from commit f8b42ef541a463f56720ec9358dd07716b04c5e2)

ticket: 7917
version_fixed: 1.12.2
status: resolved

11 years agoDon't blindly use PKCS11 slot IDs in PKINIT
Greg Hudson [Thu, 22 May 2014 23:18:34 +0000 (19:18 -0400)] 
Don't blindly use PKCS11 slot IDs in PKINIT

Passing invalid slot IDs to C_OpenSession can cause some PKCS #11
implementations (such as the Solaris one) to crash.  If a PKINIT
identity specifies a slotid, use it to filter the result of
C_GetSlotList, but don't try it if it does not appear in the list.

(cherry picked from commit ac406bac3d73a7e4efcc74adbb90c722457da969)

ticket: 7916
version_fixed: 1.12.2
status: resolved

11 years agoFix fencepost error in krad timeout handler
Greg Hudson [Sat, 17 May 2014 14:48:50 +0000 (10:48 -0400)] 
Fix fencepost error in krad timeout handler

(cherry picked from commit f4fce5afd8c4bb5e46aa7041f10118026c5152f0)

ticket: 7911
version_fixed: 1.12.2
status: resolved

11 years agoAdd tests for krb5int_c_combine_keys
Greg Hudson [Tue, 20 May 2014 18:52:44 +0000 (14:52 -0400)] 
Add tests for krb5int_c_combine_keys

krb5int_c_combine_keys is used only by SAM-2 preauth with neither the
send-encrypted-sad nor use-sad-as-key flags, so it isn't covered by
any automated function tests.  Add some unit tests to make sure that
it works and returns the expected results for two randomly generated
test vectors.

(cherry picked from commit 6e8b2fba84df2ef74ce071330b4c3f843f4b7541)

ticket: 7914
version_fixed: 1.12.2
status: resolved

11 years agoFix krb5int_c_combine_keys
Ken Hornstein [Tue, 20 May 2014 18:50:22 +0000 (14:50 -0400)] 
Fix krb5int_c_combine_keys

When krb5int_c_combine_keys was updated to use the new crypto
interface, a small bug was introduced.  It turns out the temporary
keyblock created needs to have its enctype set; otherwise, when
krb5int_derive_keyblock() is called later, it will fail with
KRB5_BAD_ENCTYPE.

(cherry picked from commit 89803a5a781107365d5a4534eebf48dbaf010f96)

ticket: 7914
version_fixed: 1.12.2
status: resolved

11 years agoFix invalid JSON handling in KDC OTP module
Greg Hudson [Sun, 18 May 2014 21:57:25 +0000 (17:57 -0400)] 
Fix invalid JSON handling in KDC OTP module

If the OTP configuration for a principal contains invalid JSON, the
KDC OTP module calls k5_json_get_tid on a null pointer, causing the
KDC process to crash.  Fix this bug by checking the return value of
k5_json_decode in decode_config_json.

(cherry picked from commit dab1c234e15afdc64dfe776bdbc65bbc17d07e12)

ticket: 7912
version_fixed: 1.12.2
status: resolved

11 years agoCheck for asprintf failure in kdb5_util create
Tomas Kuthan [Thu, 10 Apr 2014 13:16:06 +0000 (15:16 +0200)] 
Check for asprintf failure in kdb5_util create

In add_admin_princ, remove build_name_with_realm and call asprintf
directly instead.  Check for asprintf failure to avoid passing an
undefined pointer to krb5_parse_name.

[ghudson@mit.edu: rewrite commit message]

(cherry picked from commit f5645d30cf83398640c386a612eb6f07c543286f)

ticket: 7902
version_fixed: 1.12.2
status: resolved

11 years agoFix leak in kadm5_flush with LDAP KDB
Tomas Kuthan [Wed, 2 Apr 2014 15:48:04 +0000 (17:48 +0200)] 
Fix leak in kadm5_flush with LDAP KDB

Due to an inverted test in adb_policy_init, kadm5_flush calls
krb5_db_open twice.  With the DB2 KDB module, the second open is a
no-op, but with the LDAP module, a new DB handle is allocated and the
old one is leaked.

[ghudson@mit.edu: rewrote commit message]

(cherry picked from commit 372e4cb6f5d4a603e6e3157c7b5d354953836136)

ticket: 7897
version_fixed: 1.12.2
status: resolved

11 years agoGet getopt from unistd.h (not getopt.h) in tests
Greg Hudson [Fri, 28 Mar 2014 16:33:43 +0000 (12:33 -0400)] 
Get getopt from unistd.h (not getopt.h) in tests

POSIX defines getopt to be declared in unistd.h, and HP-UX (as of
version 11.31) does not appear to have getopt.h.  In test programs
which currently include getopt.h and aren't currently built on
Windows, include unistd.h or just assume we will get it via k5-int.h.

(cherry picked from commit 613c62d689c31a325d51be88657dedd17af3cf81)

ticket: 7894
version_fixed: 1.12.2
status: resolved

11 years agoFix GSS krb5 initial sequence number gap handling
Tomas Kuthan [Thu, 6 Mar 2014 12:05:24 +0000 (13:05 +0100)] 
Fix GSS krb5 initial sequence number gap handling

Since #2040, the dummy queue element inserted by g_order_init no
longer compares less than the initial sequence number, so we fail when
the first few sequence numbers are received out of order.  Properly
detect when a sequence number fits between the dummy element and the
first real queue element.

[ghudson@mit.edu: rewrote commit message]

(cherry picked from commit 13a9cb721194c8aa4ccf6ed6ef23e3ac8dd24037)

ticket: 7872
version_fixed: 1.12.2
status: resolved

11 years agoUpdate example kadmin getprinc enctype display
Greg Hudson [Wed, 26 Mar 2014 19:57:08 +0000 (15:57 -0400)] 
Update example kadmin getprinc enctype display

In kadmin_local.rst, update the example to reflect the new way we
display enctypes after #5014.

(cherry picked from commit 3890d1dff87a839efec38a77dcc88574ed65f4a9)

ticket: 7890
version_fixed: 1.12.2
status: resolved

11 years agoFix returning KDB_NOENTRY in find_alternate_tgs()
Nalin Dahyabhai [Thu, 20 Feb 2014 21:01:49 +0000 (16:01 -0500)] 
Fix returning KDB_NOENTRY in find_alternate_tgs()

After searching for a cross-realm TGS entry to provide to a client as a
referral, if we're all set to return a success code but aren't actually
returning an entry, we should be returning an error.  We might not do so
because we don't compare the right value against NULL.

This corrects an error in a redundant check in the patch for
CVE-2013-1417.  The error in the check cannot occur in practice
because the other part of the patch for CVE-2013-1417 prevents it, but
static analyzers can flag the erroneous check.

[tlyu@mit.edu: edit commit message]

(cherry picked from commit 90cbf4eb60d8ec3c083195ba4a050a31ea36be0b)

ticket: 7881
version_fixed: 1.12.2
status: resolved

11 years agoFix unlikely double free in PKINIT client code
Greg Hudson [Thu, 13 Mar 2014 22:34:22 +0000 (18:34 -0400)] 
Fix unlikely double free in PKINIT client code

In pa_pkinit_gen_req, if the cleanup handler is reached with non-zero
retval and non-null out_data, out_data is freed, then dereferenced,
then freed again.  This can only happen if one of the small fixed-size
malloc requests fails after pkinit_as_req_create succeeds, so it is
unlikely to occur in practice.

(cherry picked from commit cc002d6c1ccfc08356d01ba83e72a46855d0302c)

ticket: 7878
version_fixed: 1.12.2
status: resolved

11 years agoDon't leak the per-request preauth context
Nalin Dahyabhai [Tue, 11 Mar 2014 17:33:23 +0000 (13:33 -0400)] 
Don't leak the per-request preauth context

Currently, per-request preauth module data is only cleared when we
successfully obtain initial credentials.  Make sure to clear it at the
end of the operation even if we failed to get creds.

[ghudson@mit.edu: expanded commit message]

(cherry picked from commit a47c4e68308331a630480cb62c2b7711432e0123)

ticket: 7793
version_fixed: 1.12.2
status: resolved

11 years agoMention k5login_authoritative in k5login docs
Ben Kaduk [Thu, 13 Mar 2014 19:11:49 +0000 (15:11 -0400)] 
Mention k5login_authoritative in k5login docs

In particular, it is set by default.  This can lead to confusing
behavior wherein adding a k5login file removes a user's remote
access.

Make an example more concrete to account for this case.

(cherry picked from commit 8cdc21ef051f43ea8dcabf42540d5cff13b5adeb)

ticket: 7876
version_fixed: 1.12.2
status: resolved

11 years agoFix memory leak in krb5_verify_init_creds
Nalin Dahyabhai [Mon, 17 Feb 2014 22:14:20 +0000 (17:14 -0500)] 
Fix memory leak in krb5_verify_init_creds

When copying most of the credentials from one cache to another in
copy_creds_except (called from get_vfy_cred, from
krb5_verify_init_creds), we need to free all of the credentials that
we read, not just the ones we copied.

[ghudson@mit.edu: edited commit message]

(cherry picked from commit 27b136d2e3181e787b2d4a03ee712d5d5137f5cd)

ticket: 7875
version_fixed: 1.12.2
status: resolved

11 years agoInitialize err variable in krb5_sendto_kdc
Nalin Dahyabhai [Tue, 11 Mar 2014 17:26:32 +0000 (13:26 -0400)] 
Initialize err variable in krb5_sendto_kdc

When we get an KRB5_KDC_UNREACH error back from k5_sendto, we check if
the err variable we passed for use by our message handler has been set
to KDC_ERR_SVC_UNAVAILABLE.  If k5_sendto doesn't receive any
response, though, the handler isn't called, so we're reading an
uninitialized variable.  Initialize it to a value other than
KDC_ERR_SVC_UNAVAILABLE to be sure.

[ghudson@mit.edu: initialize err just before calling k5_sendto; edit
commit message]

(cherry picked from commit 1ed3f68c2394fbb48731bba4e4e9a60c8b925ca5)

ticket: 7874
version_fixed: 1.12.2
status: resolved

11 years agoUpdate iprop_master_ulogsize documentation
Greg Hudson [Fri, 7 Mar 2014 15:37:48 +0000 (10:37 -0500)] 
Update iprop_master_ulogsize documentation

When we removed the maximum number of ulog entries (#7368), we did not
update the documentation for that parameter in kdc.conf.  Reported by
Richard Basch.

(cherry picked from commit 5fa7e666bd81a2222b155bdf3f0c3fc1bc3fabf5)

ticket: 7849
version_fixed: 1.12.2
status: resolved