CERT-SEI

Vulnerability in rlogin/term

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

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

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.

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).

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




I. Description

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:

"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."

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.

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.

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.

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:
"The server checks the client's source port. If the port is not in the range 0-1023, the server aborts the connection."

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.

II. Impact

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

III. Solution

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.

A. Obtain and install a patch for this problem.

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.

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

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

1. Turn off rlogin.

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

% chmod 0 /usr/bin/rlogin

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

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.

2. Replace the rlogin program with a wrapper.

We have written a prototype wrapper that is available at

ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c

The PGP signature for this file is available at

ftp://ftp.cert.org/pub/tools/rlogin_wrapper/rlogin_wrapper.c.asc

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

% pgp rlogin_wrapper.c.asc rlogin_wrapper.c

Notes:

  • You may have to change this program to get it to compile and work correctly on your system.
  • 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.

Appendix A - Vendor Information

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.

Berkeley Software Design, Inc. (BSDI)

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 patches@BSDI.COM mail server or via anonymous ftp at:

ftp://ftp.bsdi.com/bsdi/patches/patches-2.1/U210-021

Cray Research - A Silicon Graphics Company

This problem has been corrected in all currently supported versions of Unicos.

Cygnus Solutions (formerly Cygnus Support)

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

KerbNet Security System (our product based on Kerberos V5) all releases are not vulnerable.
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.

Data General Corporation

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.

Digital Equipment Corporation

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

rlogin patches are available for:

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

DIGITAL EQUIPMENT CORPORATION

FreeBSD, Inc.

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.

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.

Index: rlogin.c

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]);


Hewlett-Packard Corporation

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

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

http://us-support.external.hp.com (for US, Canada, Asia-Pacific, & Latin-America)

http://europe-support.external.hp.com (for Europe)

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.

IBM Corporation

See the appropriate release below to determine your action.

AIX 3.2

Apply the following fix to your system:

APAR - IX57724 (PTF - U442613)

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

lslpp -lB U442613

AIX 4.1

Apply the following fix to your system:

APAR - IX57972

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

instfix -ik IX57972

Or run the following command:

lslpp -h bos.net.tcp.client

Your version of bos.net.tcp.client should be 4.1.4.13 or later.

AIX 4.2

No APAR required. Fix already contained in the release.

To Order

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

http://service.software.ibm.com/aixsupport/

or send e-mail to aixserv@austin.ibm.com with a subject of "FixDist".

IBM and AIX are registered trademarks of International Business Machines Corporation.

Linux Systems

Only very out of date Linux systems are vulnerable.

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.

NetKit 0.09 is available from:

ftp://ftp.uk.linux.org/pub/linux/Networking/base/NetKit-0.09.tar.gz

NCR Corporation

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.

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:

       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.

NEC Corporation

UX/4800
EWS-UX/V(Rel4.2MP)
EWS-UX/V(Rel4.2)
UP-UX/V(Rel4.2MP)
EWS-UX/V(Rel4.0)
UP-UX/V
Not vulnerable for all versions.
Not vulnerable for all versions.
Not vulnerable for all versions.
Not vulnerable for all versions.
Not vulnerable for all versions.
Not vulnerable for all versions.

NetBSD

This was fixed in NetBSD some time ago, and is part of the 1.2 release.
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.

NeXT Software, Inc.

This problem is fixed in OpenStep/Mach release 4.1 and later.

The Open Group

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

The Santa Cruz Operation (SCO)

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 ftp://ftp.sco.COM/SLS/README.

Sun Microsystems, Inc.

The vulnerability in rlogin is fixed by the following patches:
    OS version   -       Patch ID

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

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


Copyright 1997 Carnegie Mellon University.


Revision History
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.