|
__________________________________________________________ The U.S. Department of Energy Computer Incident Advisory Capability ___ __ __ _ ___ / | /_\ / \___ __|__ / \ \___ __________________________________________________________ INFORMATION BULLETIN FreeBSD Security Vulnerabilities (ppp, rdist, and rz) July 18, 1996 16:00 GMT Number G-31 ______________________________________________________________________________ PROBLEM: Three vulnerabilities have been found in the FreeBSD operating system: 1) ppp program, 2) rdist, and 3) a "trojan horse" via rz program. PLATFORM: Vulnerabilities 1 and 2: All platforms running FreeBSD 2.0, 2.0.5, 2.1, 2.1-stable, and 2.2-current. Vulnerability 3: All FreeBSD ports collections released before 2.1.5-RELEASE. DAMAGE: 1) The ppp program does not properly manage user privileges, allowing users to run any program with root access. 2) rdist creates an error message based on a user provided string, without checking bounds on the buffer used. This buffer is on the stack, and can therefore be used to execute arbitrary instructions. 3) The rz program allows the sender of a file to request the execution of arbitrary commands on the receiver's side. The user using rz does not have any control over this feature. SOLUTION: Install the proper patches and/or use the workarounds provided below. ______________________________________________________________________________ VULNERABILITY Vulnerabilities 1 and 2 are widely known. ASSESSMENT: Vulnerability 3 is relatively new. ______________________________________________________________________________ [Begin FreeBSD Bulletins] 1. ppp Program Vulnerability =============================================================================== FreeBSD-SA-96:15 Security Advisory FreeBSD, Inc. Topic: security compromise from ppp Category: core Module: ppp Announced: 1996-07-04 Affects: FreeBSD 2.0.5, 2.1, 2.1-stable, and 2.2-current Corrected: 2.1-stable and 2.2-current as of 1996-06-10 FreeBSD only: unknown Patches: ftp://freebsd.org/pub/CERT/patches/SA-96:15/ ============================================================================= I. Background FreeBSD ships a userland ppp program that can be used by users to set up ppp connections. This program is also known as ijppp. The ppp program has a vulnerability that allows any user to run commands under root privileges. II. Problem Description The ppp program does not properly manage user privileges, allowing users to run any program with root privileges. III. Impact This vulnerability can only be exploited by users with a valid account on the local system to easily obtain superuser access. IV. Workaround One may simply disable the setuid bit on all copies of the ppp program. This will close the vulnerability but will only allow the superuser to set up ppp connections. As root, execute the commands: # chmod 555 /usr/sbin/ppp then verify that the setuid permissions of the files have been removed. The permissions array should read "-r-xr-xr-x" as shown here: # ls -l /usr/sbin/ppp -r-xr-xr-x 1 root bin 86016 Nov 16 1995 /usr/sbin/ppp V. Solution Patches are available which eliminate this vulnerability. The following patch should be applied to the system sources and ppp should be rebuilt and reinstalled. The first patch is against the FreeBSD 2.1 and FreeBSD-stable source tree. The second patch is for FreeBSD-current (version before 1996-06-10). Apply the patch, then (being superuser): # cd /usr/src/usr.sbin/ppp # make depend # make all # make install Index: command.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/command.c,v retrieving revision 1.5.4.3 retrieving revision 1.5.4.4 diff -u -r1.5.4.3 -r1.5.4.4 --- command.c 1996/02/05 17:02:52 1.5.4.3 +++ command.c 1996/06/10 09:41:49 1.5.4.4 @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.5.4.3 1996/02/05 17:02:52 dfr Exp $ + * $Id: command.c,v 1.5.4.4 1996/06/10 09:41:49 ache Exp $ * */ #include <sys/types.h> @@ -187,9 +187,14 @@ * We are running setuid, we should change to * real user for avoiding security problems. */ - setgid( getgid() ); - setuid( getuid() ); - + if (setgid(getgid()) < 0) { + perror("setgid"); + exit(1); + } + if (setuid(getuid()) < 0) { + perror("setuid"); + exit(1); + } TtyOldMode(); if(argc > 0) execvp(argv[0], argv); Index: chat.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/chat.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -u -r1.4.4.1 -r1.4.4.2 --- chat.c 1995/10/06 11:24:31 1.4.4.1 +++ chat.c 1996/06/10 09:41:45 1.4.4.2 @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: chat.c,v 1.4.4.1 1995/10/06 11:24:31 davidg Exp $ + * $Id: chat.c,v 1.4.4.2 1996/06/10 09:41:45 ache Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -331,6 +331,15 @@ nb = open("/dev/tty", O_RDWR); dup2(nb, 0); LogPrintf(LOG_CHAT, "exec: %s\n", command); + /* switch back to original privileges */ + if (setgid(getgid()) < 0) { + LogPrintf(LOG_CHAT, "setgid: %s\n", strerror(errno)); + exit(1); + } + if (setuid(getuid()) < 0) { + LogPrintf(LOG_CHAT, "setuid: %s\n", strerror(errno)); + exit(1); + } pid = execvp(command, vector); LogPrintf(LOG_CHAT, "execvp failed for (%d/%d): %s\n", pid, errno, command); exit(127); Patch for FreeBSd-current before 1996-06-10: Index: command.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/command.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- command.c 1996/05/11 20:48:22 1.17 +++ command.c 1996/06/09 20:40:58 1.18 @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.17 1996/05/11 20:48:22 phk Exp $ + * $Id: command.c,v 1.18 1996/06/09 20:40:58 ache Exp $ * */ #include <sys/types.h> @@ -190,9 +190,14 @@ * We are running setuid, we should change to * real user for avoiding security problems. */ - setgid( getgid() ); - setuid( getuid() ); - + if (setgid(getgid()) < 0) { + perror("setgid"); + exit(1); + } + if (setuid(getuid()) < 0) { + perror("setuid"); + exit(1); + } TtyOldMode(); if(argc > 0) execvp(argv[0], argv); Index: chat.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/chat.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- chat.c 1996/05/11 20:48:20 1.10 +++ chat.c 1996/06/09 20:40:56 1.11 @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: chat.c,v 1.10 1996/05/11 20:48:20 phk Exp $ + * $Id: chat.c,v 1.11 1996/06/09 20:40:56 ache Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -393,6 +393,15 @@ nb = open("/dev/tty", O_RDWR); dup2(nb, 0); LogPrintf(LOG_CHAT_BIT, "exec: %s\n", command); + /* switch back to original privileges */ + if (setgid(getgid()) < 0) { + LogPrintf(LOG_CHAT_BIT, "setgid: %s\n", strerror(errno)); + exit(1); + } + if (setuid(getuid()) < 0) { + LogPrintf(LOG_CHAT_BIT, "setuid: %s\n", strerror(errno)); + exit(1); + } pid = execvp(command, vector); LogPrintf(LOG_CHAT_BIT, "execvp failed for (%d/%d): %s\n", pid, errno, command); exit(127); ============================================================================= 2. rdist Vulnerability ============================================================================= FreeBSD-SA-96:16 Security Advisory Revised: Fri Jul 12 09:32:53 PDT 1996 FreeBSD, Inc. Topic: security vulnerability in rdist Category: core Module: rdist Announced: 1996-07-12 Affects: FreeBSD 2.0, 2.0.5, 2.1, 2.1-stable, and 2.2-current Corrected: 2.1-stable and 2.2-current as of 1996-07-11 Source: 4.4BSD (lite) FreeBSD only: no Patches: ftp://freebsd.org/pub/CERT/patches/SA-96:16/ Reference: [8lgm]-Advisory-26.UNIX.rdist.20-3-1996 ============================================================================= I. Background A bug was found in the BSD rdist utility which can allow an unprivileged local user to gain unauthorized access. This problem is present in all source code and binary distributions of FreeBSD version 2.x released before 1996-07-12. rdist has been the subject of security vulnerabilities in the past. This is a newly discovered vulnerability not related to previous race conditions fixed in rdist. II. Problem Description rdist creates an error message based on a user provided string, without checking bounds on the buffer used. This buffer is on the stack, and can therefore be used to execute arbitrary instructions. III. Impact This vulnerability can allow a local user to obtain superuser privileges. It may only be exploited by users with a valid account on the local system. It is present in almost all BSD derived operating systems with a "setuid" rdist program. IV. Workaround The rdist program must be setuid root to function properly. This vulnerability can be eliminated by making rdist not executable by unprivileged users. Since this limits the usefulness of the program, a software update is advised. This workaround will work for all versions of FreeBSD affected by this problem. As root, execute the commands: # chflags noschg /usr/bin/rdist # chmod u-s,go-rx /usr/bin/rdist then verify that the setuid permissions of the files have been removed. The permissions array should read "-r-x------" as shown here: # ls -l /usr/bin/rdist -r-x------ 1 root bin 49152 Jun 16 10:46 rdist V. Solution(s) Apply the available via FTP from the patch directory noted at the top of this message. Recompile, and reinstall the rdist program. This patch is known to apply to all FreeBSD 2.x systems, it has not been tested with FreeBSD 1.x. The [8lgm] organization correctly points out that this program does not have a particularly good security "history." While the patch for this vulnerability does solve this particular problem, it's not clear if other security issues involving rdist will appear in the future. Administrators should consider whether it is appropriate to remove the standard rdist program and upgrade to rdist version 6, which is available as a FreeBSD port. FreeBSD, Inc. has not replaced the standard BSD rdist with the newer code because the new rdist is not protocol-compatible with the original version. ============================================================================= 3. rz Program Vulnerability ============================================================================= FreeBSD-SA-96:17 Security Advisory Revised: Tue Jul 16 21:44:54 PDT 1996 FreeBSD, Inc. Topic: "Trojan Horse" vulnerability via rz program Category: ports Module: rzsz Announced: 1996-07-16 Affects: All FreeBSD ports collections released before 2.1.5-RELEASE Corrected: ports collection as of 1996-07-06 Source: rzsz shareware package FreeBSD only: no Patches: ftp://freebsd.org/pub/CERT/patches/SA-96:17/ ============================================================================= I. Background All existing versions of the rz program (a program for receiving files over serial lines using the Z-Modem protocol) are equipped with a feature that allows the sender of a file to request the execution of arbitrary commands on the receiver's side. The user using rz does not have any control over this feature. The workaround is to have rz never execute any command, and always pretend a successful execution. All FreeBSD users are encouraged to use the workaround provided. Since the intent of the Z-Modem protocol is to provide a reliable connection between systems of a vastly different architecture, the execution of local commands at request of the sending side cannot even be considered a useful feature at all. II. Problem Description The Z-Modem protocol specifies a mechanism which allows the transmitter of a file to execute an arbitrary command string as part of the file transfer. This is typically used to rename files or eliminate temporary files. A malicious "trusted" sender could send down a command that could damage a user's environment. III. Impact The rzsz package is an optional port that made be installed on some FreeBSD systems. This program is not installed by default. Systems without this program are not vulnerable. rz allows "Trojan Horse" type attacks against unsuspecting users. Since the rz executable does not run with special privileges, the vulnerability is limited to changes in the operating environment that the user could willingly perform. This vulnerability is a fundamental flaw in the Z-Modem protocol. Other operating systems and other implementations of the Z-Modem protocol may also suffer similar vulnerabilities. IV. Workaround Disable the rz program. If it has been installed, it would typically be found in /usr/local/bin. # chmod 000 /usr/local/bin/rz # ls -l /usr/local/bin/rz ---------- 1 root wheel 23203 Mar 4 23:12 /usr/local/bin/rz V. Solution(s) This feature is a relatively unknown part of the Z-Modem protocol. It is not critical to file transfers in general. The safest approach is to disable this feature in the receiving program. Any rzsz port that is obtained from the official ports collection after 1996-07-06 includes the following patch to disable this feature. This patch applies to rzsz v3.42, if you have an earlier version of the rzsz sources, please upgrade to the latest version first. *** rz.c.orig Sat Jul 6 17:34:26 1996 --- rz.c Sat Jul 6 17:44:52 1996 *************** *** 1020,1039 **** --- 1020,1045 ---- case ZCOMMAND: cmdzack1flg = Rxhdr[ZF0]; if (zrdata(secbuf, 1024) == GOTCRCW) { + #ifdef BIG_SECURITY_HOLE void exec2(); if (cmdzack1flg & ZCACK1) stohdr(0L); else stohdr((long)sys2(secbuf)); + #else + stohdr(0L); + #endif purgeline(); /* dump impatient questions */ do { zshhdr(4,ZCOMPL, Txhdr); } while (++errors<20 && zgethdr(Rxhdr) != ZFIN); ackbibi(); + #ifdef BIG_SECURITY_HOLE if (cmdzack1flg & ZCACK1) exec2(secbuf); + #endif return ZCOMPL; } zshhdr(4,ZNAK, Txhdr); goto again; ============================================================================= FreeBSD, Inc. Web Site: http://www.freebsd.org/ Confidential contacts: security-officer@freebsd.org PGP Key: ftp://freebsd.org/pub/CERT/public_key.asc Security notifications: security-notifications@freebsd.org Security public discussion: security@freebsd.org Notice: Any patches in this document may not apply cleanly due to modifications caused by digital signature or mailer software. Please reference the URL listed at the top of this document for original copies of all patches if necessary. ============================================================================= [End FreeBSD Bulletins] _______________________________________________________________________________ CIAC wishes to acknowledge the contributions of FreeBSD, Inc. 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 510-422-8193 FAX: +1 510-423-8002 STU-III: +1 510-423-2604 E-mail: ciac@llnl.gov For emergencies and off-hour assistance, DOE, DOE contractor sites, and the NIH may contact CIAC 24-hours a day. During off hours (5PM - 8AM PST), call the CIAC voice number 510-422-8193 and leave a message, or call 800-759-7243 (800-SKY-PAGE) to send a Sky Page. CIAC has two Sky Page PIN numbers, the primary PIN number, 8550070, is for the CIAC duty person, and the secondary PIN number, 8550074 is for the CIAC Project Leader. Previous CIAC notices, anti-virus software, and other information are available from the CIAC Computer Security Archive. World Wide Web: http://ciac.llnl.gov/ Anonymous FTP: ciac.llnl.gov (128.115.19.53) Modem access: +1 (510) 423-4753 (28.8K baud) +1 (510) 423-3331 (28.8K baud) CIAC has several self-subscribing mailing lists for electronic publications: 1. CIAC-BULLETIN for Advisories, highest priority - time critical information and Bulletins, important computer security information; 2. CIAC-NOTES for Notes, a collection of computer security articles; 3. SPI-ANNOUNCE for official news about Security Profile Inspector (SPI) software updates, new features, distribution and availability; 4. SPI-NOTES, for discussion of problems and solutions regarding the use of SPI products. Our mailing lists are managed by a public domain software package called ListProcessor, which ignores E-mail header subject lines. To subscribe (add yourself) to one of our mailing lists, send the following request as the E-mail message body, substituting CIAC-BULLETIN, CIAC-NOTES, SPI-ANNOUNCE or SPI-NOTES for list-name and valid information for LastName FirstName and PhoneNumber when sending E-mail to ciac-listproc@llnl.gov: subscribe list-name LastName, FirstName PhoneNumber e.g., subscribe ciac-notes OHara, Scarlett W. 404-555-1212 x36 You will receive an acknowledgment containing address, initial PIN, and information on how to change either of them, cancel your subscription, or get help. 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 by sending email to docserver@first.org with an empty subject line and a message body containing the line: send first-contacts. 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) G-21: Vulnerabilities in PCNFSD Program G-22: rpc.statd Vulnerability G-23: Solaris NIS+ Configuration Vulnerability G-24: FreeBSD Security Vulnerabilities G-25: SUN statd Program Vulnerability G-26: IRIX Desktop Permissions Panel Vulnerability G-27: SCO Kernel Security Vulnerability G-28A: suidperl Vulnerability G-29: dip Program Vulnerability G-30: DEC Software Security Kits RECENT CIAC NOTES ISSUED (Previous Notes available from CIAC) Notes 07 - 3/29/95 A comprehensive review of SATAN Notes 08 - 4/4/95 A Courtney update Notes 09 - 4/24/95 More on the "Good Times" virus urban legend Notes 10 - 6/16/95 PKZ300B Trojan, Logdaemon/FreeBSD, vulnerability in S/Key, EBOLA Virus Hoax, and Caibua Virus Notes 11 - 7/31/95 Virus Update, Hats Off to Administrators, America On-Line Virus Scare, SPI 3.2.2 Released, The Die_Hard Virus Notes 12 - 9/12/95 Securely configuring Public Telnet Services, X Windows, beta release of Merlin, Microsoft Word Macro Viruses, Allegations of Inappropriate Data Collection in Win95 Notes 96-01 - 3/18/96 Java and JavaScript Vulnerabilities, FIRST Conference Announcement, Security and Web Search Engines, Microsoft Word Macro Virus Update