Original issue date: February 6, 1997<BR>
Last revised: February 12, 1998<BR>
Added vendor information for NCR Corporation.<BR>
November 14, 1997  Added vendor information for Data General Corporation.

<P>A complete revision history is at the end of this file.

<P>The CERT Coordination Center has received reports of a
vulnerability in many implementations of the rlogin program, including
eklogin and klogin.  By exploiting this vulnerability, users with
access to an account on the system can cause a buffer overflow and
execute arbitrary programs as root.

<P>The CERT/CC staff recommends installing a vendor patch for this
problem (Sec. III.A). Until you can do so, we urge you to turn off
rlogin or replace it with a wrapper (see Sec. III.B.2). </P>

<P>We will update this advisory as we receive additional
information. Please check advisory files regularly for updates that
relate to your site.

<P>
<HR></P>

<H2>I. Description</H2>

<P>The rlogin program provided by many UNIX systems, as well as some
non-UNIX systems, is described in RFC 1282. Here is an excerpt from
that RFC that describes its elemental functionality:

<P>&quot;The rlogin facility provides a remote-echoed, locally flow-
controlled virtual terminal with proper flushing of output. It is
widely used between Unix hosts because it provides transport of more
of the Unix terminal environment semantics than does the Telnet
protocol, and because on many Unix hosts it can be configured not to
require user entry of passwords when connections originate from
trusted hosts.&quot; </P>

<P>The key point from this description is that the rlogin program
passes the terminal type description from the local host to the remote
host. This functionality allows terminal-aware programs such as
full-screen text editors to operate properly across a
computer-to-computer connection created with rlogin. </P>

<P>To do this, the rlogin program uses the current terminal definition
as identified by the TERM environment variable. The protocol described
in RFC 1282 explains how this terminal information is transferred from
the local machine where the rlogin client program is running to the
remote machine where service is sought. </P>

<P>Unfortunately, many implementations of the rlogin program contain a
defect whereby the value of the TERM environment variable is copied to
an internal buffer without due care. The buffer holding the copied
value of TERM can be overflowed. In some implementations, the buffer
is a local variable, meaning that the subroutine call stack can be
overwritten and arbitrary code executed. The executed code is under
the control of the user running the rlogin program. </P>

<P>In addition, the rlogin program is set-user-id root. rlogin
requires these increased privileges so it can allocate a port in the
required range, as described in the in.rlogind (or rlogind) manual
page: <BR> &quot;The server checks the client's source port. If the
port is not in the range 0-1023, the server aborts the
connection.&quot; </P>

<P>In summary, rlogin is a set-user-id root program that in many
implementations contains a programming defect whereby an internal
buffer can be overflowed and arbitrary code can be executed as
root. </P>

<H2>II. Impact</H2>

<P>Users can become root if they have access to an account on the
system.

<H2>III. Solution</H2>

<P>Install a patch from your vendor if one is available (Section
A). Until you can take one of those actions, we recommend applying the
workaround described in Section B.

<H3>A. Obtain and install a patch for this problem.</H3>

<P>Below is a list of vendors who have provided information about
rlogin.  Details are in Appendix A of this advisory; we will update
the appendix as we receive more information. If your vendor's name is
not on this list, the CERT/CC did not hear from that vendor. Please
contact your vendor directly.

<P>Berkeley Software Design, Inc. (BSDI)<BR>
Cray Research - A Silicon Graphics Company<BR>
Cygnus Solutions (formerly Cygnus Support)<BR>
Data General Corporation <BR>
Digital Equipment Corporation<BR>
FreeBSD, Inc.<BR>
Hewlett-Packard Corporation<BR>
IBM Corporation<BR>
Linux Systems<BR>
NCR Corporation<BR>
NEC Corporation<BR>
NetBSD<BR>
NeXT Software, Inc.<BR>
The Open Group<BR>
The Santa Cruz Operation (SCO)<BR>
Sun Microsystems, Inc. <BR>
</P>

<H3>B. Until you are able to install the appropriate patch, we recommend one of the following workarounds: </H3>

<H4>1. Turn off rlogin.</H4>

<P>If your user community does not use rlogin, turn it off. As root, do
the following: </P>

<P>% chmod 0 /usr/bin/rlogin </P>

<P>You may find the rlogin program in some other directory on your system.
Example directories are: /bin, /usr/bin, /usr/ucb.</P>

<P>Note: On some systems, rlogin is provided in different forms that do
additional work. Examples are eklogin (kerberos authentication plus encryption
of the data stream) and klogin (kerberos authentication only). These, too,
need to be turned off. </P>

<H4>2. Replace the rlogin program with a wrapper.</H4>

<P>We have written a prototype wrapper that is available at </P>

<P><A HREF="ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c">ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c</A></P>

<P>The PGP signature for this file is available at </P>

<P><A HREF="ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c.asc">ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c.asc</A>
</P>

<P>To verify that this file is correct, fetch both the rlogin_wrapper.c
and rlogin_wrapper.c.asc files and check the signature with pgp as in </P>

<P>% pgp rlogin_wrapper.c.asc rlogin_wrapper.c </P>

<P>Notes:
</P>

<UL>
<LI>You may have to change this program to get it to compile and work correctly
on your system. </LI>

<LI>If you have different forms of rlogin, as noted in the previous section,
then you will need to replace those forms with the wrapper as well. </LI>
</UL>

<P>
<HR WIDTH="100%"


<H2>Appendix A - Vendor Information</H2>


Below is a list of the vendors who have provided information for this advisory.
We will update this appendix as we receive additional information. If you
do not see your vendor's name, the CERT/CC did not hear from that vendor.
Please contact the vendor directly. 

<H3>Berkeley Software Design, Inc. (BSDI)</H3>


Unpatched BSD/OS 2.1 systems are vulnerable to this problem. A patch was
issued that resolved this problem in August 1996. The patch is available
from the <A HREF="mailto:patches@BSDI.COM">patches@BSDI.COM</A>
mail server or via anonymous ftp at:

<P><A HREF="ftp://ftp.bsdi.com/bsdi/patches/patches-2.1/U210-021">ftp://ftp.bsdi.com/bsdi/patches/patches-2.1/U210-021</A>


<H3>Cray Research - A Silicon Graphics Company</H3>

<P>This problem has been corrected in all currently supported versions
of Unicos. </P>

<H3>Cygnus Solutions (formerly Cygnus Support)</H3>


CNS (our product based on Kerberos V4) all releases are not vulnerable.


<P>KerbNet Security System (our product based on Kerberos V5) all releases
are not vulnerable. <BR>
Since our version of rlogin is not installed set-user-id root, it is not
vulnerable. To secure a machine which is running our rlogin, all that is
necessary is to secure the vendor rlogin. </P>

<H3>Data General Corporation</H3>

        
The rlogin program included in DG/UX revisions prior to
R4.12/R4.11MU03 do contain this vulnerability. This problem
has been fixed in the rlogin program released with DG/UX
revisions R4.12/R4.11MU03 and later.


<H3>Digital Equipment Corporation</H3>


At the time of writing this document, patches(binary kits) are available
from your normal Digital Support Channel. 

<P>rlogin patches are available for:</P>

<P>DIGITAL UNIX V3.2c, V3.2de1/de2, V3.2g, V3.2g, V4.0, V4.0a, V4.0b. DIGITAL
ULTRIX V4.4 VAX &amp; MIPS, V4.5 VAX and MIPS </P>

<P>DIGITAL EQUIPMENT CORPORATION


<H3>FreeBSD, Inc.</H3>


This vulnerability is present in FreeBSD 2.1.5 and previous versions. It
was fixed in all FreeBSD source and binary distributions dated after 1996/07/25.

<P>The following source code patch may be applied to FreeBSD 2.1.5 based
distributions, and should work in previous distributions. Users unable
to apply this patch and recompile the rlogin binary are encouraged to use
the wrapper provided by CERT. </P>

<H3>Index: rlogin.c</H3>

<PRE>
RCS file: /home/ncvs/src/usr.bin/rlogin/rlogin.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -c -r1.5.4.1 -r1.5.4.2
*** rlogin.c    1996/06/23 13:08:27     1.5.4.1
- --- rlogin.c    1996/07/25 18:29:35     1.5.4.2
***************
*** 102,107 ****
- --- 102,108 ----
  char *speeds[] = {
        "0", "50", "75", "110", "134", "150", "200", "300", "600", "1200",
        "1800", "2400", "4800", "9600", "19200", "38400", "57600", "115200"
+ #define       MAX_SPEED_LENGTH        (sizeof("115200") - 1)
  };

  #ifdef OLDSUN
***************
*** 259,265 ****
                exit(1);
        }

!       (void)strcpy(term, (p = getenv("TERM")) ? p : "network");
        if (ioctl(0, TIOCGETP, &ttyb) == 0) {
                (void)strcat(term, "/");
                (void)strcat(term, speeds[(int)ttyb.sg_ospeed]);
- --- 260,270 ----
                exit(1);
        }

! #define       MAX_TERM_LENGTH (sizeof(term) - 1 - MAX_SPEED_LENGTH - 1)
!
!       (void)strncpy(term, (p = getenv("TERM")) ? p : "network",
!                     MAX_TERM_LENGTH);
!       term[MAX_TERM_LENGTH] = '\0';
        if (ioctl(0, TIOCGETP, &ttyb) == 0) {
                (void)strcat(term, "/");
                (void)strcat(term, speeds[(int)ttyb.sg_ospeed]);


</PRE>

<H3>Hewlett-Packard Corporation</H3>

For updated information, please refer to the Hewlett-Packard Security
Bulletin &quot;Security Vulnerability with rlogin,&quot; Document ID: HPSBUX9707-066.


<P>Use your browser to get to the HP Electronic Support Center page at:


<P><A HREF="http://us-support.external.hp.com">http://us-support.external.hp.com</A>
(for US, Canada, Asia-Pacific, &amp; Latin-America) </P>

<P><A HREF="http://europe-support.external.hp.com">http://europe-support.external.hp.com</A>
(for Europe) </P>

<P>Click on the Technical Knowledge Database, register as a user (remember
to save the User ID assigned to you, and your password), and it will connect
to a HP Search Technical Knowledge DB page. Near the bottom is a hyperlink
to our Security Bulletin archive. Once in the archive there is another
link to our current security patch matrix. Updated daily, this matrix is
categorized by platform/OS release, and by bulletin topic. </P>

<H3>IBM Corporation</H3>


See the appropriate release below to determine your action. 
<H4>AIX 3.2</H4>

Apply the following fix to your system: 

<P>APAR - IX57724 (PTF - U442613) </P>

<P>To determine if you have this PTF on your system, run the following
command: </P>

<P>lslpp -lB U442613 </P>

<H4>AIX 4.1</H4>

Apply the following fix to your system: 

<P>APAR - IX57972 </P>

<P>To determine if you have this APAR on your system, run the following
command: </P>

<P>instfix -ik IX57972 </P>

<P>Or run the following command: </P>

<P>lslpp -h bos.net.tcp.client </P>

<P>Your version of bos.net.tcp.client should be 4.1.4.13 or later. </P>

<H4>AIX 4.2</H4>
No APAR required. Fix already contained in the release. 

<H4>To Order</H4>

APARs may be ordered using Electronic Fix Distribution (via FixDist)
or from the IBM Support Center. For more information on FixDist: 

<P><A HREF="http://service.software.ibm.com/aixsupport/">http://service.software.ibm.com/aixsupport/</A>
</P>


or send e-mail to <A HREF="mailto:aixserv@austin.ibm.com">aixserv@austin.ibm.com</A>
with a subject of &quot;FixDist&quot;. 

<P>IBM and AIX are registered trademarks of International Business Machines
Corporation. </P>

<H3>Linux Systems</H3>

Only very out of date Linux systems are vulnerable. 

<P>Linux Netkit 0.08 has rlogin fixed. All Linux systems using older NetKits
should upgrade to NetKit 0.09. Some vendors have shipped patched Netkit-0.08
releases. Check with your vendor for confirmation. </P>

<P>NetKit 0.09 is available from: </P>

<P><A HREF="ftp://ftp.uk.linux.org/pub/linux/Networking/base/NetKit-0.09.tar.gz">ftp://ftp.uk.linux.org/pub/linux/Networking/base/NetKit-0.09.tar.gz</A>
</P>

<H3>NCR Corporation</H3>
NCR is delivering a set of operating system dependent patches which contain
an update for this problem .  Accompanying each patch is a README file which 
discusses the general purpose of the patch and describes how to apply it to 
your system.
 
<P>Recommended solution:
Apply one of the following patches depending on the revision of the inet 
package installed on your system. To check its version execute:
 
<PRE>       pkginfo -x inet
 
   For inet 5.01: - PINET501 (Version 5.01.01.25)
   
   For inet 6.01: - PINET610 (Version 6.01.00.17)
 
   For inet 6.02: - Fix included.
</PRE>

<H3>NEC Corporation</H3>

<TABLE CELLSPACING=0 CELLPADDING=0 >
<TR>
<TD>UX/4800<BR>
EWS-UX/V(Rel4.2MP)<BR>
EWS-UX/V(Rel4.2)<BR>
UP-UX/V(Rel4.2MP)<BR>
EWS-UX/V(Rel4.0)<BR>
UP-UX/V <BR>
</TD>

<TD>Not vulnerable for all versions.<BR>
Not vulnerable for all versions.<BR>
Not vulnerable for all versions.<BR>
Not vulnerable for all versions.<BR>
Not vulnerable for all versions.<BR>
Not vulnerable for all versions.<BR>
</TD>
</TR>
</TABLE>

<H3>NetBSD</H3>


This was fixed in NetBSD some time ago, and is part of the 1.2 release.
<BR>
NetBSD 1.1 and prior are vulnerable to this, and the best solution is to
upgrade, or at least obtain new src/usr.bin/rlogin source and recompile.



<H3>NeXT Software, Inc.</H3>


This problem is fixed in OpenStep/Mach release 4.1 and later. 
<H3>The Open Group</H3>


This problem was fixed in OSF's OSF/1 R1.3.3 maintenance release. <BR>


<H3>The Santa Cruz Operation (SCO)</H3>


SCO is investigating this problem and should a patch be necessary, SCO
will provide updated information for this advisory. Patches for SCO products
are listed at <A HREF="ftp://ftp.sco.COM/SLS/README">ftp://ftp.sco.COM/SLS/README</A>.


<H3>Sun Microsystems, Inc.</H3>


 The vulnerability in rlogin is fixed by the following patches:
 <PRE>
   <B> OS version   -       Patch ID</B>

    SunOS 5.5.1       -  104650-02<BR>
    SunOS 5.5.1_x86   -  104651-02<BR>
    SunOS 5.5         -  104669-02<BR>
    SunOS 5.5_x86     -  104670-02<BR>
    SunOS 5.4         -  105254-10<BR>
    SunOS 5.4_x86     -  105255-01<BR>
    SunOS 5.3         -  105253-01<BR>
    SunOS 4.1.4       -  105260-01<BR>
    SunOS 4.1.3_U1    -  105259-01
</PRE>

<P><HR>

<P>The CERT Coordination Center staff thanks AUSCERT and DFN-CERT for their
contributions to the development of this advisory.</P>

<P><HR>

<!--#include virtual="/include/footer_nocopyright.html" -->
<P>Copyright 1997 Carnegie Mellon University.</P>

<HR>

Revision History
<PRE>
Feb. 12, 1998  Added vendor information for NCR Corporation.

Nov. 14, 1997 Added vendor information for Data General Corporation.

Oct. 30, 1997 Updated vendor information for Sun.

Sep. 26, 1997 Updated copyright statement

July 28, 1997 Appendix A - updated Hewlett-Packard information.

Feb. 11, 1997 Appendix A - added entries for Cygnus Solutions, NetBSD, and Sun
              Microsystems.
</PRE>