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

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

                  ESB-2002.514 -- FreeBSD-SA-02:39.libkvm
         Applications using libkvm may leak sensitive descriptors
                             17 September 2002

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

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

Product:                libkvm
Vendor:                 FreeBSD
Operating System:       FreeBSD prior to and including 4.6.2-RELEASE
                        FreeBSD releases prior to 4.4-RELEASE-p27,
                         4.5-RELEASE-p20, and 4.6.2-RELEASE-p2
Impact:                 Read-only Data Access
Access Required:        Existing Account

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

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

=============================================================================
FreeBSD-SA-02:39.libkvm                                     Security Advisory
                                                          The FreeBSD Project

Topic:          Applications using libkvm may leak sensitive descriptors

Category:       core
Module:         libkvm
Announced:      2002-09-16
Credits:        David Endler <DEndler@iDefense.com>,
                <badc0ded@badc0ded.com>
Affects:        All releases prior to and including 4.6.2-RELEASE.
                Security branch releases prior to 4.4-RELEASE-p27,
                4.5-RELEASE-p20, and 4.6.2-RELEASE-p2.
Corrected:      2002-09-13 14:53:43 UTC (RELENG_4)
                2002-09-13 15:04:22 UTC (RELENG_4_6)
                2002-09-13 15:07:26 UTC (RELENG_4_5)
                2002-09-13 15:09:07 UTC (RELENG_4_4)
FreeBSD only:   NO

I.   Background

The kvm(3) library provides a uniform interface for accessing kernel
virtual memory images, including live systems and crash dumps.  Access
to live systems is via /dev/mem and /dev/kmem.  Memory can be read and
written, kernel symbol addresses can be looked up efficiently, and
information about user processes can be gathered.

The kvm_openfiles(3) function opens the special device files /dev/mem
and /dev/kmem, and returns an opaque handle that must be passed
to the other library functions.

II.  Problem Description

Applications that wish to present system information such as swap
utilization, virtual memory utilization, CPU utilization, and
so on may use the kvm(3) library to read kernel memory directly
and gather this information.  Such applications typically must
be run set-group-ID kmem so that the call to kvm_openfiles(3)
can access /dev/mem and /dev/kmem.

If the application then uses exec(2) to start another application,
the new application will continue to have open file descriptors to
/dev/mem and /dev/kmem.  This is usually avoided by marking file
descriptors as close-on-exec, but since the handle returned by
kvm_openfiles(3) is opaque, there is no direct way for the application
to determine what file descriptors have been opened by the library.
As a result, application writers may neglect to take these file
descriptors into account.

III. Impact

Set-group-ID kmem applications which use kvm(3) and start other
applications may leak /dev/mem and /dev/kmem file descriptors.  If
those applications can be specified by a local user, they may be
used to read kernel memory, resulting in disclosure of sensitive
information such as file, network, and tty buffers, authentication
tokens, and so on.

Several applications in the FreeBSD Ports Collection were identified
that are affected: asmon, ascpu, bubblemon, wmmon, and wmnet2.  There
may be other applications as well.

IV.  Workaround

Remove the set-group-ID bit on affected applications.  This will
result in the applications losing some functionality.

V.   Solution

Do one of the following:

1) Upgrade your vulnerable system to 4.6-STABLE; or to the RELENG_4_6,
RELENG_4_5, or RELENG_4_4 security branch dated after the correction
date (4.6.2-RELEASE-p2, 4.5-RELEASE-p20, or 4.4-RELEASE-p27).

2) To patch your present system:

The following patch has been verified to apply to FreeBSD 4.4, FreeBSD
4.5, FreeBSD 4.6, and FreeBSD 4.6.2 systems.

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

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-02:39/libkvm.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-02:39/libkvm.patch.asc

b) Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch
# cd /usr/src/lib/libkvm
# make depend && make && make install

VI.  Correction details

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

Path                                                             Revision
  Branch
- - -------------------------------------------------------------------------
src/lib/libkvm/kvm.c
  RELENG_4                                                       1.12.2.3
  RELENG_4_6                                                 1.12.2.2.8.1
  RELENG_4_5                                                 1.12.2.2.6.1
  RELENG_4_4                                                 1.12.2.2.4.1
src/sys/conf/newvers.sh
  RELENG_4_6                                               1.44.2.23.2.19
  RELENG_4_5                                               1.44.2.20.2.21
  RELENG_4_4                                               1.44.2.17.2.26
- - -------------------------------------------------------------------------
- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iQCVAwUBPYXz/1UuHi5z0oilAQGNGAP/cpg8s9L034EbrJriQDicHptv/2QgSnrw
2BvOaUXRIEweDz7FAoLstbxDFVE3Hx9+zN4gn7S49WIbFjATFRcL2FT/1yBhrbBx
Yp20/gveFQSU+AnjsriKVDrH9ksBO4/ZX6lBxjvxD0Hbyj4ATd027jNAXl7WeLbq
2DN6Lf4FB1Y=
=699Y
- -----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 member emergencies only.

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

iQCVAwUBPYcR2yh9+71yA2DNAQH2jAP+Mui66pprVfS7Db3GBhO8WTJpoUC9xs0J
Z8yIF6+7s23E2lbzK1LT4GLU443r+H6iGO3q3a4gkhirFyBq6zVD7CoATtbiJnHQ
nAcpDKsnptp9AW7U8c3tqna6X86BzviHOcbB15j2/stJyRdhkHLxc/j6qK8iwfGi
oPDywVdl8G8=
=07aB
-----END PGP SIGNATURE-----