Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:933
HistoryNov 15, 2000 - 12:00 a.m.

Security Advisory: FreeBSD-SA-00:69.telnetd

2000-11-1500:00:00
vulners.com
5

-----BEGIN PGP SIGNED MESSAGE-----

=============================================================================
FreeBSD-SA-00:69 Security Advisory
FreeBSD, Inc.

Topic: telnetd allows remote system resource consumption.

Category: core
Module: telnetd
Announced: 2000-11-14
Credits: Jouko Pynnonen <[email protected]>
Affects: FreeBSD 3.x (all releases), FreeBSD 4.x (all releases prior
to 4.2), FreeBSD 3.5.1-STABLE and 4.1.1-STABLE prior
to the correction date.
Corrected: 2000-10-30 (FreeBSD 4.1.1-STABLE)
2000-11-01 (FreeBSD 3.5.1-STABLE)
FreeBSD only: NO

I. Background

telnetd is the server for the telnet remote login protocol.

II. Problem Description

The telnet protocol allows for UNIX environment variables to be passed
from the client to the user login session on the server. However, some
of these environment variables have special meaning to the telnetd
child process itself and may be used to affect its operation.

Of particular relevance is the ability for remote users to cause an
arbitrary file on the system to be searched for termcap data by
passing the TERMCAP environment variable. Although any file on the
local system can be read since the telnetd server runs as root, the
contents of the file will not be reported in any way to the remote
user unless it contains a valid termcap entry, in which case the
corresponding termcap sequences will be used to format the output sent
to the client. It is believed there is no risk of data disclosure
through this vulnerability.

However, an attacker who forces the server to search through a large
file or to read from a device can cause resources to be spent by the
server, including CPU cycles and disk read bandwidth, which can
increase the server load and may prevent it from servicing legitimate
user requests. Since the vulnerability occurs before the login(1)
utility is spawned, it does not require authentication to a valid
account on the server in order to exploit.

All released versions of FreeBSD prior to the correction date
including 4.0, 4.1, 4.1.1 and 3.5.1 are vulnerable to this problem,
but it was fixed in the 4.1.1-STABLE branch prior to the release of
FreeBSD 4.2-RELEASE.

III. Impact

Remote users without a valid login account on the server can cause
resources such as CPU and disk read bandwidth to be consumed, causing
increased server load and possibly denying service to legitimate
users.

IV. Workaround

1) Disable the telnet service, which is usually run out of inetd:
comment out the following lines in /etc/inetd.conf, if present.

telnet stream tcp nowait root /usr/libexec/telnetd telnetd

telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd

2) Impose access restrictions using TCP wrappers (/etc/hosts.allow),
or a network-level packet filter such as ipfw(8) or ipf(8) on the
perimeter firewall or the local machine, to limit access to the telnet
service to trusted machines.

V. Solution

One of the following:

1) Upgrade your vulnerable FreeBSD system to 4.1.1-STABLE or
3.5.1-STABLE after the respective correction dates.

2) Apply the patch below and recompile the relevant files:

Either save this advisory to a file, or download the patch and
detached PGP signature from the following locations, and verify the
signature using your PGP utility.

ftp://ftp.freebsd.org/pub/FreeBSD/CERT/patches/SA-00:69/telnetd.patch
ftp://ftp.freebsd.org/pub/FreeBSD/CERT/patches/SA-00:69/telnetd.patch.asc

Execute the following commands as root:

cd /usr/src/libexec/telnetd

patch -p < /path/to/patch_or_advisory

make depend && make all install

Patch for vulnerable systems:

Index: sys_term.c
===================================================================
RCS file: /mnt/ncvs/src/libexec/telnetd/sys_term.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- sys_term.c      1999/08/28 00:10:24     1.24
+++ sys_term.c      2000/10/31 05:29:54     1.25
@@ -1799,6 +1799,13 @@
                strncmp&#40;*cpp, &quot;_RLD_&quot;, 5&#41; &amp;&amp;
                strncmp&#40;*cpp, &quot;LIBPATH=&quot;, 8&#41; &amp;&amp;
 #endif
+               strncmp&#40;*cpp, &quot;LOCALDOMAIN=&quot;, 12&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;RES_OPTIONS=&quot;, 12&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;TERMINFO=&quot;, 9&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;TERMINFO_DIRS=&quot;, 14&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;TERMPATH=&quot;, 9&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;TERMCAP=/&quot;, 9&#41; &amp;&amp;
+               strncmp&#40;*cpp, &quot;ENV=&quot;, 4&#41; &amp;&amp;
                strncmp&#40;*cpp, &quot;IFS=&quot;, 4&#41;&#41;
                    *cpp2++ = *cpp;
    }
Index: telnetd.c
===================================================================
RCS file: /mnt/ncvs/src/libexec/telnetd/telnetd.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- telnetd.c       2000/01/25 14:52:00     1.22
+++ telnetd.c       2000/10/31 05:29:54     1.23
@@ -811,7 +811,7 @@
                    fatal&#40;net, &quot;Out of ptys&quot;&#41;;
 
            if &#40;&#40;pty = open&#40;lp, 2&#41;&#41; &gt;= 0&#41; {
-                   strcpy&#40;line,lp&#41;;
+                   strlcpy&#40;line,lp,sizeof&#40;line&#41;&#41;;
                    line[5] = &#39;t&#39;;
                    break;
            }
@@ -1115,7 +1115,7 @@
            IM = Getstr&#40;&quot;im&quot;, &amp;cp&#41;;
            IF = Getstr&#40;&quot;if&quot;, &amp;cp&#41;;
            if &#40;HN &amp;&amp; *HN&#41;
-                   &#40;void&#41; strcpy&#40;host_name, HN&#41;;
+                   &#40;void&#41; strlcpy&#40;host_name, HN, sizeof&#40;host_name&#41;&#41;;
            if &#40;IF &amp;&amp; &#40;if_fd = open&#40;IF, O_RDONLY, 000&#41;&#41; != -1&#41;
                    IM = 0;
            if &#40;IM == 0&#41;
Index: utility.c
===================================================================
RCS file: /mnt/ncvs/src/libexec/telnetd/utility.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- utility.c       1999/08/28 00:10:25     1.13
+++ utility.c       2000/10/31 05:29:54     1.14
@@ -330,7 +330,7 @@
 {
    char buf[BUFSIZ];
 
-   &#40;void&#41; sprintf&#40;buf, &quot;telnetd: &#37;s.&#92;r&#92;n&quot;, msg&#41;;
+   &#40;void&#41; snprintf&#40;buf, sizeof&#40;buf&#41;, &quot;telnetd: &#37;s.&#92;r&#92;n&quot;, msg&#41;;
    &#40;void&#41; write&#40;f, buf, &#40;int&#41;strlen&#40;buf&#41;&#41;;
    sleep&#40;1&#41;;       /*XXX*/
    exit&#40;1&#41;;
@@ -343,7 +343,7 @@
 {
    char buf[BUFSIZ], *strerror&#40;&#41;;
 
-   &#40;void&#41; sprintf&#40;buf, &quot;&#37;s: &#37;s&quot;, msg, strerror&#40;errno&#41;&#41;;
+   &#40;void&#41; snprintf&#40;buf, sizeof&#40;buf&#41;, &quot;&#37;s: &#37;s&quot;, msg, strerror&#40;errno&#41;&#41;;
    fatal&#40;f, buf&#41;;
 }

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (FreeBSD)
Comment: For info see http://www.gnupg.org

iQCVAwUBOhG9KFUuHi5z0oilAQHUZwP/Xmo3EDteE4HwZovAO6UFzNtc3xVsFaUr
Thf5XvpPThIOKmyYsUOL/kRbfnU3vJUdPA21uDYKyUEil5+x8+ZAuDzJXfMxHwu8
MMD1/d5QFfvuWN5W+/msdT7XKEjTmm4f09/tMxRAEyIMeKRj2H4gWxEGmaivJtvT
6bFKtbsSW1Q=
=UltL
-----END PGP SIGNATURE-----

To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-security" in the body of the message