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

  1.  
  2. -----BEGIN PGP SIGNED MESSAGE-----
  3.  
  4. =============================================================================
  5. CERT(sm) Advisory CA-95:16               
  6. Original issue date: November 30, 1995
  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: wu-ftpd Misconfiguration Vulnerability
  14. - -----------------------------------------------------------------------------
  15.  
  16. A vulnerability exists with certain configurations of the SITE EXEC command
  17. in the Washington University ftpd, also known as wu-ftpd. Exploitation of
  18. this vulnerability may allow root access from any account on the system.
  19.  
  20. The vulnerable configuration is known to exist in numerous Linux distributions
  21. and is currently being actively exploited by intruders.
  22.  
  23. It should be noted that this vulnerability is not necessarily limited to Linux
  24. but may exist on any wu-ftpd installation. Thus, all users of the wu-ftpd
  25. program, not just the Linux users, should take this opportunity to verify the
  26. configuration of their daemons. Note that versions of wu-ftpd before the 2.4
  27. release contain serious security vulnerabilities and should be updated
  28. immediately.
  29.  
  30. Section III contains instructions for disabling ftpd and correcting the
  31. configuration.
  32.  
  33. We will update this advisory as we receive additional information.
  34. Please check advisory files regularly for updates that relate to your site.
  35.  
  36. - -----------------------------------------------------------------------------
  37.  
  38. I.   Description
  39.  
  40.      There is a problem with the default configuration of the Washington
  41.      University FTP Server version 2.4 in major Linux distributions, including
  42.      but not limited to Slackware 2.0, 2.1, 2.2, 2.3, Yggdrasil Plug&Play
  43.      Fall'94, and the Debian Distribution. By exploiting this problem, any
  44.      user who is able to log into a system having the vulnerable configuration
  45.      via FTP using their login, and not the anonymous login, may gain root
  46.      access.
  47.  
  48.      Other systems besides Linux can be configured to be vulnerable although
  49.      the standard wu-ftpd 2.4 source code as distributed is not vulnerable.
  50.  
  51.      The problem is that the variable _PATH_EXECPATH was set to "/bin" in
  52.      the configuration file src/pathnames.h when the distribution binary
  53.      was built. _PATH_EXECPATH should be set to "/bin/ftp-exec" or a similar
  54.      directory that does not contain a shell or command interpreter, for
  55.      example. The source code shipped with the Linux distributions contains
  56.      the correct value ("/bin/ftp-exec") despite the incorrect distribution
  57.      binary. You should verify that _PATH_EXECPATH has the correct value
  58.      before recompiling.
  59.  
  60.      Note that the documentation for wu-ftpd states that the directory
  61.      defined by _PATH_EXECPATH is relative to ~ftp, the ftp home directory
  62.      as specified in the password file. This is misleading. The pathname
  63.      is relative to ~ftp for anonymous users only. This pathname is relative
  64.      to "/" for other user sessions.
  65.  
  66. II.  Impact
  67.  
  68.      Any user with a local account on a system offering FTP services
  69.      with the vulnerable configuration may gain root access. Support for
  70.      anonymous FTP access is not required to exploit this vulnerability.
  71.  
  72.  
  73. III. How to determine if you are vulnerable
  74.  
  75.      All systems running wu-ftpd should be checked to determine if the
  76.      configuration is vulnerable.
  77.  
  78.      To test your configuration, access the FTP server using a legitimate user
  79.      account (not an anonymous FTP login) and login to your FTP server. For
  80.      example:
  81.  
  82.           srchost> ftp ftphost
  83.           Connected to ftphost
  84.           220 ftphost FTP server (Version wu-2.4(2) Mon Apr 18 09:12:35 [...]
  85.           ready.
  86.           Name (srchost:joe):
  87.           331 Password required for joe.
  88.           Password:
  89.           230 User joe logged in.
  90.  
  91.      Then type:
  92.  
  93.            ftp> quote site exec echo problem
  94.  
  95.      If you see the following response, then you are not vulnerable:
  96.  
  97.              200-echo problem
  98.              200  (end of 'echo problem')
  99.  
  100.      However, if you see this following response, then you are vulnerable
  101.      (note the additional '200-problem' entry):
  102.  
  103.              200-echo problem
  104.              200-problem
  105.              200  (end of 'echo problem')
  106.  
  107.  
  108. IV. Solution
  109.  
  110.      If you have the vulnerability, we recommend that you turn off ftpd
  111.      immediately using the method described in Section A below. Once you have
  112.      done that, you can then decide whether to rebuild or fetch a new ftpd
  113.      binary. 
  114.  
  115.      If you have built wu-ftpd from a source distribution, follow the steps
  116.      in Sections B.2 and B.3 below. 
  117.  
  118.      Once you have eliminated this vulnerability, turn on ftpd with the
  119.      method described in Section C below.
  120.     
  121.      A. Disable ftpd
  122.  
  123.         To disable ftpd, do the following as root.
  124.         
  125.         1. Shut down the FTP server using the ftpshut command.  This command
  126.            blocks all connections to the FTP server.
  127.            
  128.            For ftpshut to work correctly, the ftpaccess(5) file will need a
  129.            shutdown directive that names a file used by wu-ftpd to indicate
  130.            that the server is shutdown. If your ftpaccess file does not have
  131.            such a directive, add one to that file. When added, use ftpshut(8)
  132.            to shut down the server. Once the server has been shutdown, all
  133.            new incoming FTP requests will fail.
  134.  
  135.            Here is an example of the ftpshut command:
  136.        
  137.                     ftpshut now 
  138.  
  139.         2. Verify that the FTP service has been shut down by attempting to
  140.            connect to it. You should see a message that contains a line
  141.            similar to the following:
  142.  
  143.                     hostname FTP server shut down -- please try again later
  144.            
  145.            where hostname is the host from which you are requesting
  146.            FTP service.
  147.  
  148.  
  149.      B. Correct the configuration
  150.  
  151.         Item 1 below applies to those running Debian Linux.  Item 2 applies
  152.         to all other Linux systems.  Item 3 applies to those who are building
  153.         wu-ftpd from source on systems other than Linux.
  154.  
  155.         1. If you are running Debian Linux, obtain a fixed binary, 
  156.            available from the following location, and install this binary.
  157.  
  158.          ftp://ftp.debian.org/debian/debian-0.93/binary/net/wu-ftpd-2.4-14.deb
  159.          MD5 (wu-ftpd-2.4-14.deb) = c00a0aac75216bf83568aee4c2e7d168
  160.  
  161.         2. If you are running any version of Linux, there is a version of
  162.            the source code available that has been improved to compile more
  163.            cleanly. It too is correctly configured for SITE EXEC. It is
  164.            available from (file wu-ftpd-2.4-fixed.tar.gz)
  165.  
  166.          ftp://bach.cis.temple.edu/pub/Linux/security/wu-ftpd-2.4-fix/
  167.          MD5 (wu-ftpd-2.4-fixed.tar.gz) = 3e1c6fd7cd6757e45894df0d3638b524
  168.  
  169.            This version is also correctly configured for the SITE EXEC
  170.            command and can be compiled and installed. Consult Section
  171.            IV below for suggestions on how to configure wu-ftpd.
  172.  
  173.         3. If you are running a version of wu-ftpd before version 2.4,
  174.            you should upgrade to version 2.4 first. That version is
  175.            available from
  176.  
  177.          ftp://wuarchive.wustl.edu/packages/wuarchive-ftpd/wu-ftpd-2.4.tar.Z
  178.          MD5 (wu-ftpd-2.4.tar.Z) = 57f1a962c90a9b12825d39af518df433
  179.  
  180.            Version 2.4 is correctly configured for the SITE EXEC command
  181.            and can be compiled and installed. Consult Section IV below for 
  182.            suggestions on how to configure wu-ftpd.
  183.  
  184.  
  185.      C. Enabling ftpd
  186.  
  187.         1. To turn ftpd back on, delete the file referenced by the shutdown
  188.            directive in your ftpaccess file.
  189.  
  190.         2. Verify that the FTP service has been enabled by attempting to
  191.            connect to it. You should see a message that contains lines
  192.            similar to the following:
  193.  
  194. srchost> ftp ftphost
  195. Connected to ftphost
  196. 220 ftphost FTP server (Version wu-2.4(3) Mon Apr 3 16:53:11 EDT 1995) ready.
  197. Name (srchost:joe):
  198.  
  199. IV.  Advice on configuring the FTP Daemon for SITE EXEC
  200.  
  201.      Here are some configuration guidelines for the directories named by
  202.      the _PATH_EXECPATH variable.
  203.  
  204.      1. Directories used by SITE EXEC: The documentation for wu-ftpd
  205.         states that the directory defined by the _PATH_EXECPATH variable is
  206.         relative to ~ftp, the ftp home directory as specified in the password
  207.         file. This is misleading. The pathname is relative to ~ftp for
  208.         anonymous users only. The pathname is relative to "/" for all other
  209.         user sessions.
  210.  
  211.         Therefore, you need to check the two directories used by the SITE
  212.         EXEC command. For example, if the _PATH_EXECPATH variable is set to
  213.         /bin/ftp-exec, then wu-ftpd searches the ~ftp/bin/ftp-exec directory
  214.         for programs specified by SITE EXEC when the anonymous login is used,
  215.         and the /bin/ftp-exec directory specified by SITE EXEC when any other
  216.         login is used.
  217.  
  218.      2. Contents of the directories used by SITE EXEC: The commands installed
  219.         in these directories can be executed by the SITE EXEC command. We
  220.         strongly recommend that this directory contain only those programs
  221.         that you wish to be executed by those users who connect to your FTP
  222.         server. An example of a program to install in these directories is
  223.         the ls program. Programs that should not be installed in these
  224.         directories are shells, for example sh or csh, and command
  225.         interpreters, for example awk and perl.
  226.  
  227.  
  228. - ---------------------------------------------------------------------------
  229. The CERT Coordination Center thanks AUSCERT, the Australian response team, and
  230. Alexander O. Yuriev, Temple University, author of Linux Security Updates, for
  231. their support in responding to this problem. Linux Security Updates are
  232. available from 
  233.         http://bach.cis.temple.edu/linux/linux-security/
  234. - ---------------------------------------------------------------------------
  235.  
  236. If you believe that your system has been compromised, contact the CERT
  237. Coordination Center or your representative in the Forum of Incident
  238. Response and Security Teams (FIRST).
  239.  
  240. If you wish to send sensitive incident or vulnerability information to
  241. CERT staff by electronic mail, we strongly advise that the email be
  242. encrypted. The CERT Coordination Center can support a shared DES key, PGP
  243. (public key available via anonymous FTP on info.cert.org), or PEM (contact
  244. CERT staff for details).
  245.  
  246. Internet email: cert@cert.org
  247. Telephone: +1 412-268-7090 (24-hour hotline)
  248.            CERT personnel answer 8:30 a.m.-5:00 p.m. EST(GMT-5)/EDT(GMT-4),
  249.            and are on call for emergencies during other hours.
  250. Fax: +1 412-268-6989
  251.  
  252. Postal address:  CERT Coordination Center
  253.                  Software Engineering Institute
  254.                  Carnegie Mellon University
  255.                  Pittsburgh, PA 15213-3890
  256.                  USA
  257.  
  258. CERT advisories and bulletins are posted on the USENET newsgroup
  259. comp.security.announce. If you would like to have future advisories and
  260. bulletins mailed to you or to a mail exploder at your site, please send mail
  261. to cert-advisory-request@cert.org.
  262.  
  263. Past CERT publications, information about FIRST representatives, and
  264. other information related to computer security are available for anonymous
  265. FTP from info.cert.org. 
  266.  
  267.  
  268.  
  269. Copyright 1995, 1996 Carnegie Mellon University
  270. This material may be reproduced and distributed without permission provided it
  271. is used for noncommercial purposes and the copyright statement is included.
  272.  
  273. CERT is a service mark of Carnegie Mellon University.
  274.  
  275.  
  276. =============================================================================
  277. UPDATES
  278.  
  279. Information for Solaris 2.4
  280. - ---------------------------
  281.     After the advisory was originally issued, Charles Jardine <cj10@cam.ac.uk>
  282.     provided the following information.
  283.  
  284.     The problem with the SITE EXEC command is that programs spawned by
  285.     wu-ftpd are run as the effective user and group id of the logged in
  286.     user but real user and group id of root (or however wu-ftpd is started
  287.     by inetd, usually root).
  288.  
  289.     To address this, the following can be used as a basis for a patch.
  290.     (Note that this patch works for Solaris 2.4 compiled with gcc-2.7.2.)
  291.  
  292.  
  293.     *** /tmp/T0a001YI       Mon Dec  4 10:22:13 1995
  294.     --- popen.c     Mon Dec  4 10:22:08 1995
  295.     ***************
  296.     *** 141,146 ****
  297.     --- 141,158 ----
  298.                   }
  299.                   (void) close(pdes[1]);
  300.               }
  301.     + /*
  302.     +  * This fixes the ``real'' problem with SITE EXEC
  303.     +  */
  304.     +       {
  305.     +               uid_t u = geteuid();
  306.     +               gid_t g = getegid();
  307.     + 
  308.     +               setuid(0);
  309.     +               setgid(g);
  310.     +               setuid(u);
  311.     +       }
  312.     + 
  313.               execv(gargv[0], gargv);
  314.               _exit(1);
  315.           }
  316.  
  317.  
  318.  
  319. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  320. Revision history
  321.  
  322. Aug. 30, 1996  Information previously in the README was inserted
  323.                into the advisory.
  324. Jan. 19, 1996  Updates - Added code that can be used as the basis for a patch
  325.                for the SITE EXEC command for Solaris 2.4.
  326. Dec. 19, 1995  Sec. III - Expanded the explanation of how to determine if
  327.                you are vulnerable.
  328.  
  329.  
  330.  
  331.  
  332.  
  333. -----BEGIN PGP SIGNATURE-----
  334. Version: 2.6.2
  335.  
  336. iQCVAwUBMiS7Q3VP+x0t4w7BAQFzIwP/YFLnjg2klq6btVx3aRTrphoG6+/6WsEf
  337. Vc0nhGUghM9uYlWPmNdWw6fRS2I7OmDBF4gzyP42KeltflQzl0/Om+Nx+SRWfe7Z
  338. X0JXmiZzcuId2bS6tKB2M1UnNqnELLx7xnHLyOPtTis3Hxdw2KaJqMwPYRIZcAoA
  339. 9GCF2SkC978=
  340. =ZfNi
  341. -----END PGP SIGNATURE-----
  342.  
  343.