copyright | disclaimer | privacy | contact  
Australia's Leading Computer Emergency Response Team
 
Search this site

 
On this site

 > HOME
 > About AusCERT
 > Membership
 > Contact Us
 > PKI Services
 > Training
 > Publications
 > Sec. Bulletins
 > Conferences
 > News & Media
 > Services
 > Web Log
 > Site Map
 > Site Help
 > Member login





 

ESB-2003.0191 -- MIT krb5 Security Advisory 2003-003 -- Faulty length checks in xdrmem_getbytes

Date: 20 March 2003
References: ESB-2003.0219  ESB-2003.0221  

Click here for printable version
Click here for PGP verifiable version
-----BEGIN PGP SIGNED MESSAGE-----

===========================================================================
             AUSCERT External Security Bulletin Redistribution

           ESB-2003.0191 -- MIT krb5 Security Advisory 2003-003
                  Faulty length checks in xdrmem_getbytes
                               20 March 2003

===========================================================================

        AusCERT Security Bulletin Summary
        ---------------------------------

Product:                krb5 1.2.7 and prior
Vendor:                 MIT
Operating System:       Linux
                        UNIX
Impact:                 Denial of Service
                        Access Confidential Data
Access Required:        Remote
CVE Names:              CAN-2003-0028

Ref:                    AL-2003.03

- --------------------------BEGIN INCLUDED TEXT--------------------

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

                 MIT krb5 Security Advisory 2003-003

2003-03-18

Topic: faulty length checks in xdrmem_getbytes

Severity: serious

SUMMARY
=======

The MIT Kerberos 5 implementation includes an RPC library derived from
SUNRPC.  We have been notified that the xdrmem_getbytes() function
contains faulty length checks.  These length checks are vulnerable to
an integer overflow, which may be exploitable to create denials of
service or to gain unauthorized access to sensitive information.

An attacker who has successfully authenticated to the Kerberos
administration daemon (kadmind) may be able to crash kadmind or induce
it to leak sensitive information, such as secret keys.  For the attack
to succeed, it is believed that the configuration of the kadmind
installation must allow it to successfully allocate more than INT_MAX
bytes of memory.

IMPACT
======

* An attacker capable of authenticating to kadmind may be able to crash
  kadmind.

* Under extremely unlikely circumstances, an attacker capable of
  authenticating to kadmind may be able to induce it to return
  sensitive information, such as secret keys.

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

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

FIX
===

Apply the following patch to src/lib/rpc/xdr_mem.c and rebuild your
tree.

Index: xdr_mem.c
===================================================================
RCS file: /cvs/krbdev/krb5/src/lib/rpc/xdr_mem.c,v
retrieving revision 1.8
diff -c -r1.8 xdr_mem.c
*** xdr_mem.c	1998/02/14 02:27:24	1.8
- - --- xdr_mem.c	2003/02/04 22:57:24
***************
*** 47,52 ****
- - --- 47,54 ----
  #include <gssrpc/xdr.h>
  #include <netinet/in.h>
  #include <stdio.h>
+ #include <string.h>
+ #include <limits.h>
  
  static bool_t	xdrmem_getlong();
  static bool_t	xdrmem_putlong();
***************
*** 83,89 ****
  	xdrs->x_op = op;
  	xdrs->x_ops = &xdrmem_ops;
  	xdrs->x_private = xdrs->x_base = addr;
! 	xdrs->x_handy = size;
  }
  
  static void
- - --- 85,91 ----
  	xdrs->x_op = op;
  	xdrs->x_ops = &xdrmem_ops;
  	xdrs->x_private = xdrs->x_base = addr;
! 	xdrs->x_handy = (size > INT_MAX) ? INT_MAX : size; /* XXX */
  }
  
  static void
***************
*** 98,105 ****
  	long *lp;
  {
  
! 	if ((xdrs->x_handy -= sizeof(rpc_int32)) < 0)
  		return (FALSE);
  	*lp = (long)ntohl(*((rpc_u_int32 *)(xdrs->x_private)));
  	xdrs->x_private += sizeof(rpc_int32);
  	return (TRUE);
- - --- 100,109 ----
  	long *lp;
  {
  
! 	if (xdrs->x_handy < sizeof(rpc_int32))
  		return (FALSE);
+ 	else
+ 		xdrs->x_handy -= sizeof(rpc_int32);
  	*lp = (long)ntohl(*((rpc_u_int32 *)(xdrs->x_private)));
  	xdrs->x_private += sizeof(rpc_int32);
  	return (TRUE);
***************
*** 111,118 ****
  	long *lp;
  {
  
! 	if ((xdrs->x_handy -= sizeof(rpc_int32)) < 0)
  		return (FALSE);
  	*(rpc_int32 *)xdrs->x_private = (rpc_int32)htonl((rpc_u_int32)(*lp));
  	xdrs->x_private += sizeof(rpc_int32);
  	return (TRUE);
- - --- 115,124 ----
  	long *lp;
  {
  
! 	if (xdrs->x_handy < sizeof(rpc_int32))
  		return (FALSE);
+ 	else
+ 		xdrs->x_handy -= sizeof(rpc_int32);
  	*(rpc_int32 *)xdrs->x_private = (rpc_int32)htonl((rpc_u_int32)(*lp));
  	xdrs->x_private += sizeof(rpc_int32);
  	return (TRUE);
***************
*** 125,132 ****
  	register unsigned int len;
  {
  
! 	if ((xdrs->x_handy -= len) < 0)
  		return (FALSE);
  	memmove(addr, xdrs->x_private, len);
  	xdrs->x_private += len;
  	return (TRUE);
- - --- 131,140 ----
  	register unsigned int len;
  {
  
! 	if (xdrs->x_handy < len)
  		return (FALSE);
+ 	else
+ 		xdrs->x_handy -= len;
  	memmove(addr, xdrs->x_private, len);
  	xdrs->x_private += len;
  	return (TRUE);
***************
*** 139,146 ****
  	register unsigned int len;
  {
  
! 	if ((xdrs->x_handy -= len) < 0)
  		return (FALSE);
  	memmove(xdrs->x_private, addr, len);
  	xdrs->x_private += len;
  	return (TRUE);
- - --- 147,156 ----
  	register unsigned int len;
  {
  
! 	if (xdrs->x_handy < len)
  		return (FALSE);
+ 	else
+ 		xdrs->x_handy -= len;
  	memmove(xdrs->x_private, addr, len);
  	xdrs->x_private += len;
  	return (TRUE);
***************
*** 179,185 ****
  {
  	rpc_int32 *buf = 0;
  
! 	if (xdrs->x_handy >= len) {
  		xdrs->x_handy -= len;
  		buf = (rpc_int32 *) xdrs->x_private;
  		xdrs->x_private += len;
- - --- 189,195 ----
  {
  	rpc_int32 *buf = 0;
  
! 	if (len >= 0 && xdrs->x_handy >= len) {
  		xdrs->x_handy -= len;
  		buf = (rpc_int32 *) xdrs->x_private;
  		xdrs->x_private += len;

The patch was generated against krb5-1.2.7; patches to other releases
may apply with some offset.

This patch may also be found at:

http://web.mit.edu/kerberos/www/advisories/2003-003-xdr_patch.txt

The associated detached PGP signature is at:

http://web.mit.edu/kerberos/www/advisories/2003-003-xdr_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/www/advisories/index.html

The main MIT Kerberos web page is at:

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

CERT VU#516825

        http://www.kb.cert.org/vuls/id/516825

CVE CAN-2003-0028

        http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0028

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

Thanks to CERT for notifying us of this vulnerability.

DETAILS
=======

The xdrmem_getbytes() function decrements the private signed integer
"xdrs->x_handy" by the supplied length "len", which is an unsigned
int.  It then verifies that the resulting value of "xdrs->x_handy" is
non-negative.  Using a carefully chosen value of "len" (so that it is
greater than INT_MAX), it is possible for this check to succeed even
if the value of "len" would cause the buffer to be overrun on read.
This overrun may result in a segmentation fault, or in the
unauthorized copying of sensitive information.

A mitigating factor is that most call chains that end up calling
xdrmem_getbytes() first call malloc() (via the mem_alloc() macro) to
allocate a buffer of the requested length.  This allocation of more
than INT_MAX bytes will fail on most configurations due to internal
limitations of malloc() or due to system resource limits.  On systems
where allocation of more than INT_MAX bytes can succeed (possibly
including 64-bit environments), the probability of successful exploit
is higher.

In MIT krb5, the vulnerable invocations of xdrmem_getbytes() inside
kadmind only occur after the user has successfully authenticated.
Additionally, any unauthorized copies of sensitive data obtained by
exercising this vulnerability are extremely unlikely to be returned to
the remote client.

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

2003-03-18      original release
- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (SunOS)

iQCVAwUBPnd5J6bDgE/zdoE9AQEIeAQAxuMhSNtC94YhIqQcuhRsKXFf/T8T8lh6
YUeTNaqA9sQkZBE2sZEyI4uq0iiZjwQyUfhylcPbEaIX3f9dto8YWmRvPztsvIQR
jzAlRU4o7//kw2oWu1JQC0FNpcifr1D1j0E59xqjDaCGDa6LlMFqd/V77pHKIcLU
c0DO4+ORljY=
=54iC
- -----END PGP SIGNATURE-----

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content.  The decision to use any or all of this information is
the responsibility of each user or organisation, and should be done so in
accordance with site policies and procedures.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/render.html?cid=1980

If you believe that your system has been compromised, contact AusCERT or
your representative in FIRST (Forum of Incident Response and Security
Teams).

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business 
                hours which are GMT+10:00 (AEST).  On call after hours 
                for member emergencies only.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: http://www.auscert.org.au/render.html?it=1967

iQCVAwUBPnn4Oih9+71yA2DNAQHXVQQAg44sOul9+JY87m2papcCrSqfYUfTylG3
4nIRln/KyojoG8CcJRczesTo7Y9DiILD+ADQ2uUED2sO1IxugPTDcZlGWkvKlDbA
ycOe1gnBD/7sVdazBFGWmqQeicMHQyvlkNxhP/yLPSqzGaiZGS0eFx2TfcRWX9HB
8rIIx9sh1M4=
=hvw/
-----END PGP SIGNATURE-----