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





 

AA-95.07 -- Incorrect permissions on /tmp may allow root access

Date: 15 August 1995

Click here for printable version
Click here for PGP verifiable version
=============================================================================
AA-95.07			AUSCERT Advisory
				 15 August, 1995
		Incorrect permissions on /tmp may allow root access
-----------------------------------------------------------------------------

AUSCERT has received advice from the bugtraq mailing list that a
vulnerability exists in Solaris systems that allows a race condition to be
exploited to gain root access.  The essential problem is that the sticky
bit is sometimes not set on the /tmp directory, allowing users access to
other user's files in /tmp.

** An exploit program for this vulnerability has been published.  AUSCERT
** advises that the remedial action in Section 3 be performed immediately.

1.  Description

    A race condition exists in at least one Solaris 2.x system program that
    can be exploited to gain root access if the user has access to the
    temporary files.  Access to temporary files may be obtained if the
    permissions on the /tmp and /var/tmp directories are set incorrectly. 
    The permissions on the /tmp directory are often reset incorrectly by
    the system if tmpfs (which is mounting swap as /tmp) is in use.

    This vulnerability has been confirmed with Sun Microsystems.

    This vulnerability affects Solaris 2.x (SunOS 5.x) systems.  A similar
    problem has affected SunOS 4.1.x (Solaris 1.x) systems in the past, and
    these systems should also be checked for the correct permission bits.
    The remainder of this Advisory uses Solaris 2.x commands as examples. 
    Similar commands and configurations exist for SunOS 4.1.x users.

    To determine if you are running tmpfs, the following command can be
    used to verify if the filesystem for /tmp is swap:

	% /usr/sbin/df /tmp
	Filesystem            kbytes    used   avail capacity  Mounted on
	swap   28348      12   28336     0%    /tmp

    or look in the file /etc/vfstab for the configuration line:

#device		device		mount		FS	fsck	mount	mount
#to mount	to fsck		point		type	pass	at boot	options
swap		-		/tmp		tmpfs	-	yes	-

    If either of these two conditions exist, then you are running tmpfs and
    the system may automatically reset the permission bits of /tmp at the
    next reboot.

    To verify if your configuration is vulnerable, the following command
    may be used:

	% ls -ld /tmp
	drwxrwxrwt  2 root           61 Aug 15 12:12 /tmp

    If the sticky bit (t) is not set (it will be an x), then the system is
    vulnerable.

2.  Impact

    Users logged in to the system may gain unauthorised root privileges.

**  Note:  An exploit script for this vulnerability has been published.

3.  Workarounds

    These workarounds have been verified with Sun Microsystems.  Sun
    Microsystems expect a patch to be released in the near future.

3.1 Immediate Workaround

    The immediate workaround is to set the sticky bit on the /tmp directory
    using the following command as root:

	# /usr/bin/chmod 1777 /tmp

    Note that this command must be performed after each reboot if you are
    mounting swap as /tmp (using tmpfs).

    In addition, the ownership and group membership of the /tmp directory
    should be verified using ls -ld /tmp and if incorrect may be reset by:

	# /usr/bin/chown root /tmp
	# /usr/bin/chgrp root /tmp

    The AUSCERT Unix Security Checklist already addresses this issue in
    Section 5.5.  The Unix Security Checklist may be obtained from:

ftp://ftp.auscert.org.au/pub/auscert/papers/unix_security_checklist_1.0

3.2 System Reboot workaround

    It is possible to perform these commands automatically at reboot by
    creating the following script as /etc/init.d/tmpfsfix:

-------------------------------------8<--------------------------------------
#!/bin/sh

if [ -d /tmp ]
then
   /usr/bin/chmod 1777 /tmp
   /usr/bin/chgrp root /tmp
   /usr/bin/chown root /tmp
fi
-------------------------------------8<--------------------------------------

    A symbolic link should be then be created called /etc/rc3.d/S79tmpfix
    which points to /etc/init.d/tmpfsfix by issuing the following command
    as root:

	# /usr/bin/ln -s /etc/init.d/tmpfsfix /etc/rc3.d/S79tmpfix

3.3  /var/tmp permissions

    The /var/tmp directory should be similarly checked and corrected.  Note
    that this directory is not usually mounted as tmpfs, and therefore is
    not subject to automatic resetting of its permission bits on reboot.

	% ls -ld /var/tmp
	drwxrwxrwt  2 root          512 Aug 15 11:35 /var/tmp

----------------------------------------------------------------------------
The AUSCERT team wishes to thank Mark Graff of Sun Microsystems, Marek
Krawus of The University of Queensland, and Scott Chasin for their advice
and cooperation in this matter.
----------------------------------------------------------------------------

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

AUSCERT is the Australian Computer Emergency Response Team, funded by the
Australian Academic Research Network (AARNet) for its members.  It is
located at The University of Queensland within the Prentice Centre.
AUSCERT is a full member of the Forum of Incident Response and Security
Teams (FIRST).

AUSCERT maintains an anonymous FTP service which is found on:
ftp://ftp.auscert.org.au.  This archive contains past SERT and AUSCERT
Advisories, and other computer security information.

AUSCERT also maintains a World Wide Web service which is found on:
http://www.auscert.org.au.

Internet Email:	auscert@auscert.org.au
Facsimile:	(07) 3365 4477
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.

Postal:
Australian Computer Emergency Response Team
c/- Prentice Centre
The University of Queensland
Brisbane
Qld.  4072.
AUSTRALIA