copyright | disclaimer | privacy | contact  
Australia's Leading Computer Emergency Response Team
 
Search this site

 
On this site

 > HOME
 > About AusCERT
 > Membership
 > Contact Us
 > PKI Services
 > Training
 > Publications
 > Sec. Bulletins
 > Conferences
 > News & Media
 > Services
 > Web Log
 > Site Map
 > Site Help
 > Member login





 

ESB-2006.0916 -- [Win][UNIX/Linux][NetBSD] -- libc glob(3) buffer overflow

Date: 15 December 2006

Click here for printable version
Click here for PGP verifiable version
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

===========================================================================
             AUSCERT External Security Bulletin Redistribution

                ESB-2006.0916 -- [Win][UNIX/Linux][NetBSD]
                       libc glob(3) buffer overflow
                             15 December 2006

===========================================================================

        AusCERT Security Bulletin Summary
        ---------------------------------

Product:              libc glob(3)
Publisher:            NetBSD
Operating System:     NetBSD
                      UNIX variants (UNIX, Linux, OSX)
                      Windows
Impact:               Execute Arbitrary Code/Commands
Access:               Remote/Unauthenticated

Original Bulletin:
  ftp://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2006-027.txt.asc

- --------------------------BEGIN INCLUDED TEXT--------------------

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


		 NetBSD Security Advisory 2006-027
		 =================================

Topic:		libc glob(3) buffer overflow

Version:	NetBSD-current:	source prior to September 13, 2005
		NetBSD 4.0_BETA2:	not affected
		NetBSD 3.1:		affected
		NetBSD 3.0.*:		affected
		NetBSD 3.0:		affected
		NetBSD 2.1:		affected
		NetBSD 2.0.*:		affected
		NetBSD 2.0:		affected
		pkgsrc:			20040810 and earlier

Severity:	Potential remote root for systems providing the ftpd service
		with a custom configuration.

Fixed:		NetBSD-current:		September 13, 2005
		NetBSD-3-0 branch:	December 2, 2006
		NetBSD-3 branch:	December 2, 2006
		NetBSD-2-1 branch:	December 2, 2006
		NetBSD-2-0 branch:	December 2, 2006
		NetBSD-2 branch:	December 2, 2006
		pkgsrc:  		tnftpd-20040810nb1 corrects this issue


Abstract
========

A flaw in glob(3) could potentially allow for the execution of untrusted code.
Currently the NetBSD ftp daemon that ships with the base distribution uses 
glob(3) which has been found to be potentially vulnerable to attack.  In 
addition to this there may be other applications/network services which 
use glob(3) which are also potentially vulnerable.

In the case of ftpd the server must be configured to allow remote users
to create directories in order for attackers to exploit this issue.


Technical Details
=================

The limit computation of an internal buffer was done incorrectly.  The
size of the buffer in byte was used as element count, even though the
elements of the buffer are 2 bytes long.  Long expanded path names would
therefore overflow the buffer.


Solutions and Workarounds
=========================

* Determining if you could be vulnerable (inetd):
By default ftpd is not enabled in the default install of NetBSD.
To confirm if the host in question is running ftpd, check the ftp
entries in /etc/inetd.conf. By default, the entries look like this:

#ftp	stream	tcp	nowait	root	/usr/libexec/ftpd	ftpd -ll
#ftp	stream	tcp6	nowait	root	/usr/libexec/ftpd	ftpd -ll

If the comment character (#) has been removed from the start of the
lines, then ftpd has been enabled on this host. Hosts not running ftpd
are not vulnerable, but libc should be updated to prevent future
exposure if ftpd is enabled at a later date.

* Disable ftpd (inetd):
As root, comment out the ftp lines in /etc/inetd.conf, and execute the 
following command to disable ftpd:

	% /etc/rc.d/inetd reload

* Determining if you could be vulnerable (standalone):
On NetBSD-current it is also possible to run ftpd in standalone
mode by adding the following to rc.conf:

	ftpd=YES

If this entry exists then ftpd is being run in standalone mode.

* Disable ftpd (standalone):
As root, comment out the ftpd line in rc.conf, and execute the following
command to disable ftpd:

	% /etc/rc.d/ftpd forcestop

* Limit directory creation:
Another possible workaround is to not allow remote users to create 
directories of their choice on the ftpd server.

* Directory names:
If you allow users to create directories of their own choice check
for very long directory names.

* Drop root privileges:
As root, add -r to the command line options for any ftp entry in 
/etc/inetd.conf. Then run: 

	% /etc/rc.d/inetd reload 

This option may not be acceptable at all sites, since client compatibility 
issues are possible. See the ftpd(8) man page for more details about -r.

The following instructions describe how to upgrade your libc binaries 
by updating your source tree and rebuilding and installing a new version 
of libc.

* NetBSD-current:

	Systems running NetBSD-current dated from before 2005-09-13
	should be upgraded to NetBSD-current dated 2005-09-14 or later.

	The following files need to be updated from CVS HEAD:
		lib/libc/gen/glob.c

	To update from CVS, re-build, and re-install libc:

		# cd src
		# cvs update lib/libc/gen/glob.c
		# cd lib/libc
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install

		# cd ../../libexec/ftpd
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install


* NetBSD 3.*:

	Systems running NetBSD 3.* sources dated from before
	2006-12-02 should be upgraded from NetBSD 3.* sources dated
	2006-12-03 or later.

	The following files need to be updated from the
	netbsd-3, netbsd-3-0, netbsd-3-1 CVS branches:
		lib/libc/gen/__glob13.c

	To update from CVS, re-build, and re-install libc:

		# cd src
		# cvs update lib/libc/gen/__glob13.c
		# cd lib/libc
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install

		# cd ../../libexec/ftpd
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install


* NetBSD 2.*:

	Systems running NetBSD 2.* sources dated from before
	2006-12-02 should be upgraded from NetBSD 2.* sources dated
	2006-12-03 or later.

	The following files need to be updated from the
	netbsd-2, netbsd-2-0 or netbsd-2-1 CVS branches:
		lib/libc/gen/__glob13.c

	To update from CVS, re-build, and re-install libc:

		# cd src
		# cvs update lib/libc/gen/__glob13.c
		# cd lib/libc
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install

		# cd ../../libexec/ftpd
		# make USETOOLS=no cleandir dependall
		# make USETOOLS=no install


Thanks To
=========

Tomas Skare for reporting this issue and the initial analysis.


Revision History
================

	2006-12-14	Initial release


More Information
================

Advisories may be updated as new information becomes available.
The most recent version of this advisory (PGP signed) can be found at 
  ftp://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2006-027.txt.asc

Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.org/ and http://www.NetBSD.org/Security/.


Copyright 2006, The NetBSD Foundation, Inc.  All Rights Reserved.
Redistribution permitted only in full, unmodified form.

$NetBSD: NetBSD-SA2006-027.txt,v 1.4 2006/12/14 20:13:16 adrianp Exp $

- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iQCVAwUBRYGx2T5Ru2/4N2IFAQJbLAQAhHlwMkZdBnPhI2hFnp89DkfXvrDDQF8h
i0R4kO1BpLLFUmFfwNyQeNbRPLvfO6L5XNXMo03xAoXvbm/idhcIBXc14aysP1zG
g9HnRmthejogSI96KDtng/AWBWl3qMxIALTaOqe6uhQrYIqPbi+ITyKx3YB/gbO9
SJ28zBZQcQ0=
=4daO
- -----END PGP SIGNATURE-----

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/render.html?cid=1980

If you believe that your computer system has been compromised or attacked in 
any way, we encourage you to let us know by completing the secure National IT 
Incident Reporting Form at:

        http://www.auscert.org.au/render.html?it=3192

===========================================================================
Australian Computer Emergency Response Team
The University of Queensland
Brisbane
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.
===========================================================================

-----BEGIN PGP SIGNATURE-----
Comment: http://www.auscert.org.au/render.html?it=1967

iQCUAwUBRYHo2Ch9+71yA2DNAQKWWgP4r/auQSwP4QoV2iydFfz4bHN/LrtSkVpF
3N1XIOD+7oP/cPy3wHWHimDwIfFQHxmrHEGq7d9118zbNNsFsODlR7Pd9+Ihd4L/
51Z81+M6Tso8fZfAGN+u1/lJ9OzNy3ORxvkAAt63ye88usp30u7qwJ18BpCIuLvn
RR1JGtCFZQ==
=4K1A
-----END PGP SIGNATURE-----