]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
9 years agoFix IAKERB context export/import [CVE-2015-2698]
Greg Hudson [Mon, 2 Nov 2015 03:45:21 +0000 (22:45 -0500)] 
Fix IAKERB context export/import [CVE-2015-2698]

The patches for CVE-2015-2696 contained a regression in the newly
added IAKERB iakerb_gss_export_sec_context() function, which could
cause it to corrupt memory.  Fix the regression by properly
dereferencing the context_handle pointer before casting it.

Also, the patches did not implement an IAKERB gss_import_sec_context()
function, under the erroneous belief that an exported IAKERB context
would be tagged as a krb5 context.  Implement it now to allow IAKERB
contexts to be successfully exported and imported after establishment.

CVE-2015-2698:

In any MIT krb5 release with the patches for CVE-2015-2696 applied, an
application which calls gss_export_sec_context() may experience memory
corruption if the context was established using the IAKERB mechanism.
Historically, some vulnerabilities of this nature can be translated
into remote code execution, though the necessary exploits must be
tailored to the individual application and are usually quite
complicated.

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

(cherry picked from commit 3db8dfec1ef50ddd78d6ba9503185995876a39fd)
(cherry picked from commit 54222de30a89bfac0247dfbc1759556dc9fd2983)

ticket: 8284 (new)
version_fixed: 1.13.3

9 years agoFix two IAKERB comments
Greg Hudson [Tue, 27 Oct 2015 04:44:24 +0000 (00:44 -0400)] 
Fix two IAKERB comments

The comment explaining why there is no iakerb_gss_import_sec_context()
erroneously referenced SPNEGO instead of IAKERB (noticed by Ben
Kaduk).  The comment above iakerb_gss_delete_sec_context() is out of
date after the last commit.

(cherry picked from commit 92d6dd045dfc06cc03d20b327a6ee7a71e6bc24d)
(cherry picked from commit 1be18763f94dc519da9b9928e82566558c8748c2)

9 years agoFix build_principal memory bug [CVE-2015-2697]
Greg Hudson [Fri, 25 Sep 2015 16:51:47 +0000 (12:51 -0400)] 
Fix build_principal memory bug [CVE-2015-2697]

In build_principal_va(), use k5memdup0() instead of strdup() to make a
copy of the realm, to ensure that we allocate the correct number of
bytes and do not read past the end of the input string.  This bug
affects krb5_build_principal(), krb5_build_principal_va(), and
krb5_build_principal_alloc_va().  krb5_build_principal_ext() is not
affected.

CVE-2015-2697:

In MIT krb5 1.7 and later, an authenticated attacker may be able to
cause a KDC to crash using a TGS request with a large realm field
beginning with a null byte.  If the KDC attempts to find a referral to
answer the request, it constructs a principal name for lookup using
krb5_build_principal() with the requested realm.  Due to a bug in this
function, the null byte causes only one byte be allocated for the
realm field of the constructed principal, far less than its length.
Subsequent operations on the lookup principal may cause a read beyond
the end of the mapped memory region, causing the KDC process to crash.

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

(cherry picked from commit f0c094a1b745d91ef2f9a4eae2149aac026a5789)
(cherry picked from commit 67bdf8189b24efca8a244316e7d51bd52d0dbda9)

ticket: 8283 (new)
version_fixed: 1.13.3
status: resolved

9 years agoFix IAKERB context aliasing bugs [CVE-2015-2696]
Nicolas Williams [Mon, 14 Sep 2015 16:28:36 +0000 (12:28 -0400)] 
Fix IAKERB context aliasing bugs [CVE-2015-2696]

The IAKERB mechanism currently replaces its context handle with the
krb5 mechanism handle upon establishment, under the assumption that
most GSS functions are only called after context establishment.  This
assumption is incorrect, and can lead to aliasing violations for some
programs.  Maintain the IAKERB context structure after context
establishment and add new IAKERB entry points to refer to it with that
type.  Add initiate and established flags to the IAKERB context
structure for use in gss_inquire_context() prior to context
establishment.

CVE-2015-2696:

In MIT krb5 1.9 and later, applications which call
gss_inquire_context() on a partially-established IAKERB context can
cause the GSS-API library to read from a pointer using the wrong type,
generally causing a process crash.  Java server applications using the
native JGSS provider are vulnerable to this bug.  A carefully crafted
IAKERB packet might allow the gss_inquire_context() call to succeed
with attacker-determined results, but applications should not make
access control decisions based on gss_inquire_context() results prior
to context establishment.

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

[ghudson@mit.edu: several bugfixes, style changes, and edge-case
behavior changes; commit message and CVE description]

(cherry picked from commit e04f0283516e80d2f93366e0d479d13c9b5c8c2a)
(cherry picked from commit 096cfaa18504d20889a3d8829decb1bf72dd0ac5)

ticket: 8282
version_fixed: 1.13.3

9 years agoFix mechglue gss_acquire_cred_impersonate_name
Simo Sorce [Fri, 13 Nov 2015 19:44:54 +0000 (14:44 -0500)] 
Fix mechglue gss_acquire_cred_impersonate_name

Checking for the generic gss_acquire_cred() function is no guarantee
that gss_acquire_cred_impersonate_name() is also implemented.

[ghudson@mit.edu: edit commit message]

(cherry picked from commit 46a4e225d2ecaa4077aa65f12f64273bf4911d3a)

ticket: 8285 (new)
version_fixed: 1.13.3
status: resolved

9 years agoFix SPNEGO context aliasing bugs [CVE-2015-2695]
Nicolas Williams [Mon, 14 Sep 2015 16:27:52 +0000 (12:27 -0400)] 
Fix SPNEGO context aliasing bugs [CVE-2015-2695]

The SPNEGO mechanism currently replaces its context handle with the
mechanism context handle upon establishment, under the assumption that
most GSS functions are only called after context establishment.  This
assumption is incorrect, and can lead to aliasing violations for some
programs.  Maintain the SPNEGO context structure after context
establishment and refer to it in all GSS methods.  Add initiate and
opened flags to the SPNEGO context structure for use in
gss_inquire_context() prior to context establishment.

CVE-2015-2695:

In MIT krb5 1.5 and later, applications which call
gss_inquire_context() on a partially-established SPNEGO context can
cause the GSS-API library to read from a pointer using the wrong type,
generally causing a process crash.  This bug may go unnoticed, because
the most common SPNEGO authentication scenario establishes the context
after just one call to gss_accept_sec_context().  Java server
applications using the native JGSS provider are vulnerable to this
bug.  A carefully crafted SPNEGO packet might allow the
gss_inquire_context() call to succeed with attacker-determined
results, but applications should not make access control decisions
based on gss_inquire_context() results prior to context establishment.

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

[ghudson@mit.edu: several bugfixes, style changes, and edge-case
behavior changes; commit message and CVE description]

(cherry picked from commit b51b33f2bc5d1497ddf5bd107f791c101695000d)
(cherry picked from commit 31fb730f1ad708f230e4387e02ed2f89b93c3607)

ticket: 8282 (new)
subject: SPNEGO and IAKERB context aliasing bugs [CVE-2015-2695][CVE-2015-2696]
version_fixed: 1.13.3

9 years agoFix krb5_rd_req() memory leak
Nicolas Williams [Tue, 1 Sep 2015 15:58:30 +0000 (11:58 -0400)] 
Fix krb5_rd_req() memory leak

In release 1.13, commit eba8c4909ec7ba0d7054d5d1b1061319e9970cc7
(ticket #7232) introduced a memory leak when skipping keytab entries
which do not match the application-provided server specification.  Fix
it by freeing the keytab entry before continuing the loop on a failure
to match.

[ghudson@mit.edu: commit message]

(cherry picked from commit 3aa8506ee9e1f564e3f396eed5ac5616d7c54b34)

ticket: 8239
version_fixed: 1.13.3
status: resolved

9 years agoFix error handling in gss_export_sec_context()
Nicolas Williams [Tue, 1 Sep 2015 23:42:58 +0000 (19:42 -0400)] 
Fix error handling in gss_export_sec_context()

In the mechglue gss_export_sec_context(), make sure to delete the
union context if the underlying mech context has been deleted.  This
can happen if the mech's gss_export_sec_context() returns a failure
and deletes the context (not a behavior exhibited by any of our
in-tree mechanisms, but an allowed behavior for other mechs), or if we
fail to allocate space for the wrapped token.

[ghudson@mit.edu: commit message; rename exit label to "cleanup" and
make it valid for all exit cases]

(cherry picked from commit 4f35b27a9ee38ca0b557ce8e6d059924a63d4eff)

ticket: 8240
version_fixed: 1.13.3
status: resolved

9 years agoFix KDC client referrals
Greg Hudson [Thu, 3 Sep 2015 16:38:44 +0000 (12:38 -0400)] 
Fix KDC client referrals

Although our built-in KDB modules do not support client referrals for
AS requests, the KDC is supposed to return one if a third-party module
returns a DB entry containing a principal in a foreign realm.
Unfortunately, this code has never worked; in prepare_error_as(), we
erroneously compare the protocol code errcode against the com_err code
KRB5KDC_ERR_WRONG_REALM; as a result, we never supply the canonical
client principal.  Fix this by comparing errcode against the protocol
code KDC_ERR_WRONG_REALM instead.

Discovered by Alexander Bokovoy and Simo Sorce.

(cherry picked from commit 4e036ef4127a9b09d1a567472da1df24c55cdb89)

ticket: 8241
version_fixed: 1.13.3
status: resolved

9 years agoCheck for null name_type in gss_display_name_ext
Solly Ross [Thu, 27 Aug 2015 19:55:35 +0000 (15:55 -0400)] 
Check for null name_type in gss_display_name_ext

It is possible for the input name's name_type to be GSS_C_NO_OID.
g_OID_equal() does not account for GSS_C_NO_OID, so we have to
manually check before use to prevent null pointer dereferences.

(cherry picked from commit 3fdf09ac9a36581b47f40c9d177e463cc12687ff)

ticket: 8238
version_fixed: 1.13.3
status: resolved

9 years agoFix gss_inquire_name() name_is_MN result
Isaac Boukris [Wed, 12 Aug 2015 23:28:36 +0000 (02:28 +0300)] 
Fix gss_inquire_name() name_is_MN result

Currently name_is_MN is left uninitialized for non-mechanism names due
to a typo.

[ghudson@mit.edu: edited commit message]

(cherry picked from commit a3f3f4069858ea795b732ec1d96fae20d5fafe24)

ticket: 8232
version_fixed: 1.13.3
status: resolved

9 years agoDo not allow stream socket retries in libkrad
Nathaniel McCallum [Fri, 7 Aug 2015 19:35:58 +0000 (15:35 -0400)] 
Do not allow stream socket retries in libkrad

Before this patch, libkrad would follow the same exact logic for all
socket types when the retries parameter was non-zero.  This meant that
when connecting with SOCK_STREAM, multiple requests were sent in case
of packet drops, which, of course, cannot happen for SOCK_STREAM.

Instead, just disable retries for SOCK_STREAM sockets.

[ghudson@mit.edu: minor wording edits]

(cherry picked from commit 25e0656fdf9862faf9aa91288023776e9a47caad)

ticket: 8229
version_fixed: 1.13.3
status: resolved

9 years agoFix uncommon leak in krb5_init_creds_step()
Greg Hudson [Sun, 26 Jul 2015 17:21:47 +0000 (13:21 -0400)] 
Fix uncommon leak in krb5_init_creds_step()

Release any previous value of ctx->err_padata before setting it in
init_creds_step_reply().  It could have a prior value after a realm
referral or retriable error.

(cherry picked from commit 997eb174f5fd81747ad0ecb671f00c25951931b1)

ticket: 8223
version_fixed: 1.13.3
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: 8031
version_fixed: 1.13.3
status: resolved

9 years agoFix uncommon null dereference in PKINIT client
Greg Hudson [Fri, 3 Jul 2015 23:34:46 +0000 (19:34 -0400)] 
Fix uncommon null dereference in PKINIT client

crypto_retrieve_cert_sans() is allowed to set its princs output to
NULL, although the OpenSSL implementation rarely does.  Fix the
TRACE_PKINIT_CLIENT_SAN_KDCCERT_PRINC for loop to allow this like other
parts of the function do, and also get rid of the unnecessary princptr
variable by using an integer index like other parts of the function.

Based on a patch from Daniel Deptula.

(cherry picked from commit 47b37b9e13ca1456ba6710f31bc41012d050dd07)

ticket: 8214
version_fixed: 1.13.3
status: resolved

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: 8204
version_fixed: 1.13.3
status: resolved

10 years agoUpdate KfW copyright
Ben Kaduk [Thu, 25 Jun 2015 19:28:29 +0000 (15:28 -0400)] 
Update KfW copyright

This probably should not be a hardcoded string, but we can at
least make it correct for now.

(cherry picked from commit 27e6ab7e5b6a0538f529f440aeb967822eff8f57)

ticket: 8212
version_fixed: 1.13.3
status: resolved

10 years agoBack to krb5-1.3.2-postrelease
Ben Kaduk [Wed, 24 Jun 2015 21:27:54 +0000 (17:27 -0400)] 
Back to krb5-1.3.2-postrelease

10 years agoBump buildlevel for non-MIT KfW 4.1-beta2 kfw-4.1-beta2
Ben Kaduk [Wed, 24 Jun 2015 21:24:33 +0000 (17:24 -0400)] 
Bump buildlevel for non-MIT KfW 4.1-beta2

10 years agoReady for KfW 4.1 beta 2
Ben Kaduk [Wed, 24 Jun 2015 21:24:10 +0000 (17:24 -0400)] 
Ready for KfW 4.1 beta 2

Bump versions as needed.

10 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: 8201
version_fixed: 1.13.3
status: resolved

10 years agoFix bindresvport_sa port byte swap bug
Greg Hudson [Tue, 19 May 2015 14:38:51 +0000 (10:38 -0400)] 
Fix bindresvport_sa port byte swap bug

The sa_setport() helper handles conversion to network byte order, so
bindresvport_sa() should not itself call htons() on the port argument.

(This bug was introduced in commit
0d04b60d159ab83b943e43802b1449a3b074bc83 when adding
bindresvport_sa().  It was my fault, not Andreas Schneider's.)

(cherry picked from commit 5c6d218e385755766ff427b3e707510f0ce175c5)

ticket: 8197
version_fixed: 1.13.3
status: resolved

10 years agoMake the Principal column wider by default
Ben Kaduk [Wed, 24 Jun 2015 17:34:32 +0000 (13:34 -0400)] 
Make the Principal column wider by default

The current 100-pixel default is too small to fit most principal
names (particularly the realm).  There is no reason why all the
columns must be the same width, so promote this one as needing
more space.

(cherry picked from commit d376d5948d2af7dcf60368bc3b6fe6c23172a831)

ticket: 8211
version_fixed: 1.13.3
status: resolved

10 years agoMake registry hostrealm module highest precedence
Ben Kaduk [Tue, 23 Jun 2015 14:38:19 +0000 (10:38 -0400)] 
Make registry hostrealm module highest precedence

Testing reveals that there are a number of machines in the wild
which retain old krb5.ini files across domain configuration changes,
and it is difficult to determine which machines are potentially
affected by incorrect stale configuration data.

To enable domain administrators to easily ensure that the correct
default realm is set, allow the registry hostrealm module to take
precedence over the profile.

Note that the registry hostrealm module can still be disabled
in the hostrealm interface configuration statment in the
[plugins] section of the profile.

(cherry picked from commit 287b8eae295a3ab496b04b327840e92c235efd1a)

ticket: 8209
version_fixed: 1.13.3
status: resolved

10 years agoStop using the WiX src attribute
Ben Kaduk [Fri, 29 May 2015 18:46:58 +0000 (14:46 -0400)] 
Stop using the WiX src attribute

The src attribute has been deprecated for a while in favor of
different (more descriptive) attributes for the different XML
elements involved.

For the File element, use the Source attribute.
For the Directory element, use the FileSource attribute.
For the Merge, Binary, and Text elements, use the SourceFile attribute.

This makes the installer build much quieter, with the warnings from
the light.exe invocation all fitting into the default history buffer.

(cherry picked from commit 0e025dd9bd64169a2acf5c9bea7a17eec7b37a13)

ticket: 8208
version_fixed: 1.13.3
status: resolved

10 years agoStop using the WiX Registry element
Ben Kaduk [Wed, 27 May 2015 19:36:51 +0000 (15:36 -0400)] 
Stop using the WiX Registry element

It is deprecated in favor of more specific XML elements such
as RegistryKey, RegistryValue, and RemoveRegistryKey, so as to
stop overloading a single element for what are fundamentally
different types and operations.

RegistryValue elements can be children of RegistryKey elements,
allowing the Key attribute to be inherited, or bare within the
containing Component.  We do not take advantage of the inheritance
at this time, since that would be a more disruptive change.

WiX would prefer for us to not use the createAndRemoveOnUninstall
attribute of <RegistryKey>, in favor of ForceCreateOnInstall
and/or ForceRemoveOnUninstall, but that can wait for a follow-up
commit.

Some instances of <Registry> were commented-out and can simply be
removed.

Some of the <Registry> elements used to create keys were also
setting the KeyPath attribute, which is not permitted in the
<RegistryKey> element.  According to
http://sourceforge.net/p/wix/bugs/3197/ , this should never have
been allowed, and non-value registry keys should not be used as
MSI KeyPaths.  In all affected cases, there are child
RegistryValue elements that are suitable for use as KeyPath
elements instead.

Some of the <Registry> elements were present with a duplicate
element with different Id that added no new attributes; those
duplicate elements can safely be removed.

<RemoveRegistryKey> is used to replace <Registry> elements
with Action=removeKeyOnInstall.

(cherry picked from commit 280a4b1125743bae3bf05af266131e2a524c8adf)

ticket: 7392
version_fixed: 1.13.3
status: resolved

10 years agoPut focus on password field when principal is set
Ben Kaduk [Mon, 22 Jun 2015 23:11:28 +0000 (19:11 -0400)] 
Put focus on password field when principal is set

In the Leash "Get Ticket" window, under some user-customized
configurations, the principal field can be pre-populated.  In this case,
it makes sense for the default focus to be on the password field,
since most users will only be using a single principal and should
go directly to typing their password.

The focus was already set to the password field in the case when
the principal was not modifiable (such as when the "Get Ticket" dialog
was opened by an application requesting a specific ticket).

(cherry picked from commit 50b3bba748084c99a339bd526ad47ecfccc09472)

ticket: 8032
version_fixed: 1.13.3
status: resolved

10 years agoAdd leash column for the ccache name
Ben Kaduk [Fri, 22 May 2015 18:38:27 +0000 (14:38 -0400)] 
Add leash column for the ccache name

Previously, it was fairly easy to set the default cache to MSLSA:,
which is not collection-enabled (as opposed to the normal default
of API:, which is), and the non-collection behavior proved confusing
to many users.

Ideally there would be an option to choose the output ccache in
the "Get Ticket" window, but that is more complicated to implement
than just a display of what cache a given ticket is in.  This
extra display column should still help to alleviate user confusion.

(cherry picked from commit b26d25e97cf3c53ef896092c71948011ceac645d)

ticket: 8207
version_fixed: 1.13.3
status: resolved

10 years agoMake ribbon home tab more pretty
Ben Kaduk [Fri, 22 May 2015 18:42:02 +0000 (14:42 -0400)] 
Make ribbon home tab more pretty

In the absence of a label title for a given command group, the
text "MS Shell Dlg" was inserted, which is somewhat confusing to
the user.  Give the ticket-maniuplation group a title consisting
of a space, which removes the confusing text from the display.

(cherry picked from commit bfba2d235370a3902faeeaad8a54d8a2dcc3427b)

ticket: 8206
version_fixed: 1.13.3
status: resolved

10 years agoCorrect CSAIL KDC names
Ben Kaduk [Fri, 15 May 2015 16:09:35 +0000 (12:09 -0400)] 
Correct CSAIL KDC names

CSAIL and ATHENA are served from different KDCs.

(cherry picked from commit 1b07396924dc4c222ddb6adec415cb53827dbe25)

ticket: 8196
version_fixed: 1.13.3
status: resolved

10 years agoBack to krb5-1.13.2-postrelease
Tom Yu [Fri, 15 May 2015 19:54:26 +0000 (15:54 -0400)] 
Back to krb5-1.13.2-postrelease

10 years agoBump buildlevel for non-MIT KfW 4.1-beta1 kfw-4.1-beta1
Ben Kaduk [Tue, 12 May 2015 15:22:27 +0000 (11:22 -0400)] 
Bump buildlevel for non-MIT KfW 4.1-beta1

10 years agoReady for KfW 4.1 beta 1
Ben Kaduk [Tue, 5 May 2015 21:31:26 +0000 (17:31 -0400)] 
Ready for KfW 4.1 beta 1

Bump versions as needed.

10 years agoReboot after KfW installs to help the LSA cache
Ben Kaduk [Mon, 11 May 2015 17:08:42 +0000 (13:08 -0400)] 
Reboot after KfW installs to help the LSA cache

It seems that we need to restart in order to be able to query the
contents of the the LSA cache, even if the only contents of the LSA
cache are what we put there, and even if the Microsoft klist.exe
correctly reports the presence of tickets in the LSA cache.

(cherry picked from commit 50a3c3cbeab32577fba2b21deb72a64015c48ec7)

ticket: 8176
version_fixed: 1.13.3
status: resolved

10 years agoBump KRB5_MINOR_RELEASE for windows
Ben Kaduk [Tue, 5 May 2015 21:08:04 +0000 (17:08 -0400)] 
Bump KRB5_MINOR_RELEASE for windows

Future releases will come from the KfW 4.1.x. series.

(cherry picked from commit 770196087b12affc08591aa0ff7fa78658f467ab)

ticket: 8174
version_fixed: 1.13.3
status: resolved

10 years agoSupply a hostrealm module to query the registry
Ben Kaduk [Tue, 5 May 2015 20:55:41 +0000 (16:55 -0400)] 
Supply a hostrealm module to query the registry

Implement a default_realm function that checks the
{HKLM,HKCU}\Software\MIT\Kerberos5\default_realm registry values
on Windows, and just returns KRB5_PLUGIN_NO_HANDLE on Unix.

(cherry picked from commit 90ca670ac42a9aada3c310af491bbf8b924e6a00)

ticket: 8173
version_fixed: 1.13.3
status: resolved

10 years agoDo not set allow_weak_crypto for KfW
Ben Kaduk [Wed, 11 Mar 2015 20:38:10 +0000 (16:38 -0400)] 
Do not set allow_weak_crypto for KfW

The MIT-internal users no longer need this crutch.

(cherry picked from commit f0cd1a65e379dd21cdb565beed9e2d8917d1a701)

ticket: 8178
version_fixed: 1.13.3
status: resolved

10 years agoFix loop to determine MSLSA principal name
Ben Kaduk [Fri, 6 Mar 2015 20:42:10 +0000 (15:42 -0500)] 
Fix loop to determine MSLSA principal name

When looping over principals, check the i-th entry instead of
looking at the 0-th entry each time through the loop.  This would
only affect cases when multiple ticket entries were returned from
the LSA, the first one did not have a valid principal name, but
some other one did.  It is expected that all of the returned
ticket entries will always have a valid client principal name, so
this is unlikely to cause any functional difference.

(cherry picked from commit d7dc6c347e352324e374b3456f60e49aa4b8ba08)

ticket: 8177
version_fixed: 1.13.3
status: resolved

10 years agoKfW shortcuts for make default, change password
Ben Kaduk [Wed, 5 Dec 2012 17:15:07 +0000 (12:15 -0500)] 
KfW shortcuts for make default, change password

Shortcut keys such as these (in the ACCELERATORS entry in the resource
file) are what let users type, e.g., ctrl-t to get to the "get tickets"
dialog directly from the main frame.  We had shortcut keys for all the
other buttons already, so add these to complete the set.

The make default and change password functionality were already available
using keyboard-only interfaces via the ribbon access keys (tap alt,
then letters to walk through the tree of controls), but the two forms
of keyboard access are implemented differently.

(cherry picked from commit 3321375cf3830a4702fdea3781a07f9dde059edc)

ticket: 7442
version_fixed: 1.13.3
status: resolved

10 years agoRemove (old) consolidated ribbon bitmaps
Ben Kaduk [Thu, 16 Apr 2015 22:32:34 +0000 (18:32 -0400)] 
Remove (old) consolidated ribbon bitmaps

We are no longer using the MFC ribbon, so these resources
are now unused.  Garbage-collect them accordingly.

(cherry picked from commit 0fdbfb1891713b8ff91acba37dfb17b937929a71)

ticket: 8192
version_fixed: 1.13.3
status: resolved

10 years agoRemove another lingering Leash reference
Ben Kaduk [Thu, 16 Apr 2015 22:23:13 +0000 (18:23 -0400)] 
Remove another lingering Leash reference

Be consistent with the MIT Kerberos brand.

(cherry picked from commit 58122fec56a87ca7f88052f6b55f90b94ce1c386)

ticket: 8191
version_fixed: 1.13.3
status: resolved

10 years agoSwitch to Windows SDK Ribbon from MFC Ribbon
Ben Kaduk [Fri, 10 Apr 2015 21:33:40 +0000 (17:33 -0400)] 
Switch to Windows SDK Ribbon from MFC Ribbon

The MFC Ribbon implementation is not very accessible (e.g., to
screen reading software), whereas the windows ribbon provides
essentially the same functionality and good integration with
screen reading software, including the built-in Windows Narrator.

Remove the RT_RIBBON_XML resource from the resource file and
replace it with an inclusion of the generated kfwribbon.rc file.
Also remove the ribbon1.mfcribbon-ms ribbon description from the
res/ directory.  Add the appropriate dependency relation in the
Makefile.

LeashUIApplication implements the IUIUApplication interfaces.  It
appears to be difficult to cleanly tear down the underlying
IUIFramework and ribbon, since the WM_DESTROY event is handled by the
parent MFC window, which will not call IUIFramework::Destroy().
Manually inserting a call to IUIFramework::Destroy() in the shutdown
handling of the MFC classes is difficult, since the WM_DESTROY message
is handled by a different window than where the ribbon is initialized,
and the MFC framework will attempt to access window objects
corresponding to the UI Ribbon resources after they are destroyed,
which raises exceptions.  It seems best to just go without destroying
the IUIFramework, since its lifecycle matches that of the application
and there will be no leaks during the application lifecycle.

LeashUICommandHandler implements the IUICommandHandler interfaces,
passing messages through to the existing MFC handlers, though the
default values for the various checkbox controls must be duplicated.

The (MFC) CMainFrame creates and maintains a handle to the
LeashUIApplication associated with the ribbon it creates, so that
it can query the height of the ribbon and redraw when the
LeashUIApplication signals that the ribbon size has changed.

Record that the added object files depend on kfwribbon.h, so that
the XML markup is compiled sufficiently early in the build.

(cherry picked from commit fa5edf1e72b142f14d36b7eb304f55066c5af2f9)

ticket: 8192
version_fixed: 1.13.3

10 years agoMention Visual Studio 2010 SP1 in windows README
Ben Kaduk [Thu, 19 Mar 2015 18:14:02 +0000 (14:14 -0400)] 
Mention Visual Studio 2010 SP1 in windows README

The service pack is needed to avoid a linker error due to an
issue with the cvtres.exe utility, which manifests as
LINK: fatal error LNK1123: failure during conversion to COFF: file
invalid or corrupt.

(cherry picked from commit 025008dd215c20f804823dafa3bd9f45135be53e)

ticket: 8192
version_fixed: 1.13.3

10 years agoDo not link atl.lib into leash
Benjamin Kaduk [Wed, 22 Jan 2014 05:30:21 +0000 (00:30 -0500)] 
Do not link atl.lib into leash

We do not consume anything from the Active Template Library, and
the atl.lib form of it has been removed from Visual Studio 2013.

(cherry picked from commit 8cbe19a290f00de53da284588adc84aabf64092e)

ticket: 8190
version_fixed: 1.13.3
status: resolved

10 years agoXML Ribbon markup file
Benjamin Kaduk [Fri, 17 Jan 2014 21:02:13 +0000 (16:02 -0500)] 
XML Ribbon markup file

The standard windows library ribbon interface is either constructed
at runtime or specified in an XML file.  Since we have a static
set of functionality in our ribbon, it is simplest to just use the
XML file.

This should duplicate the interfaces currently provided by the
MFC ribbon, though the menu items in the file menu are slightly
taller than they used to be.

Use uicc.exe to compile the XML to the binary format and produce
a kfwribon.rc resource file and kfwribbon.h header.

(cherry picked from commit da60312f1352cbd82e39e31398f7ead2e817f119)

ticket: 8192
version_fixed: 1.13.3

10 years agoImport separate large ribbon bitmaps
Benjamin Kaduk [Mon, 27 Jan 2014 18:07:38 +0000 (13:07 -0500)] 
Import separate large ribbon bitmaps

This is the content from homelarge.bmp split up into the
separate component images, since the windows ribbon has the
(more sane) interface of using a separate resource for each
graphic, instead of expecting them all in a single bitmap which
is sliced up at runtime.

The bitmaps are required to have alpha channels, and it seems that
the easiest way to generate bitmaps with alpha channels is to use
Microsoft Paint, since the normal Unix open-source graphics tools
do not want to output this format.

(cherry picked from commit 8f89dc561c1e8464c423bde854b6fd4283497559)

ticket: 8192
version_fixed: 1.13.3

10 years agoRemove MBCS from leash's DEFINES
Benjamin Kaduk [Wed, 22 Jan 2014 05:05:57 +0000 (00:05 -0500)] 
Remove MBCS from leash's DEFINES

This is just enabling the use of multi-byte character set in the
MFC library, but we do not appear to make use of this feature.
Visual Studio 2013 gives ominous warnings that support for it may
be removed in future versions, so quiet the build and do not
enable the deprecated feature we are not using.

(cherry picked from commit 5d50bc2a62739e39ea0b90b0ced3b7489ba554b3)

ticket: 8190
version_fixed: 1.13.3

10 years agoFix leash crash found in some build environments
Ben Kaduk [Tue, 14 Apr 2015 19:33:20 +0000 (15:33 -0400)] 
Fix leash crash found in some build environments

When freeing a credentials cache name obtained from
krb5_cc_get_full_name(), the code was using plain free()
instead of the matching krb5_free_string().  If these routines
are picked from different modules at runtime, the mismatch
will cause a crash in free(), so change to using the matched
deallocation function.

In order to use it in leash, it must be declared in Lglobals.h and
the function pointer symbol defined in Leash.cpp.

(cherry picked from commit ebeb1e359fa10ea710d467ca3756ababd1276fa6)

ticket: 8189
version_fixed: 1.13.3
status: resolved

10 years agoAvoid unneeded GetMSTGT() calls in cc_mslsa.c
Ben Kaduk [Thu, 14 Aug 2014 17:57:48 +0000 (13:57 -0400)] 
Avoid unneeded GetMSTGT() calls in cc_mslsa.c

Both lcc_resolve() and lcc_get_principal() were using GetMSTGT()
to fetch a ticket from which to obtain the client principal name
of the credentials cache.  However, that name is contained in
the results of the the cache information query; there is no need
to retrieve a full ticket of any sort to get it.  Since there
may sometimes be difficulties obtaining a TGT when UAC is enabled,
avoid these unneeded calls.

(cherry picked from commit 76a16d2652da483dd7bc95f24257e0f195b833f0)

ticket: 7989
version_fixed: 1.13.3
status: resolved

10 years agoMove realm conversion into helper in cc_mslsa.c
Ben Kaduk [Thu, 14 Aug 2014 17:51:22 +0000 (13:51 -0400)] 
Move realm conversion into helper in cc_mslsa.c

All the callers of UnicodeStringToMITPrinc() were already converting
a UnicodeString into a wchar* just to pass it in as the realm.

Simplify everyone's life by making the helper do the conversion.

(cherry picked from commit e2d1a3aea7789b6acc5fa963da75ea666614764c)

ticket: 7989
version_fixed: 1.13.3

10 years agoRename cc_mslsa.c routines to avoid OS versions
Ben Kaduk [Wed, 13 Aug 2014 21:48:08 +0000 (17:48 -0400)] 
Rename cc_mslsa.c routines to avoid OS versions

We don't care about XP versus non-XP; just indicate which
revision of the data type is being used.

Standardize on the lowercase 'x' in "Ex", for both the "Ex" and
"Ex2" forms.

While here, adjust the function definition prototypes to match
current style.

(cherry picked from commit bbf946566b32dcf2f9a718b28acd948eeb53ade4)

ticket: 7989
version_fixed: 1.13.3

10 years agoRemove unused code from cc_mslsa.c
Ben Kaduk [Wed, 13 Aug 2014 20:28:57 +0000 (16:28 -0400)] 
Remove unused code from cc_mslsa.c

Remove PreserveInitialTicketIdentity() and IsKerberosLogon(), as well
as the preprocessor conditionals ENABLE_PURGING and PURGE_ALL, which
have not been used in a very long time, if ever.

There was one potential callsite of IsKerberosLogon(), in
lcc_resolve(), which was disabled.  It is perfectly reasonable to want
to use the MSLSA cache on a non-domain-joined workstation, as it is
now a read-write cache type, so we need not concern ourselves whether
the logon was performed or may have been performed using kerberos.

(cherry picked from commit 07aaaee56bf40bfef2847b6f09897ce1aa96773d)

ticket: 7989
version_fixed: 1.13.3

10 years agocomment some future cleanup for cc_mslsa.c
Ben Kaduk [Wed, 13 Aug 2014 20:31:49 +0000 (16:31 -0400)] 
comment some future cleanup for cc_mslsa.c

The function does_query_ticket_cache_ex2() will not be needed once
Windows Server 2003 drops out of support in approximately one year's
time.  Note the doom timer at its definition, to facilitate future
cleanup.

(cherry picked from commit 9d16f24e59e2a0f0809741236344394da49935e2)

ticket: 7989
version_fixed: 1.13.3

10 years agoRemove old Windows support from cc_mslsa.c
Ben Kaduk [Wed, 13 Aug 2014 16:54:37 +0000 (12:54 -0400)] 
Remove old Windows support from cc_mslsa.c

It is safe to remove is_windows_2000(), is_windows_xp(), and
is_windows_vista(), since the former two only check for very old
versions of windows which are no longer supported, and
is_windows_vista() was unused.  Note that the check being implemented
was whether the running OS was the named version or higher, not an
exact match.  The current Microsoft documentation recommends against
the sort of OS version checks that were employed here, in favor of
explicit feature tests.

Remove is_broken_wow64() as the problem it works around (Microsoft
Article ID 960077) is believed to have been fixed in subsequent
updates to Windows Server 2003 and XP.

Remove does_retrieve_ticket_cache_ticket() since support for the
KERB_RETRIEVE_TICKET_CACHE_TICKET flag in the
KERB_RETRIEVE_TKT_REQUEST structure was added in service packs for
Windows Server 2003 and XP.  Also remove buildtime fallbacks that
are no longer needed.

Remove the conditionals TRUST_ATTRIBUTE_TRUST_USES_AES_KEYS,
HAVE_CACHE_INFO_EX2, and KERB_SUBMIT_TICKET as all current SDK
versions have the relevant functionality.

In all cases, de-indent chunks that are no longer conditional.
Where indentation levels changed, update the style of the reindented
code to current practices.

(cherry picked from commit 471b8474de8c5dfbbcc6a5a39201426bdca09f0d)

ticket: 7989
version_fixed: 1.13.3

10 years agoUpdate for krb5-1.13.2-postrelease
Tom Yu [Fri, 8 May 2015 23:48:48 +0000 (19:48 -0400)] 
Update for krb5-1.13.2-postrelease

10 years agoUpdates for krb5-1.13.2 krb5-1.13.2-final
Tom Yu [Wed, 6 May 2015 18:37:45 +0000 (14:37 -0400)] 
Updates for krb5-1.13.2

10 years agomake update-po
Tom Yu [Wed, 6 May 2015 18:57:21 +0000 (14:57 -0400)] 
make update-po

10 years agoUpdate manpages
Tom Yu [Wed, 6 May 2015 18:51:14 +0000 (14:51 -0400)] 
Update manpages

10 years agomake depend
Tom Yu [Wed, 6 May 2015 18:29:14 +0000 (14:29 -0400)] 
make depend

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)

ticket: 8170
version_fixed: 1.13.2
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)

ticket: 8160
version_fixed: 1.13.2
status: resolved

10 years agoFix memory leak in DB2 iteration
Pavel Jindra [Wed, 15 Apr 2015 15:49:53 +0000 (11:49 -0400)] 
Fix memory leak in DB2 iteration

Use the correct function to free the decoded principal entry in
curs_run_cb().

[ghudson@mit.edu: commit message]

(cherry picked from commit 527edfaadb648a0dd2a42cd39a5a02a4ac37d7e3)

ticket: 8168
version_fixed: 1.13.2
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)

ticket: 8166
version_fixed: 1.13.2
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)

ticket: 8162
version_fixed: 1.13.2
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)

ticket: 8155
version_fixed: 1.13.2
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)

ticket: 8155
version_fixed: 1.13.2
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)

ticket: 8154
version_fixed: 1.13.2
status: resolved

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)

ticket: 8153
version_fixed: 1.13.2
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)

ticket: 8149
version_fixed: 1.13.2
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)

ticket: 8050
version_fixed: 1.13.2
status: resolved

10 years agoUpdate for krb5-1.13.1-postrelease
Tom Yu [Thu, 12 Feb 2015 03:54:37 +0000 (22:54 -0500)] 
Update for krb5-1.13.1-postrelease

10 years agoUpdates for krb5-1.13.1 krb5-1.13.1-final
Tom Yu [Wed, 11 Feb 2015 18:32:31 +0000 (13:32 -0500)] 
Updates for krb5-1.13.1

10 years agoUpdate manpages
Tom Yu [Tue, 10 Feb 2015 20:28:04 +0000 (15:28 -0500)] 
Update manpages

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

10 years agoAvoid uninitialized data in t_prf.c
Tom Yu [Wed, 4 Feb 2015 22:01:14 +0000 (17:01 -0500)] 
Avoid uninitialized data in t_prf.c

In t_prf.c, make sure that the partially initialized, faked-up
structures gss_union_ctx_id_desc and krb5_gss_ctx_id_rec are zeroed.
This avoids uninitialized reads in gss_pseudo_random(), which can
cause intermittent test failures on some platforms.

(cherry picked from commit b5143bdc766ad4819355ac2cd52f685ec5dafa16)

ticket: 8072
version_fixed: 1.13.1
status: resolved

10 years agoBump DAL major version for iterate change
Greg Hudson [Wed, 4 Feb 2015 18:03:20 +0000 (13:03 -0500)] 
Bump DAL major version for iterate change

Commit ab009b8568d9b64b7e992ecdb98114e895b4a7ff for issue #7977
changed the signature of krb5_db_iterate() and properly bumped
KRB5_KDB_API_VERSION from 7 to 8.  It also changed the signature of
the DAL iterate() function, but did not bump
KRB5_KDB_DAL_MAJOR_VERSION.  Bump that version from 4 to 5 now.

(cherry picked from commit 58f6636ba3af96f7b94ba6d4b2c91b61fc85e58a)

ticket: 8066
version_fixed: 1.13.1
status: resolved

10 years agoAdd test program for gss_process_context_token
Greg Hudson [Wed, 5 Nov 2014 16:58:52 +0000 (11:58 -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.

(cherry picked from commit bfb472ff67c00da2f2b0d0ada1af57a2c4493a11)

ticket: 8055
version_fixed: 1.13.1
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: 8058
version_fixed: 1.13.1
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: 8057
version_fixed: 1.13.1
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: 8056
version_fixed: 1.13.1
status: resolved

10 years agoFix gss_process_context_token() [CVE-2014-5352]
Greg Hudson [Wed, 5 Nov 2014 16:58:04 +0000 (11:58 -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.

(cherry picked from commit 82dc33da50338ac84c7b4102dc6513d897d0506a)

ticket: 8055
version_fixed: 1.13.1
status: resolved

10 years agoUpdate copyright years
Tom Yu [Tue, 3 Feb 2015 19:25:09 +0000 (14:25 -0500)] 
Update copyright years

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: 8060
version_fixed: 1.13.1
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: 8060
version_fixed: 1.13.1

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: 8061
version_fixed: 1.13.1
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: 8059
version_fixed: 1.13.1
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: 8053
version_fixed: 1.13.1
status: resolved

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: 8041
version_fixed: 1.13.1
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: 8051
version_fixed: 1.13.1
status: resolved

10 years agoFix LDAP tests when sasl.h not found
Greg Hudson [Mon, 8 Dec 2014 20:30:25 +0000 (15:30 -0500)] 
Fix LDAP tests when sasl.h not found

Do not try to run the SASL EXTERNAL auth test if we could not define a
useful interact function.  With current libraries the interact
function is asked for an authorization name, and the bind fails if it
gets an unsuccessful result or if no interaction function is defined.

(cherry picked from commit 8466003864b294cdb9e5547c2f8e574d2c156b13)

ticket: 8049
version_fixed: 1.13.1
status: resolved

10 years agoAvoid infinite loop on duplicate keysalts
Ben Kaduk [Thu, 20 Nov 2014 20:44:04 +0000 (15:44 -0500)] 
Avoid infinite loop on duplicate keysalts

When duplicate suppression was requested, we would enter an
infinite loop upon encountering a duplicate entry, a bug
introduced in commit 0918990bf1d8560d74473fc0e41d08d433da1a15
and thus present in release 1.13.

Rework the conditional to avoid the loop, at the expense of
additional indentation for some of the code.

(cherry picked from commit c828e7cb137de3559f026dcc552a52162d9ca5cd)

ticket: 8038
version_fixed: 1.13.1
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: 8035
version_fixed: 1.13.1
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: 8034
version_fixed: 1.13.1
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: 8011
version_fixed: 1.13.1
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: 8029
version_fixed: 1.13.1
status: resolved

10 years agoAdd test for kinit output ccache error
Tom Yu [Tue, 16 Dec 2014 17:38:47 +0000 (12:38 -0500)] 
Add test for kinit output ccache error

(back ported from commit e47d8204843ce87fcc1342c7970dded8536fcbde)

ticket: 8028
version_fixed: 1.13.1
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: 8028
version_fixed: 1.13.1
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: 7962
version_fixed: 1.13.1
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: 7880
version_fixed: 1.13.1
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: 8024
version_fixed: 1.13.1
status: resolved