home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / general / cert0117.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  18.0 KB  |  473 lines

  1.  
  2. -----BEGIN PGP SIGNED MESSAGE-----
  3.  
  4. =============================================================================
  5. CERT(sm) Advisory CA-96.12
  6. Original issue date: June 26, 1996
  7. Last revised: August 30, 1996
  8.               Information previously in the README was inserted
  9.               into the advisory.
  10.  
  11.               A complete revision history is at the end of this file.
  12.  
  13. Topic: Vulnerability in suidperl
  14. - -----------------------------------------------------------------------------
  15.  
  16. The CERT Coordination Center has received reports of a vulnerability in
  17. systems that contain the suidperl program and that support saved
  18. set-user-ID and saved set-group-ID. By exploiting this vulnerability,
  19. anyone with access to an account on such a system may gain root access.
  20.  
  21. Saved set-user-IDs and set-group-IDs are sometimes referred to as POSIX
  22. saved IDs. suidperl is also known as sperl followed by a version number,
  23. as in sperl5.002.
  24.  
  25. Perl versions 4 and 5 can be compiled and installed in such a way that
  26. they will be vulnerable on some systems. If you have installed the
  27. suidperl or sperl programs on a system that supports saved set-user-ID and
  28. set-group-ID, you may be at risk.
  29.  
  30. The CERT Coordination Center recommends that you first disable the
  31. suidperl and sperl programs (Section III.A). If you need the
  32. functionality, we further recommend that you either apply a patch for
  33. this problem or install Perl version 5.003 (Section III.B). If neither
  34. a patch nor a new version are viable alternatives, we recommend
  35. installing the wrapper written by Larry Wall as a workaround for this
  36. problem (Section III.C).
  37.  
  38. We will update this advisory as we receive additional information.
  39. Please check advisory files regularly for updates that relate to your site.
  40.  
  41. - -----------------------------------------------------------------------------
  42.  
  43. I.   Description
  44.  
  45.      On some systems, setuid and setgid scripts (scripts written in the
  46.      C shell, Bourne shell, or Perl, for example, with the set user or
  47.      group ID permissions enabled) are insecure due to a race condition in
  48.      the kernel. For those systems, Perl versions 4 and 5 attempt to work
  49.      around this vulnerability with a special program named suidperl, also
  50.      known as sperl. Even on systems that do provide a secure mechanism for
  51.      setuid and setgid scripts, suidperl may also be installed--although it
  52.      is not needed.
  53.  
  54.      suidperl attempts to emulate the set-user-ID and set-group-ID
  55.      features of the kernel. Depending on whether the script is
  56.      set-user-ID, set-group-ID, or both, suidperl achieves this emulation
  57.      by first changing its effective user or group ID to that of the
  58.      original Perl script. suidperl then reads and executes the script as
  59.      that effective user or group. To do these user and group ID changes
  60.      correctly, suidperl must be installed as set-user-ID root.
  61.  
  62.      On systems that support saved set-user-ID and set-group-ID, suidperl
  63.      does not properly relinquish its root privileges when changing its
  64.      effective user and group IDs.
  65.  
  66. II.  Impact
  67.  
  68.      On a system that has the suidperl or sperl program installed and
  69.      that supports saved set-user-ID and saved set-group-ID, anyone with
  70.      access to an account on the system can gain root access.
  71.  
  72. III. Solution
  73.  
  74.      The command in Section A helps you determine if your system is
  75.      vulnerable and, if it is, optionally disables the suidperl and
  76.      sperl programs that it locates. After you have run this command
  77.      on all of your systems, your system will no longer be vulnerable.
  78.  
  79.      If you find that your system is vulnerable, then you need to replace
  80.      the suidperl and sperl programs with new versions. Section B describes
  81.      how to do that.
  82.  
  83.      Finally, Section C identifies a wrapper that can be used in place of
  84.      the suidperl program.
  85.  
  86.      A. How to determine if your system is vulnerable
  87.  
  88.         To determine if a system is vulnerable to this problem and to
  89.         disable the programs that are believed to be vulnerable, use the
  90.         following find command or a variant. Consult your local system
  91.         documentation to determine how to tailor the find program on your
  92.         system.
  93.  
  94.         You will need to run the find command on each system you maintain
  95.         because the command examines files on the local disk only. Substitute
  96.         the names of your local file systems for FILE_SYSTEM_NAMES in the
  97.         example. Example local file system names are /, /usr, and /var.
  98.         You must do this as root.
  99.  
  100.         Note that this is one long command, though we have separated
  101.         it onto three lines using back-slashes.
  102.  
  103.              find FILE_SYSTEM_NAMES -xdev -type f -user root \
  104.                     \( -name 'sperl[0-9].[0-9][0-9][0-9]' -o -name \
  105.                     'suidperl' \) -perm -04000 -print -ok chmod ug-s '{}' \;
  106.  
  107.         This command will find all files on a system that are
  108.             - only in the file system you name (FILE_SYSTEM_NAMES -xdev)
  109.             - regular files (-type f)
  110.             - owned by root (-user root)
  111.             - named appropriately (-name 'sperl[0-9].[0-9][0-9][0-9]'
  112.                                     -o -name 'suidperl')
  113.             - setuid root (-perm -04000)
  114.  
  115.         Once found, those files will
  116.             - have their names printed (-print)
  117.             - have their modes changed, but only if you type `y'
  118.               in response to the prompt (-ok chown ug-s '{}' \;)
  119.  
  120.  
  121.      B. Obtain and install the appropriate patch according to the
  122.         instructions included with the patch.
  123.  
  124.         Vendor patches
  125.         --------------
  126.         You may be vulnerable if your vendor supports saved set-user-ID
  127.         and set-group-ID and ships suidperl or sperl. You need to get
  128.         a patched version from your vendor. Appendix A contains
  129.         information provided by the following vendors. If you vendor is not on
  130.         this list, please contact the vendor directly.
  131.  
  132.               Vendor or Source
  133.               ----------------
  134.               Apple Computer, Inc.
  135.               Data General Corp.
  136.               Digital Equipment Corp.
  137.               FreeBSD, Inc.
  138.               Hewlett-Packard Company
  139.               IBM Corporation
  140.               Linux
  141.               NEC
  142.               Open Software Foundation
  143.               Sony Corporation
  144.               X.org
  145.         
  146.  
  147.         Until you can install a patch, we recommend disabling suidperl.
  148.         The find command above will help you do that. If you need
  149.         suidperl or sperl, an alternative is to install the wrapper
  150.         described in Section C.
  151.  
  152.         Source code patches
  153.         -------------------
  154.         If you have installed Perl from source code, you should install
  155.         source code patches. Patches are available from the CPAN
  156.         (Comprehensive Perl Archive Network) archives.
  157.  
  158.         Patch for Perl Version 4:
  159.             File                src/fixsuid4-0.pat
  160.             MD5 Checksum        af3e3c40bbaafce134714f1381722496
  161.  
  162.         Patch for Perl Version 5:
  163.             File                src/fixsuid5-0.pat
  164.             MD5 Checksum        135c96ee400fd37a38a7ef37edd489e9
  165.  
  166.         In addition, Perl version 5.003 contains this patch, so installing
  167.         it on your system also addresses this vulnerability. Perl 5.003 is
  168.         available from the CPAN archives. Here are the specifics:
  169.  
  170.             File                src/5.0/perl5.003.tar.gz
  171.             MD5 Checksum        b1bb23995cd25e5b750585bfede0e8a5
  172.  
  173.         The CPAN archives can be found at the following locations:
  174.  
  175.         CPAN master site
  176.           ftp://ftp.funet.fi/pub/languages/perl/CPAN/
  177.         Africa
  178.           ftp://ftp.is.co.za/programming/perl/CPAN/
  179.         Asia
  180.           ftp://dongpo.math.ncu.edu.tw/perl/CPAN/
  181.           ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
  182.         Australasia
  183.           ftp://coombs.anu.edu.au/pub/perl/
  184.           ftp://ftp.mame.mu.oz.au/pub/perl/CPAN/
  185.           ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/
  186.         Europe
  187.           ftp://ftp.arnes.si/software/perl/CPAN/
  188.           ftp://ftp.ci.uminho.pt/pub/lang/perl/
  189.           ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
  190.           ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
  191.           ftp://ftp.funet.fi/pub/languages/perl/CPAN/
  192.           ftp://ftp.ibp.fr/pub/perl/CPAN/
  193.           ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/
  194.           ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/
  195.           ftp://ftp.rz.ruhr-uni-bochum.de/pub/programming/languages/perl/CPAN/
  196.           ftp://ftp.sunet.se/pub/lang/perl/CPAN/
  197.           ftp://ftp.switch.ch/mirror/CPAN/
  198.           ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/
  199.         North America
  200.           ftp://ftp.cis.ufl.edu/pub/perl/CPAN/
  201.           ftp://ftp.delphi.com/pub/mirrors/packages/perl/CPAN/
  202.           ftp://ftp.sedl.org/pub/mirrors/CPAN/
  203.           ftp://ftp.sterling.com/programming/languages/perl/
  204.           ftp://ftp.uoknor.edu/mirrors/CPAN/
  205.           ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/
  206.  
  207.  
  208.         C. If you need setuid or setgid Perl scripts and are unable to apply
  209.            the source code patches listed in Section B, we suggest that you
  210.            retrieve Larry Wall's fixsperl script noted below. fixsperl is a
  211.            script that replaces the suidperl and sperl programs with a wrapper
  212.            that eliminates the vulnerability. The script is available from the
  213.            CPAN archives as
  214.  
  215.             File                src/fixsperl-0
  216.             MD5 Checksum        f13900d122a904a8453a0af4c1bdddc6
  217.  
  218.            Note that this script should be run one time, naming every suidperl
  219.            or sperl file on your system. If you add another version of
  220.            suidperl or sperl to your system, then you must run fixsperl
  221.            on those newly installed versions.
  222.  
  223.  
  224. .........................................................................
  225. Appendix A: Vendor Information
  226.  
  227. Below is information we have received from vendors concerning the
  228. vulnerability described in this advisory. If you do not see your vendor's
  229. name, please contact the vendor directly for information.
  230.  
  231. Apple Computer, Inc.
  232. ====================
  233.         A/UX 3.1.1 and earlier support saved set-{user,group}-ids.
  234.  
  235.         A/UX 3.1.1 and earlier do not have Perl as part of the standard
  236.         product.
  237.  
  238. Data General Corporation
  239. ========================
  240.         Data General does support saved set-user-IDs and set-group-IDs on
  241.         DG/UX.
  242.  
  243.         Data General does not ship suidperl or sperl* with DG/UX.
  244.  
  245. Digital Equipment Corporation
  246. =============================
  247.         Digital UNIX and Digital's ULTRIX Operating systems do support
  248.         saved suid and saved guid in the process context.
  249.  
  250.         Digital does not ship Perl with any operating system.
  251.  
  252. FreeBSD, Inc.
  253. =============
  254.  
  255. This information is taken from FreeBSD advisory SA-96:12.
  256. For the complete text of the advisory, please refer to 
  257.  
  258.         ftp://freebsd.org/pub/CERT/patches/SA-96:12/
  259.  
  260.      This vulnerability is present on all systems with the
  261.      _POSIX_SAVED_IDS functionality extension where suidperl
  262.      has been installed.
  263.  
  264.      One may disable the setuid bit on all copies of the setuid
  265.      version of perl.  This will close the vulnerability but render
  266.      inoperable setuid perl scripts.  No software currently shipping
  267.      as part of FreeBSD relies on this functionality so the impact is
  268.      only to third party software.
  269.  
  270.      As root, execute the commands:
  271.  
  272.          # chmod 111 /usr/bin/suidperl
  273.          # chmod 111 /usr/bin/sperl4.036
  274.  
  275.      In addition, if you have installed the perl5 port:
  276.          # chmod 111 /usr/local/bin/suidperl
  277.          # chmod 111 /usr/local/bin/sperl5.001
  278.  
  279.      then verify that the setuid permissions of the files have been
  280.      removed.  The permissions array should read "-r-xr-xr-x" as
  281.      shown here:
  282.  
  283.          # ls -l /usr/bin/s*perl*
  284.          ---x--x--x  2 root  bin  307200 Jun  1 17:16 /usr/bin/sperl4.036
  285.          ---x--x--x  2 root  bin  307200 Jun  1 17:16 /usr/bin/suidperl
  286.  
  287.      and for the perl5 port:
  288.  
  289.          # ls -l /usr/local/bin/s*perl*
  290.          ---x--x--x  2 root  bin  397312 Jan 22 15:15 /usr/local/bin/sperl5.001
  291.          ---x--x--x  2 root  bin  397312 Jan 22 15:15 /usr/local/bin/suidperl
  292.  
  293. Other information:
  294.  
  295.      *NOTE* A patch for perl is available directly from Larry Wall
  296.      (the author of perl) which solves this vulnerability in a
  297.      different fashion than the FreeBSD patches.  You may apply
  298.      either the FreeBSD patches, or Larry's patches, or both.
  299.      The patches solve the problem via two different mechanisms.
  300.  
  301.      Patches are available which eliminate this vulnerability.
  302.      The following patch should be applied to the system sources and
  303.      suidperl should be rebuilt and reinstalled.
  304.  
  305.      Apply the patch, then:
  306.         # cd /usr/src/gnu/usr.bin/perl/sperl
  307.         # make depend
  308.         # make all
  309.         # make install
  310.  
  311.      A similar patch is also available for the perl5 port.
  312.      Apply the following patch by moving it into the patch
  313.      directory for the port distribution and rebuilding and
  314.      installing perl5:
  315.  
  316.         # cd /usr/ports/lang/perl5
  317.         # cp <location of new patches>/patch-a[ab] patches
  318.         # make all
  319.         # make install
  320.  
  321.      NOTE: These patches do NOT solve the vulnerability for FreeBSD 2.0
  322.            or 2.0.5.  These only solve the problem for 2.1 and later.
  323.            Patches specific to FreeBSD 2.0 and 2.0.5 are available at
  324.            the URL listed above.
  325.  
  326.  
  327. Hewlett-Packard Company
  328. =======================
  329.         HP/UX versions 8.X, 9.X, and 10.X all support saved set-user-id.
  330.  
  331.         None of HP/UX versions 8.X, 9.X, and 10.X have Perl as part of the
  332.         standard product.
  333.  
  334. IBM Corporation
  335. ===============
  336.         AIX versions 3.2.5 and 4.X support saved set-user-id.
  337.  
  338.         AIX versions 3.2.5 and 4.X do not have Perl as part of the standard
  339.         product. However, the SP2's PSSP software does contain suidperl, but
  340.         the program is not installed with the setuid bit set.
  341.  
  342. Linux
  343. =====
  344.         Linux 1.2 and 2.0 support saved set-user-id.
  345.  
  346.         Most distributions of Linux provide suidperl and sperl.
  347.  
  348.         The fixsperl script works on linux, and it is recommended that this
  349.         fix be applied until a new Perl release is made.
  350.  
  351. NEC
  352. ===
  353.  
  354.    OS                    Support Saved Sets?         Provide suidperl?
  355.    -------------------------------------------------------------------
  356.    UX/4800                 yes                             no
  357.    EWS-UX/V (Rel4.2MP)     yes                             no
  358.    UP-UX/V (Rel4.2MP)      yes                             no
  359.    EWS-UX/V (Rel4.2)       yes                             no
  360.  
  361.  
  362. Open Software Foundation
  363. ========================
  364.          OSF/1 1.3 or later support saved set-user-id
  365.  
  366.          OSF/1 1.3 or later does not have Perl as part of the standard
  367.          product.
  368.  
  369. Sony Corporation
  370. ================
  371.         NEWS-OS 4.X does not support saved set-user-id and therefore any
  372.         version of Perl on that system is not vulnerable.
  373.  
  374.         NEWS-OS 6.X does support saved set-user-id.
  375.  
  376. X.org
  377. =====
  378.         None of X.org's development systems are vulnerable to the saved
  379.         set-user-IDs and set-group-IDs problems, and suidperl is not shipped
  380.         with either of our products.
  381.  
  382.  
  383. - ---------------------------------------------------------------------------
  384. The CERT Coordination Center staff thanks Paul Traina, Larry Wall, Eric
  385. Allman, Tom Christiansen, and AUSCERT for their support in the development
  386. of this advisory.
  387. - ---------------------------------------------------------------------------
  388.  
  389. If you believe that your system has been compromised, contact the CERT
  390. Coordination Center or your representative in the Forum of Incident
  391. Response and Security Teams (FIRST).
  392.  
  393. We strongly urge you to encrypt any sensitive information you send by
  394. email. The CERT Coordination Center can support a shared DES key and PGP.
  395. Contact the CERT staff for more information.
  396.  
  397. Location of CERT PGP key:
  398.  
  399.          ftp://info.cert.org/pub/CERT_PGP.key
  400.  
  401. CERT Contact Information
  402. - ------------------------
  403. Email    cert@cert.org
  404.  
  405. Phone    +1 412-268-7090 (24-hour hotline)
  406.                 CERT personnel answer 8:30-5:00 p.m. EST
  407.                 (GMT-5)/EDT(GMT-4), and are on call for
  408.                 emergencies during other hours.
  409.  
  410. Fax      +1 412-268-6989
  411.  
  412. Postal address
  413.         CERT Coordination Center
  414.         Software Engineering Institute
  415.         Carnegie Mellon University
  416.         Pittsburgh PA 15213-3890
  417.         USA
  418.  
  419. CERT publications, information about FIRST representatives, and other
  420. security-related information are available for anonymous FTP from
  421.         http://www.cert.org/
  422.         ftp://info.cert.org/pub/
  423.  
  424. CERT advisories and bulletins are also posted on the USENET newsgroup
  425.         comp.security.announce
  426.  
  427. To be added to our mailing list for CERT advisories and bulletins, send your
  428. email address to
  429.         cert-advisory-request@cert.org
  430.  
  431.  
  432. Copyright 1996 Carnegie Mellon University
  433. This material may be reproduced and distributed without permission provided
  434. it is used for non-commercial purposes and the copyright statement is
  435. included.
  436.  
  437. CERT is a service mark of Carnegie Mellon University.
  438.  
  439.  
  440. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  441. Revision history
  442.  
  443. Aug. 30, 1996  Information previously in the README was inserted into the
  444.                advisory.
  445. July 01, 1996  Appendix, FreeBSD - added an entry for this vendor.
  446. June 27, 1996  Appendix, NEC - added an entry for this vendor.
  447. June 26, 1996  Appendix, Digital - added an entry for this vendor.
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463. -----BEGIN PGP SIGNATURE-----
  464. Version: 2.6.2
  465.  
  466. iQCVAwUBMiTCgXVP+x0t4w7BAQH42wP/WCjDtu4Vbyu0KfyJ4fBd+WQxDPMubopV
  467. i1A5/Ix+C0TYOXddycl5oOmpPt8HzWBCZ1nIu0oU1RWs6W1GI7SZEdf2v4NLHX1y
  468. Y3NKVIiIIc/JRv1PkT8WvELcGlsWZxIRlfQZ6Mqi+dJ4KL4q7+co/mXZ9Fcpe6Dd
  469. 6aeSfh6cu70=
  470. =4WGb
  471. -----END PGP SIGNATURE-----
  472.  
  473.