Australia's Leading Computer Emergency Response Team

ESB-2013.0599 - ALERT [FreeBSD] nfsserver: Root compromise - Remote/unauthenticated
Date: 30 April 2013
Original URL: http://www.auscert.org.au/render.html?cid=1980&it=17454

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

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

                               ESB-2013.0599
              Insufficient input validation in the NFS server
                               30 April 2013

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

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

Product:           nfsserver
Publisher:         FreeBSD
Operating System:  FreeBSD
Impact/Access:     Root Compromise   -- Remote/Unauthenticated
                   Denial of Service -- Remote/Unauthenticated
Resolution:        Patch/Upgrade
CVE Names:         CVE-2013-3266  

Original Bulletin: 
   ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-13:05.nfsserver.asc

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

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

=============================================================================
FreeBSD-SA-13:05.nfsserver                                  Security Advisory
                                                          The FreeBSD Project

Topic:          Insufficient input validation in the NFS server

Category:       core
Module:         nfsserver
Announced:      2013-04-29
Revised:        2013-04-29
Credits:        Adam Nowacki
Affects:        All supported versions of FreeBSD.
Corrected:      2013-04-29 21:10:49 UTC (stable/8, 8.4-PRERELEASE)
                2013-04-29 21:10:53 UTC (releng/8.3, 8.3-RELEASE-p8)
                2013-04-29 21:11:31 UTC (releng/8.4, 8.4-RC1-p1)
                2013-04-29 21:11:31 UTC (releng/8.4, 8.4-RC2-p1)
                2013-04-29 21:11:01 UTC (stable/9, 9.1-STABLE)
                2013-04-29 21:11:05 UTC (releng/9.1, 9.1-RELEASE-p3)
CVE Name:       CVE-2013-3266

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:http://security.FreeBSD.org/>.

0.   Revision History

v1.0  2013-04-29 Initial release.
v1.1  2013-04-29 Corrected patch URL.
                 Additional workaround information.

I.   Background

The Network File System (NFS) allows a host to export some or all of its
file systems so that other hosts can access them over the network and mount
them as if they were on local disks.  FreeBSD includes server and client
implementations of NFS.

FreeBSD 8.0 and onward has two NFS implementations: the original CSRG
NFSv2 and NFSv3 implementation and a new implementation which also
supports NFSv4.

FreeBSD 9.0 and onward uses the new NFS implementation by default.

II.  Problem Description

When processing READDIR requests, the NFS server does not check that
it is in fact operating on a directory node.  An attacker can use a
specially modified NFS client to submit a READDIR request on a file,
causing the underlying filesystem to interpret that file as a
directory.

III. Impact

The exact consequences of an attack depend on the amount of input
validation in the underlying filesystem:

 - If the file resides on a UFS filesystem on a little-endian server,
   an attacker can cause random heap corruption with completely
   unpredictable consequences.

 - If the file resides on a ZFS filesystem, an attacker can write
   arbitrary data on the stack.  It is believed, but has not been
   confirmed, that this can be exploited to run arbitrary code in
   kernel context.

Other filesystems may also be vulnerable.

IV.  Workaround

Systems that do not provide NFS service are not vulnerable.  Neither
are systems that do but use the old NFS implementation, which is the
default in FreeBSD 8.x.

To determine which implementation an NFS server is running, run the
following command:

# kldstat -v | grep -cw nfsd

This will print 1 if the system is running the new NFS implementation,
and 0 otherwise.

To switch to the old NFS implementation:

1) Append the following lines to /etc/rc.conf:

   nfsv4_server_enable="no"
   oldnfs_server_enable="yes"

2) If the NFS server is compiled into the kernel (which is the case
   for the stock GENERIC kernel), replace the NFSD option with the
   NFSSERVER option, then recompile your kernel as described in
   <URL:http://www.FreeBSD.org/handbook/kernelconfig.html>.

   If the NFS server is not compiled into the kernel, the correct
   module will be loaded at boot time.

3) Finally, reboot the system.

V.   Solution

Perform one of the following:

1) Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date.

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch http://security.FreeBSD.org/patches/SA-13:05/nfsserver.patch
# fetch http://security.FreeBSD.org/patches/SA-13:05/nfsserver.patch.asc
# gpg --verify nfsserver.patch.asc

b) Apply the patch.

# cd /usr/src
# patch < /path/to/patch

c) Recompile your kernel as described in
<URL:http://www.FreeBSD.org/handbook/kernelconfig.html> and reboot the
system.

3) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the i386 or amd64
platforms can be updated via the freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

VI.  Correction details

The following list contains the revision numbers of each file that was
corrected in FreeBSD.

Branch/path                                                      Revision
- - -------------------------------------------------------------------------
stable/8/                                                         r250068
releng/8.3/                                                       r250069
releng/8.4/                                                       r250073
stable/9/                                                         r250070
releng/9.1/                                                       r250071
- - -------------------------------------------------------------------------

VII. References

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-3266

The latest revision of this advisory is available at
http://security.FreeBSD.org/advisories/FreeBSD-SA-13:05.nfsserver.asc
- -----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlF+7BUACgkQFdaIBMps37I3LACeIFS/wiaA6eDn9F8ByZ6V8CH4
GT4AoIrhX24l+LHxpvtHoaDmKOoBpva5
=bbRm
- -----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

===========================================================================
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

iQIVAwUBUX8jD+4yVqjM2NGpAQKvhA/9EEURJt6U0ZQoYAuSReat/ABhrTIUWMKr
yAFGMDm/gBssyfwS/zzU9aimQOA0nHeOOhGrMoctjG9UZq8FUjf7P06VGnyBU7OY
1ufcY69R1ckHUhXkNVWf6NiXrmU33evVQhywAnTa/DUMtdkcRzruBSKsWdrjK8Lz
IeHxNWIz70Q0Q7XibInWYeJ7pwd10drBTkZj2MNUuwxx9QAGnX/GLlFJDpBQov2X
oWPQ1rHyoI5wV3GjYHt4CJGtl1xp22axQ8Z7rvZgA9rILAJapZdcp1tHJnthhFfh
FVUR47ELyjrAHMvLjn329jOhmauvtQc8U4ulAYIrFHWwn7cSyL1GlVWWEaeGpLck
PwHmpFwODZXkpj1ZpQaFgNs7ilEH6SKbSuY8y9pPpwYNH9vOIdVBue7YAQg9b+Cl
e5VOxGDMGu4FB46YeMFrXudXiTN7aGWRlpnVBd12mMU0SUg8jn6/ktDqyDcK9QlM
wt7YDfV0FWl5rFccfh4uKAaUrgbHDSce8OKOeaz52fTIqlGORwaJ6JiJeKG0/7eH
iC9l35aPISaaAROyqVa6XT9jrFYTNGc1F2tadoYy24mp39iKzxJaRQeCLbh5F5iQ
Shea0PwYSUAiQa8sg1TxZsigei4WQR3njPDnUPaqijZpG6cuwgPU2rPzAstd4+dx
Z8lmWPbeQlE=
=64Xo
-----END PGP SIGNATURE-----