Date: Tue, 10 Apr 2001 16:43:46 +1000
From: NetBSD Security Officer <security-officer@netbsd.org.>
To: [email protected]Subject: NetBSD Security Advisory 2001-005; ftpd remote buffer overflow
--DocE+STaALJfprDB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
--DocE+STaALJfprDB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="NetBSD-SA2001-005.txt"
-----BEGIN PGP SIGNED MESSAGE-----
NetBSD Security Advisory 2001-005
Topic: Ftpd denial of service and remote buffer overflow
Version: NetBSD 1.4, 1.5, -current
Severity: Remote root compromise
Fixed: NetBSD-current: April 03, 2001
NetBSD-1.5 branch: April 04, 2001
NetBSD-1.4 branch: April 04, 2001
Abstract
========
A recent COVERT Labs Security Advisory (COVERT-2001-02) describes
a remote denial of service and buffer overrun that COVERT Labs
discovered in the glob(3) library function. This function is called
by the ftp server daemon (ftpd), and therefore the ftp server is
vulnerable to this attack.
Systems running ftpd are vulnerable.
ftpd is usually started from inetd; inetd is configured through
the /etc/inetd.conf file.
As of the release date of this advisory, all past NetBSD releases,
including NetBSD 1.5, are vulnerable.
Fresh installs of NetBSD 1.5 are not vulnerable as ftpd is disabled
by default in /etc/inetd.conf; however, a system upgraded from an
earlier release to 1.5 may still be using an old inetd.conf with
ftpd still enabled, or it may need to run an ftp server and will
thus have it enabled.
Technical Details
=================
The glob(3) library function in the C library (libc) had two problems:
* There was no limit placed on the number of matches returned.
This vulnerability could lead to a remote denial of service
against the service or the machine running the service when
certain glob patterns are provided that result in the calling
process consuming RAM, CPU, and disk I/O in building the pattern.
* It used a stack-based buffer for storing pathnames, and the
data transfers to this buffer did not enforce the end of
buffer boundary.
This vulnerability could lead to remote root compromise,
through execution of arbitrary code in an overflowed buffer.
Solutions and Workarounds
All NetBSD official releases up to 1.5, have a vulnerable glob
function in libc, and a vulnerable ftp server binary in /usr/libexec/ftpd.
You should replace it to fix the problem.
If you do not run ftpd on your system, your system is not vulnerable.
Check /etc/inetd.conf to see if you have a line that starts with
"ftp". In any event, we suggest you apply the fix, in case you want
to run ftpd in the future. Note that NetBSD 1.5 does not run ftpd
by default (/etc/inetd.conf has a commented-out "ftp" line).
There are several ways that systems administrators may update their
versions of the C library and the ftp server. Each of these
mechanisms is described in more detail in the following subsections.
* System upgrade via source
* Replace the system ftpd with one from the NetBSD Packages collection.
Updating via source:
Users may update their system source, from the appropriate release
branch or NetBSD-current, and rebuild the C library and the ftp
server (as well as other parts of the system).
This method is recommended for users of NetBSD-current and
technically literate users of the most recent releases on each
branch (1.4.3 or 1.5).
Note that the NetBSD release branches contain accumulated changes
and bugfixes since the most recent release; these changes are
intended to improve the system, but have not yet been through the
complete release engineering cycle. Users who wish to remain at a
formal release should use the pkgsrc method instead.
System sources can be updated via anonymous CVS, SUP, or via
download of source tarfiles from the appropriate branch,
collection or directory:
Release CVS branch SUP collection FTP directory
-------------------------------------------------------------------
1.4 netbsd-1-4 release-1-4 /pub/NetBSD/NetBSD-release-1-4
1.5 netbsd-1-5 release-1-5 /pub/NetBSD/NetBSD-release-1-5
current HEAD current /pub/NetBSD/NetBSD-current
Systems running NetBSD-current dated from before 2001-04-04 should
be upgraded to NetBSD-current dated 2001-04-04 or later. For
NetBSD-current, see /usr/src/UPDATING for additional instructions,
as additional dependencies may need to be rebuilt before libc and
ftpd.
Systems running the NetBSD 1.5 release branch dated from before
2001-04-05 should be upgraded to 2001-04-05 or later.
Systems running the NetBSD 1.4 release branch dated from before
2001-04-05 should be upgraded to 2001-04-05 or later.
It is recommended that users tracking inter-release sources do a
full system update. Once sources and dependencies have been taken
care of, the following will rebuild *just* libc and ftpd:
# cd /usr/src/include
# make includes
# cd /usr/src/lib/libc
# make depend
# make
# make install
# cd /usr/src/libexec/ftpd
# make depend
# make
# make install
Updating via pkgsrc:
For many users looking for a quick and specific update, the NetBSD
packages collection provides a simple mechanism to install a
current version of NetBSD's ftpd that has been made portable to
older NetBSD releases and other operating systems, to replace the
system version.
This technique is applicable to ALL systems, and is recommended
for urgent fixes. It may be used as a temporary measure even by
those intending to follow up with a full system upgrade.
1) First, make sure you have an up-to-date pkgsrc collection (at
least as recent as 2001-04-05). This can be obtained via
anonymous CVS, SUP or FTP from the project servers or mirrors.
2) Change to the appropriate subdirectory:
# cd /usr/pkgsrc/net/lukemftpd
3) Ensure that the pkgsrc version is 1.0 or newer:
# grep PKGNAME Makefile
PKGNAME= lukemftpd-1.0
4) Build and install the package. This will download the sources
automatically. (If prompted to update the pkg tools first, do
so according to the instructions presented, then return to the
lukemftpd directory and resume here).
# make install
Now you have an up-to-date version of ftpd installed in /usr/pkg.
5) Next, it is necessary to use the new ftpd instead of the system one.
Edit /etc/inetd.conf and change the path in any entries for "ftp"
from "/usr/libexec/ftpd" to "/usr/pkg/libexec/ftpd". Notify inetd
to reload its config file with:
# kill -1 `cat /var/run/inetd.pid`
Pre-compiled binary packages of net/lukemftpd have been prepared for
some architectures and NetBSD versions. These can be found under
ftp://ftp.netbsd.org/pub/NetBSD/packages
You may wish to use one of these instead of having the pkgsrc
system compile for you. Download the appropriate file for your
system if available, and use:
# pkg_add lukemftpd-1.0
to install the pre-built package. Then follow the steps from 5
above to use the new ftpd instead of the system ftpd.
Thanks To
=========
COVERT Labs for bringing this problem to our attention.
Christos Zoulas for the glob(3) fixes, and the corresponding changes
to the ftp server, and Luke Mewburn for providing the `lukemftpd'
portable version of the ftp server.
Revision History
================
2001-04-10 Initial release
More Information
================
Information about NetBSD and NetBSD security can be found at:
http://www.NetBSD.ORG/ and http://www.NetBSD.ORG/Security/
COVERT Labs Security Advisory COVERT-2001-02, "Globbing
Vulnerabilities in Multiple FTP Daemons" is available at:
http://www.pgp.com/research/covert/advisories/048.asp
Copyright 2001, The NetBSD Foundation, Inc. All Rights Reserved.
$NetBSD: NetBSD-SA2001-005.txt,v 1.7 2001/04/10 06:32:20 lukem Exp $
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (NetBSD)
Comment: For info see http://www.gnupg.org
iQCUAwUBOtKpGj5Ru2/4N2IFAQFIYAP402v6dtw9Yi8/iyzqfAinh6R5Uq685tbB
1MLXClU7AK/WdyrWT2W3sMgcap+13e5QQBR20UUmLVmicGliEzNg0frhETaFgH6s
zF8p7a/WbjFFwCms7X6rVyU8j4nOXSJY27KaOwCL3LMgIkxTYN/iiR/KP2aEzoXM
K+5LXclZXQ==
=YPEj
-----END PGP SIGNATURE-----
--DocE+STaALJfprDB--