__________________________________________________________ The U.S. Department of Energy Computer Incident Advisory Capability ___ __ __ _ ___ / | /_\ / \___ __|__ / \ \___ __________________________________________________________ INFORMATION BULLETIN Buffer Overflow in kadmind4 [MIT krb5 Security Advisory 2002-002] October 23, 2002 17:00 GMT Number N-009 ______________________________________________________________________________ PROBLEM: A stack buffer overflow in the implementation of the Kerberos v4 compatibility administration daemon (kadmind4) in the MIT krb5 distribution could be exploited to gain unauthorized root access to a KDC host. SOFTWARE: All releases of MIT Kerberos 5, up to and including krb5-1.2.6. All Kerberos 4 implementations derived from MIT Kerberos 4, including Cygnus Network Security (CNS). DAMAGE: A remote attacker could execute arbitrary code on the KDC with the privileges of the user running kadmind4 (usually root). SOLUTION: Apply patch. ______________________________________________________________________________ VULNERABILITY The risk is HIGH. An attacker does not need to authenticate to ASSESSMENT: the daemon to successfully perform this attack. At least one exploit is known to exist in the wild. ______________________________________________________________________________ LINKS: CIAC BULLETIN: http://www.ciac.org/ciac/bulletins/n-009.shtml ORIGINAL BULLETIN: http://web.mit.edu/kerberos/www/advisories/MITKRB5-SA-2002-002-kadm4.txt ______________________________________________________________________________ [***** Start MIT krb5 Security Advisory 2002-002 *****] -----BEGIN PGP SIGNED MESSAGE----- MIT krb5 Security Advisory 2002-002 2002-10-22 Topic: Buffer overflow in kadmind4 Severity: CRITICAL - Remote user can gain root access to KDC host. SUMMARY ======= A stack buffer overflow in the implementation of the Kerberos v4 compatibility administration daemon (kadmind4) in the MIT krb5 distribution can be exploited to gain unauthorized root access to a KDC host. The attacker does not need to authenticate to the daemon to successfully perform this attack. At least one exploit is known to exist in the wild. The kadmind4 supplied with MIT krb5 is intended for use in sites that require compatibility with legacy administrative clients; sites that do not have this requirement are not likely to be running this daemon. IMPACT ====== A remote attacker can execute arbitrary code on the KDC with the privileges of the user running kadmind4 (usually root). This can lead to compromise of the Kerberos database. AFFECTED SOFTWARE ================= * All releases of MIT Kerberos 5, up to and including krb5-1.2.6. * All Kerberos 4 implementations derived from MIT Kerberos 4, including Cygnus Network Security (CNS). FIXES ===== Apply the following patch to src/kadmin/v4server/kadm_ser_wrap.c: Index: kadm_ser_wrap.c =================================================================== RCS file: /cvs/krbdev/krb5/src/kadmin/v4server/kadm_ser_wrap.c,v retrieving revision 1.10.4.1 diff -c -r1.10.4.1 kadm_ser_wrap.c *** kadm_ser_wrap.c 2000/05/23 21:44:50 1.10.4.1 - --- kadm_ser_wrap.c 2002/10/22 22:07:11 *************** *** 170,183 **** u_char *retdat, *tmpdat; int retval, retlen; ! if (strncmp(KADM_VERSTR, (char *)*dat, KADM_VERSIZE)) { errpkt(dat, dat_len, KADM_BAD_VER); return KADM_BAD_VER; } in_len = KADM_VERSIZE; /* get the length */ ! if ((retc = stv_long(*dat, &r_len, in_len, *dat_len)) < 0) return KADM_LENGTH_ERROR; in_len += retc; authent.length = *dat_len - r_len - KADM_VERSIZE - sizeof(krb5_ui_4); memcpy((char *)authent.dat, (char *)(*dat) + in_len, authent.length); - --- 170,190 ---- u_char *retdat, *tmpdat; int retval, retlen; ! if ((*dat_len < KADM_VERSIZE + sizeof(krb5_ui_4)) ! || strncmp(KADM_VERSTR, (char *)*dat, KADM_VERSIZE)) { errpkt(dat, dat_len, KADM_BAD_VER); return KADM_BAD_VER; } in_len = KADM_VERSIZE; /* get the length */ ! if ((retc = stv_long(*dat, &r_len, in_len, *dat_len)) < 0 ! || (r_len > *dat_len - KADM_VERSIZE - sizeof(krb5_ui_4)) ! || (*dat_len - r_len - KADM_VERSIZE - ! sizeof(krb5_ui_4) > sizeof(authent.dat))) { ! errpkt(dat, dat_len, KADM_LENGTH_ERROR); return KADM_LENGTH_ERROR; + } + in_len += retc; authent.length = *dat_len - r_len - KADM_VERSIZE - sizeof(krb5_ui_4); memcpy((char *)authent.dat, (char *)(*dat) + in_len, authent.length); The patch was generated against krb5-1.2.6; patches to other releases may apply with some offset. This patch may also be found at: http://web.mit.edu/kerberos/www/advisories/2002-002-kadm4_patch.txt The associated detached PGP signature is at: http://web.mit.edu/kerberos/www/advisories/2002-002-kadm4_patch.txt.asc This announcement and code patches related to it 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 ACKNOWLEDGMENTS =============== Thanks to Johan Danielsson and Love Hornquist-Astrand for alerting us to this problem and providing us with an initial patch. Thanks to Assar Westerlund for further assistance in developing the patch. DETAILS ======= The function kadm_ser_in() is passed an allocated buffer (containing a request read from the network) and its length. From this buffer, it reads an 8-byte version string followed by a 4-byte length. This length field is not checked; an attacker can construct a request that will cause authent.length to become negative or to become greater than sizeof(authent.dat). Both cases can cause the following call to memcpy() to overflow authent.dat, which is a buffer on the stack. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (SunOS) iQCVAwUBPbYaj6bDgE/zdoE9AQHYRwP9GJFVcvLfyOgeAXEpWqnQS/RdH5PwOCoi 7+6P2jILef1glCfqNmGfJK2kCh5pN8cioplYUgG2XLC1ATHSQoy18ldByfeU9mwJ ae5GV0K8v7LifpMqPobxCHQdzNi02xjZtiLbQTH/8ACtYLn+rS7ZbtfrVti5bWy9 juJ+NZDS4RA= =5VQa -----END PGP SIGNATURE----- [***** End MIT krb5 Security Advisory 2002-002 *****] _______________________________________________________________________________ CIAC wishes to acknowledge the contributions of MIT for the information contained in this bulletin. _______________________________________________________________________________ CIAC, the Computer Incident Advisory Capability, is the computer security incident response team for the U.S. Department of Energy (DOE) and the emergency backup response team for the National Institutes of Health (NIH). CIAC is located at the Lawrence Livermore National Laboratory in Livermore, California. CIAC is also a founding member of FIRST, the Forum of Incident Response and Security Teams, a global organization established to foster cooperation and coordination among computer security teams worldwide. CIAC services are available to DOE, DOE contractors, and the NIH. CIAC can be contacted at: Voice: +1 925-422-8193 (7x24) FAX: +1 925-423-8002 STU-III: +1 925-423-2604 E-mail: ciac@ciac.org Previous CIAC notices, anti-virus software, and other information are available from the CIAC Computer Security Archive. World Wide Web: http://www.ciac.org/ Anonymous FTP: ftp.ciac.org PLEASE NOTE: Many users outside of the DOE, ESnet, and NIH computing communities receive CIAC bulletins. If you are not part of these communities, please contact your agency's response team to report incidents. Your agency's team will coordinate with CIAC. The Forum of Incident Response and Security Teams (FIRST) is a world-wide organization. A list of FIRST member organizations and their constituencies can be obtained via WWW at http://www.first.org/. This document was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes. LAST 10 CIAC BULLETINS ISSUED (Previous bulletins available from CIAC) M-129: Microsoft FrontPage SmartHTML Interpreter Vulnerability M-128: Apple QuickTime ActiveX Buffer Overrun N-001: Microsoft File Decompression Functions Vulnerabilities N-002: Microsoft HTML Help ActiveX Control Vulnerabilities N-003: Microsoft Cumulative Patch for SQL Server N-004: SGI rpcbind User-level Vulnerabilities N-005: Apache 1.3.27 HTTP Server Release N-006: HP pam_authz in LDAP-UX Integration Vulnerabilities N-007: Microsoft Outlook Express Unchecked Buffer in S/MIME Vulnerability N-008: Microsoft Elevation of Privilege in SQL Server Web Tasks