SecurityTracker.com
Keep Track of the Latest Vulnerabilities
with SecurityTracker!
    Home    |    View Topics    |    Search    |    Contact Us    |   

SecurityTracker
Archives


 
Sign Up
Sign Up for Your FREE Weekly SecurityTracker E-mail Alert Summary
Instant Alerts
Buy our Premium Vulnerability Notification Service to receive customized, instant alerts
Affiliates
Put SecurityTracker Vulnerability Alerts on Your Web Site -- It's Free!
Partners
Become a Partner and License Our Database or Notification Service
Report a Bug
Report a vulnerability that you have found to SecurityTracker
bugs
@
securitytracker.com






Category:   Application (Security)  >   Kerberos Vendors:   MIT
Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access
SecurityTracker Alert ID:  1010356
SecurityTracker URL:  http://securitytracker.com/id/1010356
CVE Reference:   CAN-2004-0523   (Links to External Site)
Updated:  Jun 4 2004
Original Entry Date:  Jun 1 2004
Impact:   Execution of arbitrary code via network, Root access via network
Fix Available:  Yes  Vendor Confirmed:  Yes  
Version(s): 5-1.3.3 and prior versions
Description:   Some buffer overflow vulnerabilities were reported in Kerberos 5 in the krb5_aname_to_localname() function. A remote user may be able to gain root access on the target system.

MIT reported that there are several overflows in the krb5_aname_to_localname() library function. According to the report, an "unusual combination" of factors are required to successfully exploit the flaw, including authenticating to a vulnerable service using a principal name explicitly listed in the mapping list.

The report also indicates that default configurations of the target service are not affected. Only those configurations that enable the explicit mapping or rules-based mapping functionality of krb5_aname_to_localname() are reported to be vulnerable.

If the rules-based mapping functionality is enabled, the remote user must first create an arbitrary principal name in the local Kerberos realm or in a remote realm that is accessible via cross-realm authentication.

It is reported that various remote login services (e.g., ftp, rsh, rlogin, telnet) are affected, as well as ksu. Other services that use the krb5 library may be affected if they use the vulnerable function, the report said.

Impact:   In certain cases, a remote user may be able to execute arbitrary code with root privileges.
Solution:   The vendor has issued a patch, available at:

http://web.mit.edu/kerberos/advisories/2004-001-an_to_ln_patch.txt

Also, the upcoming version krb5-1.3.4 release will include a fix for this vulnerability.

Vendor URL:  web.mit.edu/kerberos/advisories/MITKRB5-SA-2004-001-an_to_ln.txt (Links to External Site)
Cause:   Boundary error
Underlying OS:   Linux (Any), UNIX (Any)

Message History:   This archive entry has one or more follow-up message(s) listed below.
Jun 2 2004 (Trustix Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Trustix Security Advisor <tsl@trustix.org>)
Trustix has released a fix.
Jun 4 2004 (Mandrake Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Mandrake Linux Security Team <security@linux-mandrake.com>)
Mandrake has released a fix.
Jun 9 2004 (Red Hat Issues Fix for RH Enterprise Linux) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (bugzilla@redhat.com)
Red Hat has released a fix for Red Hat Enterprise Linux 2.1 and 3.
Jun 9 2004 (Mandrake Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Mandrake Linux Security Team <security@linux-mandrake.com>)
Mandrake has released a fix.
Jun 10 2004 (Fedora Issues Fix for FC1) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Nalin Dahyabhai <nalin@redhat.com>)
Fedora has released a fix for Fedora Core 1.
Jun 10 2004 (Fedora Issues Fix for FC2) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Nalin Dahyabhai <nalin@redhat.com>)
Fedora has released a fix for Fedora Core 2.
Jun 17 2004 (Debian Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Matt Zimmerman <mdz@debian.org>)
Debian has released a fix.
Jun 30 2004 (Gentoo Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Kurt Lieber <klieber@gentoo.org>)
Gentoo has released a fix.
Sep 8 2004 (Apple Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Apple Product Security <product-security@apple.com>)
Apple has released a fix for Mac OS X.
Sep 11 2004 (Conectiva Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Conectiva Updates <secure@conectiva.com.br>)
Conectiva has released a fix.
Dec 29 2004 (Conectiva Issues Fix) Kerberos Buffer Overflows in krb5_aname_to_localname() May Let Remote Users Gain Root Access   (Conectiva Updates <secure@conectiva.com.br>)
Conectiva has released a fix.



 Source Message Contents

Date:  Tue, 01 Jun 2004 16:32:42 -0400
Subject:  MITKRB5-SA-2004-001: buffer overflows in krb5_aname_to_localname


-----BEGIN PGP SIGNED MESSAGE-----

                 MIT krb5 Security Advisory 2004-001

2004-06-01

Topic: buffer overflows in krb5_aname_to_localname

Severity: serious

SUMMARY
=======

The krb5_aname_to_localname() library function contains multiple
buffer overflows which could be exploited to gain unauthorized root
access.  Exploitation of these flaws requires an unusual combination
of factors, including successful authentication to a vulnerable
service and a non-default configuration on the target service.  (See
MITIGATING FACTORS below.)  No exploits are known to exist yet.

IMPACT
======

A remote attacker can potentially execute arbitrary code on hosts
running vulnerable services.

MITIGATING FACTORS
==================

Only configurations which enable the explicit mapping or rules-based
mapping functionality of krb5_aname_to_localname() are vulnerable.
These configurations are not the default.

If the explicit mapping functionality is enabled, an attacker must
authenticate using a principal name listed in the explicit mapping
list.

If the rules-based mapping functionality is enabled, an attacker must
be able to create arbitrary principal names either in the local
Kerberos realm or in a remote realm from which the local realm's
services are reachable by cross-realm authentication.

AFFECTED SOFTWARE
=================

All releases of MIT Kerberos 5, up to and including krb5-1.3.3.

The upcoming krb5-1.3.4 release will contain a fix for this problem.

Affected services contained in these releases include the remote login
applications (e.g., ftp, rsh, rlogin, telnet), as well as ksu.
Third-party application servers using the affected functionality of
the krb5 library may be vulnerable.

These services are only vulnerable in non-default configurations.

FIXES
=====

* If you are using the vulnerable functionality, consider disabling it
  immediately.  Complete disabling of any configuration of explicit
  mapping or rules-based mapping should prevent exploitation.

* The upcoming krb5-1.3.4 release will contain a fix for this problem.

* Apply the following patch to src/lib/krb5/os/an_to_ln.c, and
  recompile the affected libraries and applications.

Index: an_to_ln.c
===================================================================
RCS file: /cvs/krbdev/krb5/src/lib/krb5/os/an_to_ln.c,v
retrieving revision 5.39
diff -c -r5.39 an_to_ln.c
*** an_to_ln.c	2002/09/03 19:29:34	5.39
- --- an_to_ln.c	2004/05/14 19:39:21
***************
*** 270,278 ****
   * If no regcomp() then just return the input string verbatim in the output
   * string.
   */
! static void
  do_replacement(char *regexp, char *repl, int doall, char *in, char *out)
  {
  #if	HAVE_REGCOMP
      regex_t	match_exp;
      regmatch_t	match_match;
- --- 270,283 ----
   * If no regcomp() then just return the input string verbatim in the output
   * string.
   */
! #define use_bytes(x) \
!     out_used += (x); \
!     if (out_used > MAX_FORMAT_BUFFER) goto mem_err
! 
! static int
  do_replacement(char *regexp, char *repl, int doall, char *in, char *out)
  {
+     size_t out_used = 0;
  #if	HAVE_REGCOMP
      regex_t	match_exp;
      regmatch_t	match_match;
***************
*** 287,303 ****
  	do {
  	    if (!regexec(&match_exp, cp, 1, &match_match, 0)) {
  		if (match_match.rm_so) {
  		    strncpy(op, cp, match_match.rm_so);
  		    op += match_match.rm_so;
  		}
  		strncpy(op, repl, MAX_FORMAT_BUFFER - 1 - (op - out));
  		op += strlen(op);
  		cp += match_match.rm_eo;
! 		if (!doall)
  		    strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
  		matched = 1;
  	    }
  	    else {
  		strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
  		matched = 0;
  	    }
- --- 292,313 ----
  	do {
  	    if (!regexec(&match_exp, cp, 1, &match_match, 0)) {
  		if (match_match.rm_so) {
+ 		    use_bytes(match_match.rm_so);
  		    strncpy(op, cp, match_match.rm_so);
  		    op += match_match.rm_so;
  		}
+ 		use_bytes(strlen(repl));
  		strncpy(op, repl, MAX_FORMAT_BUFFER - 1 - (op - out));
  		op += strlen(op);
  		cp += match_match.rm_eo;
! 		if (!doall) {
! 		    use_bytes(strlen(cp));
  		    strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
+ 		}
  		matched = 1;
  	    }
  	    else {
+ 		use_bytes(strlen(cp));
  		strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
  		matched = 0;
  	    }
***************
*** 322,338 ****
- --- 332,352 ----
  	    sdispl = (size_t) (loc1 - cp);
  	    edispl = (size_t) (loc2 - cp);
  	    if (sdispl) {
+ 		use_bytes(sdispl);
  		strncpy(op, cp, sdispl);
  		op += sdispl;
  	    }
+ 	    use_bytes(strlen(repl));
  	    strncpy(op, repl, MAX_FORMAT_BUFFER - 1 - (op - out));
  	    op += strlen(repl);
  	    cp += edispl;
  	    if (!doall)
+ 		use_bytes(strlen(cp));
  		strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
  	    matched = 1;
  	}
  	else {
+ 	    use_bytes(strlen(cp));
  	    strncpy(op, cp, MAX_FORMAT_BUFFER - 1 - (op - out));
  	    matched = 0;
  	}
***************
*** 340,346 ****
- --- 354,368 ----
  #else	/* HAVE_REGEXP_H */
      memcpy(out, in, MAX_FORMAT_BUFFER);
  #endif	/* HAVE_REGCOMP */
+     return 1;
+  mem_err:
+ #ifdef HAVE_REGCMP
+     	regfree(&match_exp);
+ #endif
+ 	return 0;
+ 	
  }
+ #undef use_bytes
  
  /*
   * aname_replacer()	- Perform the specified substitutions on the input
***************
*** 412,418 ****
  
  		    /* Do the replacemenbt */
  		    memset(out, '\0', MAX_FORMAT_BUFFER);
! 		    do_replacement(rule, repl, doglobal, in, out);
  		    free(rule);
  		    free(repl);
  
- --- 434,445 ----
  
  		    /* Do the replacemenbt */
  		    memset(out, '\0', MAX_FORMAT_BUFFER);
! 		    if (!do_replacement(rule, repl, doglobal, in, out)) {
! 			free(rule);
! 		    free(repl);
! 			kret = KRB5_LNAME_NOTRANS;
! 			break;
! 		    }
  		    free(rule);
  		    free(repl);
  
***************
*** 459,464 ****
- --- 486,492 ----
      char		*fprincname;
      char		*selstring = 0;
      int			num_comps, compind;
+     size_t selstring_used;
      char		*cout;
      krb5_data		*datap;
      char		*outstring;
***************
*** 479,484 ****
- --- 507,513 ----
  		     */
  		    current = strchr(current, ':');
  		    selstring = (char *) malloc(MAX_FORMAT_BUFFER);
+ 		    selstring_used = 0;
  		    if (current && selstring) {
  			current++;
  			cout = selstring;
***************
*** 497,502 ****
- --- 526,539 ----
  								  aname,
  								  compind-1))
  				    ) {
+ 				    if ((datap->length < MAX_FORMAT_BUFFER)
+ 					&&  (selstring_used+datap->length
+ 					     < MAX_FORMAT_BUFFER)) {
+ 					selstring_used += datap->length;
+ 				    } else {
+ 					kret = ENOMEM;
+ 					goto errout;
+ 				    }
  				    strncpy(cout,
  					    datap->data,
  					    (unsigned) datap->length);
***************
*** 527,533 ****
  			else
  			    kret = KRB5_CONFIG_BADFORMAT;
  
! 			if (kret)
  			    free(selstring);
  		    }
  		}
- --- 564,570 ----
  			else
  			    kret = KRB5_CONFIG_BADFORMAT;
  
! 			errout: if (kret)
  			    free(selstring);
  		    }
  		}
***************
*** 643,649 ****
      const char		*hierarchy[5];
      char		**mapping_values;
      int			i, nvalid;
!     char		*cp;
      char		*typep, *argp;
      unsigned int        lnsize;
  
- --- 680,686 ----
      const char		*hierarchy[5];
      char		**mapping_values;
      int			i, nvalid;
!     char		*cp, *s;
      char		*typep, *argp;
      unsigned int        lnsize;
  
***************
*** 677,687 ****
  
  		    /* Just use the last one. */
  		    /* Trim the value. */
! 		    cp = &mapping_values[nvalid-1]
! 			[strlen(mapping_values[nvalid-1])];
! 		    while (isspace((int) (*cp))) cp--;
! 		    cp++;
! 		    *cp = '\0';
  
  		    /* Copy out the value if there's enough room */
  		    if (strlen(mapping_values[nvalid-1])+1 <= (size_t) lnsize)
- --- 714,727 ----
  
  		    /* Just use the last one. */
  		    /* Trim the value. */
! 		    s = mapping_values[nvalid-1];
! 		    cp = s + strlen(s);
! 		    while (cp > s) {
! 			cp--;
! 			if (!isspace((int)(*cp)))
! 			    break;
! 			*cp = '\0';
! 		    }
  
  		    /* Copy out the value if there's enough room */
  		    if (strlen(mapping_values[nvalid-1])+1 <= (size_t) lnsize)

The patch was generated against krb5-1.3.3; it may apply, with some
offset, to other releases.

This patch may also be found at:

http://web.mit.edu/kerberos/advisories/2004-001-an_to_ln_patch.txt

The associated detached PGP signature is at:

http://web.mit.edu/kerberos/advisories/2004-001-an_to_ln_patch.txt.asc

REFERENCES
==========

This announcement and related security advisories may be found on the
MIT Kerberos security advisory page at:

        http://web.mit.edu/kerberos/advisories/index.html

The main MIT Kerberos web page is at:

        http://web.mit.edu/kerberos/index.html

ACKNOWLEDGMENTS
===============

Thanks to Christopher Nebergall for finding the single-byte overflow.

Thanks to Nico Williams for finding a vulnerability in the rules-based
mapping.

Thanks to Matt Crawford for useful comments.

DETAILS
=======

krb5_aname_to_localname() translates a Kerberos principal name to a
local account name, typically a UNIX username.  In the file
src/lib/krb5/os/an_to_ln.c, the helper functions aname_replacer(),
do_replacement(), and rule_an_to_ln() do not perform adequate checks
of the lengths of strings which contain the name of the principal
whose authorization is being checked.  This can result in the overflow
of heap buffers when an attacker authenticates using a sufficiently
long principal name.

In addition, the implementation of the explicit mapping functionality
in krb5_aname_to_localname() consistently writes a zero byte at a
location one byte past the end of a heap buffer when handling a
principal name matching an explicit mapping.  Single-byte overflows of
heap buffers are known to be exploitable on some architectures.  The
vulnerability in the explicit mapping functionality was fixed around
December 2003 in the development sources, but the fix was not
propagated to the krb5-1.3.x release branch.

REVISION HISTORY
================

2004-06-01      original release

Copyright (C) 2004 Massachusetts Institute of Technology
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (SunOS)

iQCVAwUBQLzhKKbDgE/zdoE9AQEIQAP+Nr2GZig5o2TM/0hxmuSDKuDCHQ8k4KBr
NCucgV8qVfhXw6MLX+PLX96CniyaFjuKGlS6PS7z2eTRt6qsvxohR1gAfZ7olN5u
pDOl5/D9CXnNqwz5ulh7TiaWuVXZab5RfjveZSvxi2fR2CCdUnBab/J4jzOeQyl+
bjJPpeMJiQE=
=yGUt
-----END PGP SIGNATURE-----

 
 


Go to the Top of This SecurityTracker Archive Page





Home   |    View Topics   |    Search   |    Contact Us

Copyright 2013, SecurityGlobal.net LLC