-----BEGIN PGP SIGNED MESSAGE----- =============================================================================== Security Advisory CERT-NL =============================================================================== Author/Source : Rene Ritzen Index : S-96-33 Distribution : World Page : 1 Classification: External Version: 1 Subject : Vendor Initiated Bulletin: FreeBSD sec. compDate : 08-jul-96 =============================================================================== By courtesy of FreeBSD Inc. we received information on a vulnerability in the PPP-module which allows a user to run programs under root privilege. FreeBSD Inc. urges you to act on this information as soon as possible. FreeBSD Inc. contact information is included in the forwarded text below; please contact them if you have any questions or need futher information. CERT-NL recommends to implement the provided patch. ============================================================================== FreeBSD-SA-96:15 Security Advisory FreeBSD, Inc. Topic: security compromise from ppp Category: core Module: ppp Announced: 1996-06-25 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 @@ -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 @@ -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); ============================================================================= 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. ============================================================================= CERT-NL is the Computer Emergency Response Team for SURFnet customers. SURFnet is the Dutch network for educational, research and related institutes. CERT-NL is a member of the Forum of Incident Response and Security Teams (FIRST). All CERT-NL material is available under: http://www.surfnet.nl/surfnet/security/cert-nl.html ftp://ftp.surfnet.nl/surfnet/net-security In case of computer or network security problems please contact your local CERT/security-team or CERT-NL (if your institute is NOT a SURFnet customer please address the appropriate (local) CERT/security-team). CERT-NL is one/two hour(s) ahead of UTC (GMT) in winter/summer, i.e. UTC+0100 in winter and UTC+0200 in summer (DST). Email: cert-nl@surfnet.nl Phone: +31 302 305 305 Fax: +31 302 305 329 Snailmail: SURFnet bv Attn. CERT-NL P.O. Box 19035 NL - 3501 DA UTRECHT The Netherlands A 7 * 24 hours phone number is available to SURFnet SSC's and FIRST members on request. ============================================================================== -----BEGIN PGP SIGNATURE----- Version: 2.6.i iQCVAgUBMeD/bmL2fnkJN/jpAQH/mgQApeZZRSreh2Y1rtlid3B9IAuAdV5mNrrD WH+bfEUHP8GYJzHpyMOHohSBtJSvTtCIA0MG16eMTVZsMoxDNPmUdXJ06MWqxhac X/QYIDquPnKqV7F/IFsCBSE7vi/JZbr3965rbACaK0a3v7bs5kX1eg9ugcNbFB25 FNaQQ9y+ALY= =pxIX -----END PGP SIGNATURE----- -- End --