Original issue date: January 7, 1997<BR>
Last revised: September 26, 1997<BR>
Updated copyright statement

<P>A complete revision history is at the end of this file.

<P>The text of this advisory was originally released on December 3,
1996, as AA-96.16.HP-UX.newgrp.Buffer.Overrun.Vulnerability, developed
by AUSCERT.  Because of the seriousness of the problem, we are
reprinting the AUSCERT advisory here with their permission. Only the
contact information at the end has changed: AUSCERT contact
information has been replaced with CERT/CC contact information.

<P>We will update this advisory as we receive additional
information. Look for it in an "Updates" section at the end of the
advisory.

<P><HR>

<P>AUSCERT has received information that a vulnerability exists in the
<I>newgrp(1)</I> program under HP-UX 9.x and 10.x.

<P>This vulnerability may allow local users to gain root privileges.

<P>Exploit information involving this vulnerability has been made
publicly available.

<P>Currently there are no vendor patches available that address this
vulnerability.  AUSCERT recommends that sites take the steps outlined
in section 3 as soon as possible.

<P>This advisory will be updated as more information becomes available.

<P>
<HR Width="100%">
<H2>1. Description</H2>
AUSCERT has received information that a vulnerability exists in the HP-UX
<I>newgrp(1)</I> program. The newgrp command is used to change a users
group identification, and is installed by default.

<P>Due to insufficient bounds checking on arguments which are supplied
by users, it is possible to overwrite the internal stack space of the
newgrp program while it is executing. By supplying a carefully
designed argument to the newgrp program, intruders may be able to
force newgrp to execute arbitrary commands. As newgrp is setuid root,
this may allow intruders to run arbitrary commands with root
privileges.

<P>This vulnerability is known to affect both HP-UX 9.x and 10.x.

<P>By default, newgrp is located in /bin under HP-UX 9.x and in
/usr/bin under HP-UX 10.x.

<P>Exploit information involving this vulnerability has been made
publicly available.

<H2>2. Impact</H2>
Local users may gain root privileges.

<H2>3. Workarounds/Solution</H2>

<P>AUSCERT recommends that sites limit the possible exploitation of
this vulnerability by immediately removing the setuid permissions as
stated in Section 3.1.  If the newgrp command is required, AUSCERT
recommends the newgrp wrapper program given in Section 3.2 be
installed.

<P>AUSCERT recommends that official vendor patches be installed when
they are made available. See the Updates section for information about
availability of patches.

<H3>3.1 Remove setuid and non-root execute permissions</H3>

<P>To prevent the exploitation of the vulnerability described in the
advisory, AUSCERT recommends that the setuid permissions be removed
from the newgrp program immediately. As the newgrp program will no
longer work for non-root users, it is recommended that the execute
permissions also be removed.  Before doing so, the original
permissions for newgrp should be noted as they will be needed if sites
choose to install the newgrp wrapper program (Section 3.2).

<PRE> For HP-UX 9.x:

 # ls -l /bin/newgrp
 -r-sr-xr-x 1 root sys 16384 Dec 2 13:45 /bin/newgrp

 # chmod 500 /bin/newgrp
 # ls -l /bin/newgrp
 -r-x------ 1 root sys 16384 Dec 2 13:45 /bin/newgrp

 For HP-UX 10.x:

 # ls -l /usr/bin/newgrp
 -r-sr-xr-x 1 root sys 12288 Dec 2 13:27 /usr/bin/newgrp

 # chmod 500 /usr/bin/newgrp
 # ls -l /usr/bin/newgrp
 -r-x------ 1 root sys 12288 Dec 2 13:27 /usr/bin/newgrp</PRE>
Note that this will remove the ability for any non-root user to run the
newgrp program.

<H3>3.2 Install newgrp wrapper</H3>

<P>AUSCERT has developed a wrapper to help prevent programs from being
exploited using the vulnerability described in this advisory. This
wrapper, including installation instructions, can be found at:

<P><A HREF="ftp://ftp.auscert.org.au/pub/auscert/tools/overflow_wrapper.c">ftp://ftp.auscert.org.au/pub/auscert/tools/overflow_wrapper.c</A>

<P>This replaces the newgrp program with a wrapper which checks the
length of the command line arguments passed to it. If an argument
exceeds a certain predefined value (MAXARGLEN), the wrapper exits
without executing the newgrp command. The wrapper program can also be
configured to syslog any failed attempts to execute newgrp with
arguments exceeding MAXARGLEN. For further instructions on using this
wrapper, please read the comments at the top of overflow_wrapper.c.

<P>When compiling overflow_wrapper.c for use with HP-UX newgrp,
AUSCERT recommends defining MAXARGLEN to be 16.

<P>The MD5 checksum for Version 1.0 of overflow_wrapper.c is:

<P>MD5 (overflow_wrapper.c) = f7f83af7f3f0ec1188ed26cf9280f6db

<P>AUSCERT recommends that until vendor patches can be installed,
sites requiring the newgrp functionality apply this workaround.

<P>
<HR width="100%">

<P>AUSCERT thanks Hewlett-Packard for their continued assistance and
technical expertise essential for the production of this
advisory. AUSCERT also thanks Information Technology Services of the
University of Southern Queensland for their assistance.

<P><HR>
<H2>Updates</H2>
 
<H4>April 4, 1997</H4>

The CERT/CC has received reports that the vulnerability described in this
advisory is being exploited.

<H4>January 14, 1997</H4>
All HP patches are now available, see HEWLETT-PACKARD SECURITY BULLETIN:
#00048, issued on 09 January 1997:
 
<P>PHCO_9603 for all platforms with HP-UX releases 9.X
<BR>PHCO_9604 for all platforms with HP-UX releases 10.00/10.01
<BR>PHCO_9605 for all platforms with HP-UX releases 10.10/10.20
 
<P><B>Fixing the problem</B>
 
<P>The vulnerability can be eliminated from HP-UX releases 9.X and 10.X
by applying the appropriate patch.
 
<P><B>Recommended solution</B>

<P>1. Determine which patch are appropriate for your operating system.
<BR>2. Hewlett-Packard's HP-UX patches are available via email and the
World Wide Web
 
<P>To obtain a copy of the Hewlett-Packard SupportLine email service user's
guide, send the following in the TEXT PORTION OF THE MESSAGE to <A
HREF="mailto:
support@us.external.hp.com">support@us.external.hp.com</A>
(no Subject is required):
 
<P>send guide
 
<P>The users guide explains the HP-UX patch downloading process via email
and other services available.
 
<P>World Wide Web service for downloading of patches is available via our
URL:
 
<P>(<A HREF="http://us.external.hp.com">http://us.external.hp.com</A>)
 
<P>3. Apply the patch to your HP-UX system.
 
<P>4. Examine /tmp/update.log (9.X), or /var/adm/sw/swinstall.log
 
<P>(10.X), for any relevant WARNING's or ERROR's.

<P><HR>

<!--#include virtual="/include/footer_nocopyright.html" -->
<P>Copyright 1997 Carnegie Mellon University.</P>

<HR>

Revision History
<PRE>
Sep. 26, 1997 Updates - added copyright statement

Apr. 04, 1997 Updates - added note that the vulnerability is being exploited.

Jan. 14, 1997 Updates - added patch information.
</PRE>