NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/61084: kinit: krb5_init_context failed: 6



>Number:         61084
>Category:       lib
>Synopsis:       kinit: krb5_init_context failed: 6
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 27 21:10:01 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, ...
>Organization:
The NetBSD Kerberotion, Inc.
>Environment:
>Description:

	With no /etc/krb5.conf or ~/.krb5/config (or KRB5_CONFIG
	pointing at a nonempty config file):

	$ kinit riastradh%NETBSD.ORG@localhost
	kinit: krb5_init_context failed: 6

	This makes it troublesome to just use krb5 for client-side
	single-sign-on out of the box on systems that aren't kerberized
	themselves, e.g. NetBSD developers using their personal laptops
	for access to the NETBSD.ORG realm.

	We put this in a long time ago as a local patch in NetBSD,
	presumably to avoid annoying login delays out of the box
	arising from trying krb5 DNS autoconfiguration -- which is
	neither sensible nor safe to try by default:

> revision 1.2
> date: 2000-07-16 18:27:53 +0000;  author: thorpej;  state: Exp;  lines: +5 -2;
> Return failure if there is no Kerberos 5 configuration file.

	https://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/dist/heimdal/lib/krb5/Attic/context.c#rev1.2

> revision 1.2
> date: 2011-04-14 18:02:07 +0000;  author: elric;  state: Exp;  lines: +2 -2;
> branches:  1.2.4;  1.2.6;  1.2.10;  1.2.12;  1.2.20;
> Turn on the hack which disables Kerberos if there is no /etc/krb5.conf.
> We should review this logic and come up with a better way to do this as
> now that there are DNS SRV RRs for locating KDCs, the lack of a config
> does not imply that Kerberos should be turned off.

	https://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/external/bsd/heimdal/dist/lib/krb5/context.c#rev1.2

	The change made login(1) and su(1) use the existence of a
	nonempty /etc/krb5.conf as an indicator for whether to verify a
	password by acquiring a krb5 ticket with it: no /etc/krb5.conf,
	no krb5 paths in login(1) or su(1).

	This is a bad system for several reasons:

	1. A krb5.conf is not enough to make this secure.  Without a
	   keytab, the verification process used by login(1) and su(1)
	   is vulnerable to a MITM on the network spoofing the KDC.  So
	   simply creating a stub /etc/krb5.conf file has the effect of
	   making the system configuration more vulnerable, and not
	   creating it makes the system less usable.

	   Instead, the Kerberos paths of login(1) and su(1) should
	   check for a keytab first and require having a keytab to
	   verify the tickets, like pam_krb5(8) does:

	   https://mail-index.netbsd.org/source-changes/2023/06/20/msg145461.html

	2. The default builds all use MKKERBEROS=yes MKPAM=yes, under
	   which settings the relevant paths in login(1) and su(1)
	   aren't even built -- they are only built if MKKERBEROS=yes
	   MKPAM=no (which, frankly, I expect is an extremely obscure
	   configuration!).  In the default builds, we already have
	   pam_krb5(8) and pam_ksu(8) disabled by default for other
	   reasons:

	   https://mail-index.netbsd.org/source-changes/2023/06/20/msg145459.html
	   https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2023-005.txt.asc
	   https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2023-006.txt.asc

	3. This obscure `krb5_init_context failed: 6' error message
	   makes people think krb5 is weird and hard to use and
	   configure, that aspect of it is a purely self-inflicted
	   mistake in NetBSD.

	See also:

	PR bin/57470: su hangs on network access via pam_ksu even if it
	will never succeed
	https://gnats.NetBSD.org/57470

>How-To-Repeat:

	Try to use krb5 purely for client-side SSO:

	$ kinit jrandomdev%NETBSD.ORG@localhost
	kinit: krb5_init_context failed: 6

>Fix:

	1. Fix the login(1) and su(1) paths under MKKERBEROS=yes so
	   that they require a keytab like pam_krb5(8) and pam_ksu(8)
	   do.

	   (In principle this could break the configurations either
	   with a local KDC or by operators who don't care about
	   vulnerability to a MITM spoofing the KDC.  But that seems
	   unlikely and such configurations can use pam with the
	   allow_kdc_spoof option, which is better for usability too
	   because it gets a ticket in addition to verifying a
	   password.)

	2. Verify there are no other users of krb5_verify_user* or
	   krb5_get_init_creds_password that could be affected by this;
	   make sure they all require a keytab and verify the ticket
	   with it.

	3. Change krb5_init_context to not fail with ENXIO when there's
	   no config.  I.e., put the #if 1 back to #if 0 in the
	   one-line changes quoted above:

--- src/crypto/external/bsd/heimdal/dist/lib/krb5/context.c:1.1	Wed Apr 13 18:15:32 2011
+++ src/crypto/external/bsd/heimdal/dist/lib/krb5/context.c	Thu Apr 14 18:02:07 2011
@@ -612,7 +612,7 @@ krb5_set_config_files(krb5_context conte
 	}
 	filenames++;
     }
-#if 0
+#if 1
     /* with this enabled and if there are no config files, Kerberos is
        considererd disabled */
     if(tmp == NULL)




Home | Main Index | Thread Index | Old Index