Original issue date: June 26, 1996<BR>
Last revised: September 24, 1997<BR>
Updated copyright statement

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

<P>The CERT Coordination Center has received reports of a
vulnerability in systems that contain the suidperl program and that
support saved set-user-ID and saved set-group-ID. By exploiting this
vulnerability, anyone with access to an account on such a system may
gain root access.

<P>Saved set-user-IDs and set-group-IDs are sometimes referred to as
POSIX saved IDs. suidperl is also known as sperl followed by a version
number, as in sperl5.002.

<P>Perl versions 4 and 5 can be compiled and installed in such a way
that they will be vulnerable on some systems. If you have installed
the suidperl or sperl programs on a system that supports saved
set-user-ID and set-group-ID, you may be at risk.

<P>The CERT Coordination Center recommends that you first disable the
suidperl and sperl programs (Section III.A). If you need the
functionality, we further recommend that you either apply a patch for
this problem or install Perl version 5.003 (Section III.B). If neither
a patch nor a new version are viable alternatives, we recommend
installing the wrapper written by Larry Wall as a workaround for this
problem (Section III.C).

<P>We will update this advisory as we receive additional
information. Please check advisory files regularly for updates that
relate to your site.

<H2>I. Description</H2>

<P>On some systems, setuid and setgid scripts (scripts written in the
C shell, Bourne shell, or Perl, for example, with the set user or
group ID permissions enabled) are insecure due to a race condition in
the kernel. For those systems, Perl versions 4 and 5 attempt to work
around this vulnerability with a special program named suidperl, also
known as sperl. Even on systems that do provide a secure mechanism for
setuid and setgid scripts, suidperl may also be installed--although it
is not needed.

<P>suidperl attempts to emulate the set-user-ID and set-group-ID
features of the kernel. Depending on whether the script is
set-user-ID, set-group-ID, or both, suidperl achieves this emulation
by first changing its effective user or group ID to that of the
original Perl script. suidperl then reads and executes the script as
that effective user or group. To do these user and group ID changes
correctly, suidperl must be installed as set-user-ID root.

<P>On systems that support saved set-user-ID and set-group-ID,
suidperl does not properly relinquish its root privileges when
changing its effective user and group IDs.

<H2>II. Impact</H2>

<P>On a system that has the suidperl or sperl program installed and
that supports saved set-user-ID and saved set-group-ID, anyone with
access to an account on the system can gain root access.

<H2>III. Solution</H2>

<P>The command in Section A helps you determine if your system is
vulnerable and, if it is, optionally disables the suidperl and sperl
programs that it locates. After you have run this command on all of
your systems, your system will no longer be vulnerable.

<P>If you find that your system is vulnerable, then you need to
replace the suidperl and sperl programs with new versions. Section B
describes how to do that.

<P>Finally, Section C identifies a wrapper that can be used in place
of the suidperl program.

<H3>A. How to determine if your system is vulnerable</H3>

<P>To determine if a system is vulnerable to this problem and to
disable the programs that are believed to be vulnerable, use the
following find command or a variant. Consult your local system
documentation to determine how to tailor the find program on your

<P>You will need to run the find command on each system you maintain
because the command examines files on the local disk only. Substitute
the names of your local file systems for FILE_SYSTEM_NAMES in the
example. Example local file system names are /, /usr, and /var. You
must do this as root.

<P>Note that this is one long command, though we have separated it
onto three lines using back-slashes.

<PRE>find FILE_SYSTEM_NAMES -xdev -type f -user root \
           \( -name 'sperl[0-9].[0-9][0-9][0-9]'-o -name \ 
	   'suidperl' \) -perm -04000 -print -ok chmod ug-s '{}' \;</PRE>

<P>This command will find all files on a system that are

<LI>only in the file system you name (FILE_SYSTEM_NAMES -xdev) -
regular files (-type f)</LI>

<LI>owned by root (-user root)</LI>

<LI>named appropriately (-name 'sperl[0-9].[0-9][0-9][0-9]' -o -name

<LI>setuid root (-perm -04000)</LI>

Once found, those files will

<LI>have their names printed (-print)</LI>

<LI>have their modes changed, but only if you type `y' in response to
the prompt (-ok chown ug-s '{}' \;)</LI>

<H3>B. Obtain and install the appropriate patch according to the
instructions included with the patch.</H3>

<H4>Vendor patches</H4>

<P>You may be vulnerable if your vendor supports saved set-user-ID and
set-group-ID and ships suidperl or sperl. You need to get a patched
version from your vendor. Appendix A contains information provided by
the following vendors.  If you vendor is not on this list, please
contact the vendor directly.

<H4>Vendor or Source</H4>

<UL>Apple Computer, Inc.
<BR>Data General Corp.
<BR>Digital Equipment Corp.
<BR>FreeBSD, Inc.
<BR>Hewlett-Packard Company
<BR>IBM Corporation
<BR>Open Software Foundation
<BR>Sony Corporation
Until you can install a patch, we recommend disabling suidperl. The find
command above will help you do that. If you need suidperl or sperl, an
alternative is to install the wrapper described in Section C.
<H4>Source code patches</H4>
If you have installed Perl from source code, you should install source
code patches. Patches are available from the CPAN (Comprehensive Perl Archive
Network) archives.

<P>Patch for Perl Version 4:
<TR><TD>File</TD><TD> src/fixsuid4-0.pat</TD>
</TR><TR><TD>MD5 Checksum</TD><TD> af3e3c40bbaafce134714f1381722496</TD>

<P>Patch for Perl Version 5:
<TR><TD>File</TD><TD> src/fixsuid5-0.pat</TD>
</TR><TR><TD>MD5 Checksum</TD><TD>af3e3c40bbaafce134714f1381722496</TD>

<P>In addition, Perl version 5.003 contains this patch, so installing it
on your system also addresses this vulnerability. Perl 5.003 is available
from the CPAN archives. Here are the specifics:
<TR><TD>File</TD><TD> src/5.0/perl5.003.tar.gz</TD>
<TD>MD5 Checksum</TD><TD> b1bb23995cd25e5b750585bfede0e8a5</TD></TR>

<P>The CPAN archives can be found at the following locations:

<P>CPAN master site<A HREF="ftp://ftp.funet.fi/pub/languages/perl/CPAN/"></A>

<BR><A HREF="ftp://ftp.funet.fi/pub/languages/perl/CPAN/">ftp://ftp.funet.fi/pub/languages/perl/CPAN/</A>

<A HREF="ftp://ftp.is.co.za/programming/perl/CPAN/"></A>
<BR><A HREF="ftp://ftp.is.co.za/programming/perl/CPAN/">ftp://ftp.is.co.za/programming/perl/CPAN/</A>

<BR><A HREF="ftp://dongpo.math.ncu.edu.tw/perl/CPAN/"></A>
<BR><A HREF="ftp://dongpo.math.ncu.edu.tw/perl/CPAN/">ftp://dongpo.math.ncu.edu.tw/perl/CPAN/</A>

<BR><A HREF="ftp://coombs.anu.edu.au/pub/perl/"></A>

<BR><A HREF="ftp://coombs.anu.edu.au/pub/perl/">ftp://coombs.anu.edu.au/pub/perl/</A>
<BR><A HREF="ftp://ftp.mame.mu.oz.au/pub/perl/CPAN/">ftp://ftp.mame.mu.oz.au/pub/perl/CPAN/</A><A HREF="ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/"></A>

<BR><A HREF="ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/">ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/</A>


<BR><A HREF="ftp://ftp.arnes.si/software/perl/CPAN/">ftp://ftp.arnes.si/software/perl/CPAN/</A>
<BR><A HREF="ftp://ftp.ci.uminho.pt/pub/lang/perl/">ftp://ftp.ci.uminho.pt/pub/lang/perl/</A>
<A HREF="ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/">ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/</A>
<A HREF="ftp://ftp.funet.fi/pub/languages/perl/CPAN/">ftp://ftp.funet.fi/pub/languages/perl/CPAN/</A>

<BR><A HREF="ftp://ftp.ibp.fr/pub/perl/CPAN/">ftp://ftp.ibp.fr/pub/perl/CPAN/</A>
<A HREF="ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/">ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/</A>

<BR><A HREF="ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/">ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/</A>

<BR><A HREF="ftp://ftp.rz.ruhr-uni-bochum.de/pub/programming/languages/perl/CPAN/">ftp://ftp.rz.ruhr-uni-bochum.de/pub/programming/languages/perl/CPAN/</A>

<BR><A HREF="ftp://ftp.sunet.se/pub/lang/perl/CPAN/">ftp://ftp.sunet.se/pub/lang/perl/CPAN/</A><A HREF="ftp://ftp.switch.ch/mirror/CPAN/"></A>

<BR><A HREF="ftp://ftp.switch.ch/mirror/CPAN/">ftp://ftp.switch.ch/mirror/CPAN/</A>
<BR><A HREF="ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/">ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/</A>

<P>North America
<Br><A HREF="ftp://ftp.cis.ufl.edu/pub/perl/CPAN/">ftp://ftp.cis.ufl.edu/pub/perl/CPAN/</A>
<BR><A HREF="ftp://ftp.delphi.com/pub/mirrors/packages/perl/CPAN/">ftp://ftp.delphi.com/pub/mirrors/packages/perl/CPAN/</A>
<A HREF="ftp://ftp.sterling.com/programming/languages/perl/">ftp://ftp.sterling.com/programming/languages/perl/</A>
<BR><A HREF="ftp://ftp.uoknor.edu/mirrors/CPAN/">ftp://ftp.uoknor.edu/mirrors/CPAN/</A>
<BR><A HREF="ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/">ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/</A>


<H3>C. If you need setuid or setgid Perl scripts and are unable to apply the source code patches listed in Section B,</H3> we suggest that you retrieve
Larry Wall's fixsperl script noted below. fixsperl is a script that replaces
the suidperl and sperl programs with a wrapper that eliminates the
vulnerability.  The script is available from the CPAN archives as<BR>

<TR><TD>File</TD><TD> src/fixsperl-0</TD></TR>
<TR><TD>MD5 Checksum</TD><TD> f13900d122a904a8453a0af4c1bdddc6</TD></TR>

<P>Note that this script should be run one time, naming every suidperl
or sperl file on your system. If you add another version of suidperl or
sperl to your system, then you must run fixsperl on those newly installed
<H2>Appendix A: Vendor Information</H2>
Below is information we have received from vendors concerning the vulnerability
described in this advisory. If you do not see your vendor's name, please
contact the vendor directly for information.
<H3>Apple Computer, Inc.</H3>
A/UX 3.1.1 and earlier support saved set-{user,group}-ids.

<P>A/UX 3.1.1 and earlier do not have Perl as part of the standard product.
<H3>Data General Corporation</H3>
Data General does support saved set-user-IDs and set-group-IDs on DG/UX.

<P>Data General does not ship suidperl or sperl* with DG/UX.
<H3>Digital Equipment Corporation</H3>
Digital UNIX and Digital's ULTRIX Operating systems do support saved suid
and saved guid in the process context.

<P>Digital does not ship Perl with any operating system.
<H3>FreeBSD, Inc.</H3>
This information is taken from FreeBSD advisory SA-96:12.

<P>For the complete text of the advisory, please refer to
<UL><A HREF="ftp://freebsd.org/pub/CERT/patches/SA-96:12/">ftp://freebsd.org/pub/CERT/patches/SA-96:12/</A></UL>

<P>This vulnerability is present on all systems with the
<BR>_POSIX_SAVED_IDS functionality extension where suidperl has been installed.

<P>One may disable the setuid bit on all copies of the setuid version of
perl. This will close the vulnerability but render inoperable setuid perl
scripts. No software currently shipping as part of FreeBSD relies on this
functionality so the impact is only to third party software.

<P>As root, execute the commands:
<UL># chmod 111 /usr/bin/suidperl
<BR># chmod 111 /usr/bin/sperl4.036</UL>
In addition, if you have installed the perl5 port:
<UL># chmod 111 /usr/local/bin/suidperl
<BR># chmod 111 /usr/local/bin/sperl5.001</UL>
then verify that the setuid permissions of the files have been removed.
The permissions array should read "-r-xr-xr-x" as shown here:

<P># ls -l /usr/bin/s*perl*
<TR><TD>---x--x--x</TD><TD> 2 root<TD> bin</TD><TD> 307200</TD><TD>Jun</TD><TD> 1 17:16</TD><TD> /usr/bin/sperl4.036</TD></TR><TR>
<TR><TD>---x--x--x</TD><TD> 2 root<TD> bin</TD><TD> 307200</TD><TD>Jun</TD><TD> 1 17:16</TD><TD> /usr/bin/suidperl</TD></TR></TABLE>
<BR>and for the perl5 port:

<P># ls -l /usr/local/bin/s*perl*
<TR><TD>---x--x--x</TD><TD> 2 root </TD><TD>bin</TD><TD> 397312</TD><TD>Jan</TD><TD> 22 15:15</TD><TD> /usr/local/bin/sperl5.001</TD></TR><TR>
<TD>---x--x--x</TD><TD> 2 root</TD><TD> bin</TD><TD> 397312</TD><TD> Jan</TD><TD> 22 15:15</TD><TD> /usr/local/bin/suidperl</TD></TR></TABLE>

<P>Other information:

<P>*NOTE* A patch for perl is available directly from Larry Wall (the author
of perl) which solves this vulnerability in a different fashion than the
FreeBSD patches. You may apply either the FreeBSD patches, or Larry's patches,
or both. The patches solve the problem via two different mechanisms.

<P>Patches are available which eliminate this vulnerability. The following
patch should be applied to the system sources and suidperl should be rebuilt
and reinstalled.

<P>Apply the patch, then:
<LI>cd /usr/src/gnu/usr.bin/perl/sperl</LI>

<LI>make depend</LI>

<LI>make all</LI>

<LI>make install</LI>
A similar patch is also available for the perl5 port.
<BR>Apply the following patch by moving it into the patch
<BR>directory for the port distribution and rebuilding and
<BR>installing perl5:
<LI>cd /usr/ports/lang/perl5</LI>

<LI>cp &lt;location of new patches>/patch-a[ab] patches</LI>

<LI>make all</LI>

<LI>make install</LI>

<P>NOTE: These patches do NOT solve the vulnerability for FreeBSD 2.0 or
2.0.5. These only solve the problem for 2.1 and later. Patches specific
to FreeBSD 2.0 and 2.0.5 are available at the URL listed above.
<H3>Hewlett-Packard Company</H3>
HP/UX versions 8.X, 9.X, and 10.X all support saved set-user-id.

<P>None of HP/UX versions 8.X, 9.X, and 10.X have Perl as part of the standard
<H3>IBM Corporation</H3>
AIX versions 3.2.5 and 4.X support saved set-user-id.

<P>AIX versions 3.2.5 and 4.X do not have Perl as part of the standard
product. However, the SP2's PSSP software does contain suidperl, but the
program is not installed with the setuid bit set.
Linux 1.2 and 2.0 support saved set-user-id.

<P>Most distributions of Linux provide suidperl and sperl.

<P>The fixsperl script works on linux, and it is recommended that this
fix be applied until a new Perl release is made.
OS </TD><TD>Support Saved Sets?</TD><TD> Provide suidperl?</TD></TR>
<TR><TD>UX/4800</TD><TD>yes</TD><TD> no</TD></TR>
<TR><TD> EWS-UX/V (Rel4.2MP)</TD><TD> yes</TD><TD>no</TD></TR>
<TR><TD> UP-UX/V (Rel4.2MP)</TD><TD> yes</TD><TD> no</TD></TR>
<TR><TD>EWS-UX/V (Rel4.2) </TD><TD>yes</TD><TD> no</TD></TR></TABLE>
<H3>Open Software Foundation</H3>
OSF/1 1.3 or later support saved set-user-id

<P>OSF/1 1.3 or later does not have Perl as part of the standard product.
<H3>Sony Corporation</H3>
NEWS-OS 4.X does not support saved set-user-id and therefore any version
of Perl on that system is not vulnerable.

<P>NEWS-OS 6.X does support saved set-user-id.
None of X.org's development systems are vulnerable to the saved set-user-IDs
and set-group-IDs problems, and suidperl is not shipped with either of
our products.


<P>The CERT Coordination Center staff thanks Paul Traina, Larry Wall,
Eric Allman, Tom Christiansen, and AUSCERT for their support in the
development of this advisory.


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


Revision History
Sep. 24, 1997 Updated copyright statement
Aug. 30, 1996 Information previously in the README was inserted into
              the advisory.
July 01, 1996 Appendix, FreeBSD - added an entry for this vendor. 
June 27, 1996 Appendix, NEC - added an entry for this vendor. 
June 26, 1996 Appendix, Digital - added an entry for this vendor.