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

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

             ESB-2001.388 -- NetBSD Security Advisory 2001-016
                       unsafe chdir usage in fts(3)
                             7 September 2001

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

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

Product:                fts(3)
Vendor:                 NetBSD
Operating System:       All NetBSD releases prior to July 9, 2001
Impact:                 Modify Arbitrary Files
Access Required:        Existing Account

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

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


		 NetBSD Security Advisory 2001-016
		 =================================

Topic:		unsafe chdir usage in fts(3)

Version:	All NetBSD releases prior to July 9, 2001.

Severity:	Local users can trick processes that walk file system
		trees to perform their actions in the wrong location.

Fixed:		NetBSD-current:		July 9, 2001
		NetBSD-1.5 branch:	August 22, 2001 (1.5.2 includes the fix)


Abstract
========

The fts(3) functions can be tricked by a rogue user into performing
actions on incorrect file system hierarchies.


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

The macro for chdir used in libc/gen/fts (__fts13.c after NetBSD 1.3)
did not perform sufficient safety checks. If any directory (or symlink
to a directory) above the current directory fts was processing was
moved, the fts-using application could be made to descend the wrong
directory sub-tree, and/or ascend above the original starting directory.
Once it has ascended above the starting directory, the process could
descend into an unintended file system hierarchy.

This is particularly dangerous when combined with automated scripts
which run programs such as 'rm -r'.


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

The following instructions describe how to upgrade your C library
and affected statically linked system binaries by updating your source
tree and rebuilding and installing a new version of the C library
and affected binaries.

* NetBSD-current: 

	Systems running NetBSD-current dated from before 2001-06-09
	should be upgraded to NetBSD-current dated 2001-06-10 or later.

	The following directory needs to be updated from the
	netbsd-current CVS branch (aka HEAD):
		src/lib/libc

	To update from CVS, re-build, and re-install libc:
		# cd /usr/src/lib/libc
		# cvs update -d -P
		# make cleandir dependall install


	Alternatively, apply the following patch (with potential offset 
	differences) and rebuild & re-install libc:
		ftp://ftp.netbsd.org/pub/NetBSD/security/patches/SA2001-016-fts.patch

	To patch, re-build and re-install libc:
		# cd /usr/src
		# patch < /path/to/SA2001-016-fts.patch
		# make cleandir dependall install


	The following static binaries must also be rebuilt for the fix
	to be complete:
		/bin/chmod /bin/cp /bin/ksh /bin/ls /bin/pax /bin/rm
		/sbin/dump /sbin/dump_lfs


* NetBSD 1.5, 1.5.1:

	Systems running NetBSD releases up to and including 1.5.1 should
	apply the following patch (with potential offset differences):
		ftp://ftp.netbsd.org/pub/NetBSD/security/patches/SA2001-016-fts-1.5.patch

	To patch, re-build and re-install libc
		# cd /usr/src
		# patch < /path/to/SA2001-016-fts.patch
		# make cleandir dependall install


	The following static binaries must also be rebuilt for the fix
	to be complete:
		/bin/chmod /bin/cp /bin/ksh /bin/ls /bin/pax /bin/rm
		/sbin/dump /sbin/dump_lfs


Systems running releases older than NetBSD 1.5 should be upgraded to
NetBSD 1.5.1 before applying the fixes described here.


Thanks To
=========

Kris Kennaway for initial notification of the issue.

Christos Zoulas for patches, inspired by Todd C. Miller, and for
clarification of the descriptions in this advisory.


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

	2001-09-06	Initial release


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

An up-to-date PGP signed copy of this release will be maintained at
  ftp://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2001-016.txt.asc

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


Copyright 2001, The NetBSD Foundation, Inc.  All Rights Reserved.

$NetBSD: NetBSD-SA2001-016.txt,v 1.11 2001/09/06 15:40:50 lukem Exp $

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

iQCVAwUBO5eZIj5Ru2/4N2IFAQG7WAP+MDviy39gwuXdaUdYtPvpPULDsD/Euh6e
OUbJIZDykDAwS/w8NSa+vlS3+PJmaWPl1FW0uYTnjWAyfS6A3HGozS45QrXCRhj+
f7yrqp24SaIYOG6/eNRg0J9Ekm53DzN6BsBWveFCS/P/oaji7JT7UC7A3mtzn9et
5zg8cBYPLxs=
=RvHM
- -----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.

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 use any or all of this information is
the responsibility of each user or organisation, and should be done so in
accordance with site policies and procedures.

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 original authors 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/Information/advisories.html

If you believe that your system has been compromised, contact AusCERT or
your representative in FIRST (Forum of Incident Response and Security
Teams).

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

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: ftp://ftp.auscert.org.au/pub/auscert/AUSCERT_PGP.key

iQCVAwUBO5j6Wih9+71yA2DNAQFW2QQAhmZcClnOJPzkVwApOzcDa0NFtEOFm1QY
R59f9cuMuJVuaS8X/VygHBtWf5soFxCIvxwqZObn0GG74gcAp/HJbUntL1nUQP/k
kQBIzlDXMTrFSAtQJBzHJghuoP3edAFrQWDZDHhLRltShHhDMrBST2Kk0OusT+Y/
McW4kraXVGY=
=XS23
-----END PGP SIGNATURE-----