home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit 2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Texts / Improving-Security / security2.txt < prev    next >
Encoding:
Text File  |  1999-11-04  |  21.9 KB  |  483 lines

  1.  
  2.                Author:              CERT(sm) Coordination Center
  3.  
  4.                 Date:                January 1996
  5.  
  6.                 TEXT-Version:        Markus Hⁿbner
  7.  
  8. The information in this document can help you:
  9.  
  10.    * Determine whether or not your site may have had a break-in.
  11.    * Assess the security of your site.
  12.    * Learn how to make your site more secure.
  13.  
  14. Section A lists several ways to determine whether or not your system has
  15. been compromised. Sections B and C contain lists of UNIX and VMS system
  16. vulnerabilities that have been exploited by intruders to gain unauthorized
  17. access to systems. Section D includes descriptions of tools that can be
  18. used to help secure a system.
  19.  
  20. System administrators can use this document to prevent several types of
  21. break-ins. We encourage system administrators to review all sections of
  22. this document and modify their systems accordingly to close these potential
  23. vulnerabilities.
  24.  
  25. In addition to the information in this document, we provide an 01-README
  26. file, which contains a list and brief description of all CERT advisories.
  27. This file is available by anonymous FTP from
  28.  
  29. ftp://info.cert.org/pub/cert_advisories/01-README
  30.  
  31. We encourage you to get all advisories that pertain to your system(s),
  32. along with the widely applicable advisories, such as those on rdist and
  33. TFTP, and to install all patches or workarounds described in the
  34. advisories.
  35.  
  36. ---------------------------------------------------------------------------
  37.  
  38. How To Determine Whether Your System Has Been Compromised
  39.  
  40.   1. Examine log files such as your 'last' log, process accounting, syslog,
  41.      and C2 security logs for logins from unusual locations or other
  42.      unusual activity. Note that this is not foolproof; many intruders edit
  43.      accounting files in an attempt to hide their activity.
  44.   2. Look everywhere on the system for unusual or hidden files (files that
  45.      start with a period and are normally not shown by ls) as these can be
  46.      used to hide information such as password cracking programs and
  47.      password files from other systems. A favorite trick on UNIX systems is
  48.      to put a hidden directory in a user's account with an unusual name,
  49.      something like '...' or '.. ' (dot dot space space) or '..^G' (dot dot
  50.      control-G). Also, files with names such as '.xx' and '.mail' have been
  51.      used.
  52.   3. Look for setuid files (especially setuid root files) everywhere on
  53.      your system. Intruders often leave setuid copies of /bin/sh around to
  54.      allow them root access at a later time. The UNIX find(1) program can
  55.      be used to hunt for setuid files. You can use the following command to
  56.      find setuid root files on the entire file system. Note that this
  57.      searches the entire directory tree, including NFS/AFS mounted file
  58.      systems.
  59.  
  60.                      find / -user root -perm -4000 -print
  61.  
  62.      Some find(1) commands support an "-xdev" option to avoid searching
  63.      those hierarchies.
  64.  
  65.      Another way to search for setuid files is to use the ncheck(8) command
  66.      on each disk partition. For example, use the following command to
  67.      search for setuid files and special devices on the disk partition
  68.      /dev/rsd0g:
  69.  
  70.                       ncheck -s /dev/rsd0g
  71.  
  72.   4. Check your system binaries to make sure that they haven't been
  73.      changed. We've seen intruders change programs on UNIX systems such as
  74.      login, su, telnet, netstat, ifconfig, ls, find, du, df, libc, sync,
  75.      any binaries referenced in /etc/inetd.conf, and other critical network
  76.      and system programs. On VMS systems, we've seen intruders change
  77.      programs such as loginout.exe and show.exe. Compare the versions on
  78.      your systems with known good copies such as those from your initial
  79.      installation tapes. Be careful of trusting backups; your backups could
  80.      also contain Trojan horses.
  81.  
  82.      Trojan horse programs may produce the same standard checksum and
  83.      timestamp as the legitimate version. Because of this, the standard
  84.      UNIX sum(1) command and the timestamps associated with the programs
  85.      are not sufficient to determine whether the programs have been
  86.      replaced.
  87.  
  88.      The use of cmp(1), MD5, and other cryptographic checksum tools is
  89.      sufficient to detect these Trojan horse programs, provided the
  90.      checksum tools were not available for modification by the intruder.
  91.  
  92.   5. Examine all the files that are run by cron and at. We've seen
  93.      intruders leave back doors in files run from cron or submitted to at.
  94.      These techniques can let an intruder back on the system even after
  95.      you've kicked him or her off. Also, verify that all files/programs
  96.      referenced (directly or indirectly) by the cron and at jobs, and the
  97.      job files themselves, are not world-writable.
  98.   6. Inspect /etc/inetd.conf for unauthorized additions or changes. In
  99.      particular, search for entries that execute a shell program (for
  100.      example, /bin/sh or /bin/csh) and check all programs that are
  101.      specified in /etc/inetd.conf to verify that they are correct and
  102.      haven't been replaced by Trojan horse programs.
  103.   7. Check your system and network configuration files for unauthorized
  104.      entries. In particular, look for '+' (plus sign) entries and
  105.      inappropriate non-local host names in /etc/hosts.equiv,
  106.      /etc/hosts.lpd, and in all .rhosts files (especially root, uucp, ftp,
  107.      and other system accounts) on the system. These files should not be
  108.      world-writable. Furthermore, ensure that these files existed prior to
  109.      any intrusion and have not been created by the intruder.
  110.   8. Examine all machines on the local network when searching for signs of
  111.      intrusion. Most of the time, if one host has been compromised, others
  112.      on the network have been too. This is especially true for networks
  113.      where NIS is running or where hosts trust each other through the use
  114.      of .rhosts files and/or /etc/hosts.equiv files. Also, check any hosts
  115.      with which your users share .rhosts access.
  116.   9. Examine the /etc/passwd file on the system and check for any
  117.      additional or modified accounts. In particular, look for the
  118.      unauthorized creation of new accounts, accounts with no passwords, or
  119.      UID changes (especially UID 0) to existing accounts.
  120.  
  121. UNIX System Configuration Problems That Have Been Exploited
  122.  
  123.      Weak passwords
  124.  
  125.      Intruders often use finger or ruser to discover account names and then
  126.      try simple passwords. Encourage your users to choose passwords that
  127.      are difficult to guess (for example, words that are not in any
  128.      dictionary of words of any language; no proper nouns, including names
  129.      of "famous" real or fictitious characters; no acronyms that are common
  130.      to computer professionals; no simple variations of first or last
  131.      names.) Furthermore, inform your users not to leave any clear-text
  132.      username/password information in files on any system.
  133.  
  134.      A good heuristic for choosing a password is to choose an
  135.      easy-to-remember phrase, such as "By The Dawn's Early Light", and use
  136.      the first letters to form a password. Add some punctuation or mix case
  137.      letters as well. For the phrase above, one example password might be:
  138.      bt}DeL{. (DO NOT use this sample phrase for your password.)
  139.  
  140.      If intruders can get a password file, they usually move or copy it to
  141.      another machine and run password guessing programs on it. These
  142.      programs involve large dictionary searches and run quickly even on
  143.      slow machines. Most systems that do not put any controls on the types
  144.      of passwords used probably have at least one password that can be
  145.      easily guessed.
  146.  
  147.      If you believe that your password file may have been taken, change all
  148.      the passwords on the system. At the very least, you should change all
  149.      system passwords because an intruder may concentrate on those and may
  150.      be able to guess even a reasonably 'good' password.
  151.  
  152.      Section D contains a list of tools, some of which can help you to to
  153.      ensure that users set 'good' passwords and that encrypted passwords
  154.      are not visible to system users.
  155.  
  156.      Accounts without passwords or default passwords
  157.  
  158.      Intruders exploit system default passwords that have not been changed
  159.      since installation,including accounts with vendor-supplied default
  160.      passwords. Be sure to change all default passwords when the software
  161.      is installed. Also, be aware that product upgrades can quietly change
  162.      account passwords to a new default. It is best to change the passwords
  163.      of default accounts after applying updates.
  164.  
  165.      Scan your password file for extra UID 0 accounts, accounts with no
  166.      password, or new entries in the password file. Do not allow any
  167.      accounts without passwords. Remove entries for unused accounts from
  168.      the password file. To disable an account, change the password field in
  169.      the /etc/passwd file to an asterisk '*' and change the login shell to
  170.      /bin/false to ensure that an intruder cannot login to the account from
  171.      a trusted system on the network.
  172.  
  173.      Reusable passwords
  174.  
  175.      Even when excellent passwords are chosen, if these passwords are sent
  176.      in clear text across public networks, they are subject to capture by
  177.      sniffer programs. We recommend moving to one-time passwords,
  178.      especially for authenticated accesses from external networks, and for
  179.      accesses to sensitive resources like name servers and routers. For
  180.      more information, see the appendix of the following advisory:
  181.  
  182.      ftp://info.cert.org/pub/cert_advisories/CA-94:01.network.monitoring.attacks
  183.  
  184.      Use of TFTP (Trivial File Transfer Protocol) to steal password files
  185.  
  186.      To test your system for this vulnerability, connect to your system
  187.      using tftp and try
  188.  
  189.                      get /etc/motd
  190.  
  191.      If you can do this, anyone else on the network can probably get your
  192.      password file. To avoid this problem, either disable tftpd if you
  193.      don't require it or ensure that it is configured with restricted
  194.      access.
  195.  
  196.      If you believe your password file may have been taken, the safest
  197.      course is to change all passwords in the system.
  198.  
  199.      Vulnerabilities in sendmail
  200.  
  201.      There have been a number vulnerabilities identified over the years in
  202.      sendmail(8). To the best of our knowledge, BSD 8.6.9 appears to
  203.      address those vulnerabilities. To establish which version of sendmail
  204.      are running, use telnet to connect to the SMTP port (25) on your
  205.      system:
  206.  
  207.                   telnet  25
  208.  
  209.      We encourage you to keep up to date with the latest version of
  210.      sendmail from your vendor, and ensure that it is up to date with any
  211.      security patches or workarounds detailed in CERT advisories and
  212.      bulletins. See also the Sendmail Bug list.
  213.  
  214.      Old versions of FTP; misconfigured anonymous FTP
  215.  
  216.      Make sure that you are running the most recent version of ftpd. Check
  217.      with your vendor for information on configuration upgrades. Also check
  218.      your anonymous FTP configuration. It is important to follow the
  219.      instructions provided with the operating system to properly configure
  220.      the files and directories available through anonymous FTP (for
  221.      example, file and directory permissions, ownership and group). Note
  222.      that you should not use your system's standard password file or group
  223.      file as the password file or group file for FTP. The anonymous FTP
  224.      root directory and its two subdirectories, etc and bin, should not be
  225.      owned by ftp. For more information, see
  226.  
  227.      ftp://info.cert.org/pub/tech_tips/anonymous_ftp
  228.  
  229.      Inappropriate network configuration file entries
  230.  
  231.      Several vendors supply /etc/hosts.equiv files with a '+' (plus sign)
  232.      entry. The '+' entry should be removed from this file because it means
  233.      that your system will trust all other systems. Other files that should
  234.      not contain a '+' entry include /etc/hosts.lpd and all .rhosts files
  235.      on the system. These files should not be world-writable.
  236.  
  237.      If your /usr/lib/X11/xdm/Xsession file includes the line
  238.  
  239.                      /usr/bin/X11/xhost +
  240.  
  241.      remove that line. If this line remains intact, anyone on the network
  242.      can talk to the X server and potentially stuff commands into windows
  243.      or read console keystrokes.
  244.  
  245.      Misconfiguration of uucp
  246.  
  247.      If your machine supports uucp, check the L.cmds (Permissions) file and
  248.      ensure that only the commands you require are included. This file
  249.      should be owned by root (not by uucp!) and should be world-readable.
  250.      The L.sys (Systems) file should be owned by uucp and protected (600)
  251.      so that only programs running setuid uucp can access it.
  252.  
  253.      Inappropriate 'secure' settings in /etc/ttys and /etc/ttytab
  254.  
  255.      Check the file /etc/ttys or /etc/ttytab depending on the release of
  256.      UNIX being used. The default setting should be that no terminal lines,
  257.      pseudo terminals, or network terminals are set secure except for the
  258.      console.
  259.  
  260.      Inappropriate entries in /usr/lib/aliases
  261.  
  262.      Examine the /usr/lib/aliases (mail alias) file for inappropriate
  263.      entries. Some alias files include an alias named 'uudecode' or just
  264.      'decode'. If this alias exists on your system and you are not
  265.      explicitly using it, then it should be removed.
  266.  
  267.      Inappropriate file and directory protections
  268.  
  269.      Check your system documentation to establish the correct file and
  270.      directory protections and ownership for system files and directories.
  271.      In particular, check the '/' (root) and '/etc' directories, and all
  272.      system and network configuration files. Examine file and directory
  273.      protections before and after installing software or running
  274.      verification utilities. These procedures can cause file and directory
  275.      protections to change.
  276.  
  277.      Old versions of system software
  278.  
  279.      Older versions of operating systems often have security
  280.      vulnerabilities that are well known to intruders. To minimize your
  281.      vulnerability to attacks, keep the version of your operating system up
  282.      to date and apply security patches appropriate to your system(s) as
  283.      soon as they become available.
  284.  
  285.      Use of setuid shell scripts
  286.  
  287.      Setuid shell scripts (especially setuid root) can pose potential
  288.      security problems, a fact that has been well documented in many UNIX
  289.      system administration texts. Do not create or allow setuid shell
  290.      scripts, especially setuid root.
  291.  
  292.      Inappropriate export settings
  293.  
  294.      Wherever possible, file systems should be exported read-only. Check
  295.      the configuration of the /etc/exports files on your hosts. Do not
  296.      self-reference an NFS server in its own exports file. Do not allow the
  297.      exports file to contain a "localhost" entry. Export file systems only
  298.      to hosts that require them. Export only to fully qualified hostnames.
  299.      Ensure that export lists do not exceed 256 characters after the
  300.      aliases have been expanded or that all security patches relating to
  301.      this problem have been applied. Use the showmount(8) utility to check
  302.      that exports are correct.
  303.  
  304. VMS System Vulnerabilities
  305.  
  306.      Accounts with known default passwords
  307.  
  308.      Intruders often exploit system default passwords that have not been
  309.      changed since installation. Be sure to change all default passwords
  310.      when the software is installed. Be aware that product upgrades can
  311.      quietly change account passwords to a new default. It is best to
  312.      change the passwords of default accounts after applying updates.
  313.      Accounts no longer in use should be removed from the authorization
  314.      file and rights database. Dormant accounts should be set to DISUSER.
  315.  
  316.      Intruders also try guessing simple user passwords. See the discussion
  317.      on weak passwords in Section A for suggestions on choosing good
  318.      passwords.
  319.  
  320.      Unauthorized versions of system files
  321.  
  322.      If intruders get into a system, they often modify the programs
  323.      patch.exe, loginout.exe, and show.exe. Compare these programs with
  324.      those found in your distribution media.
  325.  
  326. Software Tools To Assist In Securing Your System
  327.  
  328.  The CERT Coordination Center does not formally review, evaluate, or
  329.  endorse the tools and techniques described. The decision to use the tools
  330.  and techniques described is the responsibility of each user or
  331.  organization, and we encourage each organization to thoroughly evaluate
  332.  new tools and techniques before installation or use.
  333.  
  334.      Shadow passwords
  335.  
  336.      If your UNIX system has a shadow password capability, you should
  337.      consider using it. Under a shadow password system, the /etc/passwd
  338.      file does not have encrypted passwords in the password field. Instead,
  339.      the encrypted passwords are held in a shadow file that is not world
  340.      readable. Consult your system manuals to determine whether a shadow
  341.      password capability is available on your system and to get details of
  342.      how to set up and manage such a facility.
  343.  
  344.      COPS (The Computer Oracle and Password System)
  345.  
  346.      COPS is a publicly available collection of programs that attempt to
  347.      identify security problems in a UNIX system. COPS does not attempt to
  348.      correct any discrepancies found; it simply produces a report of its
  349.      findings. COPS is available by anonymous FTP from
  350.  
  351.      ftp://info.cert.org/pub/tools/cops
  352.  
  353.      and by uucp from
  354.  
  355.                      uunet.uu.net
  356.  
  357.      npasswd
  358.  
  359.      npasswd is a program suite that allows a system manager to enforce
  360.      policies for selecting passwords. This software is available by
  361.      anonymous FTP from
  362.  
  363.      ftp://ftp.cc.utexas.edu:/pub/npasswd/npasswd.tar.Z
  364.  
  365.      TCP/IP wrapper program
  366.  
  367.      This program provides additional network logging information and gives
  368.      a system administrator the ability to deny or allow access from
  369.      certain systems or domains to the host on which the program is
  370.      installed. Installation of this software does not require any
  371.      modification to existing network software or network configuration
  372.      files. This program is available by anonymous FTP from
  373.  
  374.      ftp://info.cert.org/pub/tools/tcp_wrappers
  375.  
  376.      Crack
  377.  
  378.      Crack is a freely available program designed to identify standard UNIX
  379.      DES encrypted passwords that can be found in widely available
  380.      dictionaries by standard guessing techniques outlined in the Crack
  381.      documentation.
  382.  
  383.      Many system administrators run Crack as a regular system
  384.      administration procedure and notify account owners who have
  385.      "crackable" passwords. Crack is available by anonymous FTP from
  386.  
  387.      ftp://info.cert.org/pub/tools/crack
  388.  
  389.      lsof
  390.  
  391.      lsof lists open files for running UNIX processes. lsof is available by
  392.      anonymous FTP from
  393.  
  394.      ftp://vic.cc.purdue.edu:/pub/tools/unix/lsof
  395.  
  396.      MD5
  397.  
  398.      MD5 is a cryptographic checksum program. MD5 takes as input a message
  399.      of arbitrary length and produces as output a 128-bit "fingerprint" or
  400.      "message digest" of the input. It is thought to be computationally
  401.      unfeasible to produce two messages having the same message digest or
  402.      to produce any message having a given prespecified target message
  403.      digest. MD5 is found in RFC 1321. It is available by anonymous FTP
  404.      from
  405.  
  406.      ftp://info.cert.org/pub/tools/md5
  407.  
  408.      Tripwire
  409.  
  410.      Tripwire checks file and directory integrity; it is a utility that
  411.      compares a designated set of files and directories to information
  412.      stored in a previously generated database. Any differences are flagged
  413.      and logged, including added or deleted entries. When run against
  414.      system files on a regular basis, Tripwire enables you to spot changes
  415.      in critical system files and to immediately take appropriate damage
  416.      control measures. Tripwire is available by anonymous FTP from
  417.  
  418.      ftp://info.cert.org/pub/tools/tripwire
  419.  
  420.      ifstatus
  421.  
  422.      This program can be run on UNIX systems to identify network interfaces
  423.      that are in debug or promiscuous mode. Network interfaces in these
  424.      modes may be the sign of an intruder performing network monitoring to
  425.      steal passwords and other traffic (see CERT advisory CA-94:01).
  426.  
  427.      The program does not print any output (unless -v is given) unless it
  428.      finds interfaces in "bad" modes. So, it's easy to run ifstatus from
  429.      cron once an hour or so. If you have a modern cron that mails the
  430.      output of cron jobs to their owner, use a line like this:
  431.  
  432.                      00  *  *  *  * /usr/local/etc/ifstatus
  433.  
  434.      If you have a version of cron that doesn't do this, use the
  435.      "run-ifstatus" shell script instead (edit it to use the right path to
  436.      the command):
  437.  
  438.                      00  *  *  *  * /usr/local/etc/run-ifstatus
  439.  
  440. ---------------------------------------------------------------------------
  441.  
  442. If you believe that your system has been compromised, contact the CERT
  443. Coordination Center or your representative in Forum of Incident Response
  444. and Security Teams (FIRST).
  445.  
  446. Internet E-mail: cert@cert.org
  447.  
  448. Telephone: 412-268-7090 (24-hour hotline)
  449.  
  450.            CERT personnel answer 8:30 a.m.-5:00 p.m. EST(GMT-5)/EDT(GMT-4),
  451.  
  452.            and are on call for emergencies during other hours.
  453.  
  454. CERT Coordination Center Software Engineering Institute Carnegie Mellon
  455. University Pittsburgh, PA 15213-3890
  456.  
  457. The CERT Coordination Center issues CERT advisories and bulletins, which
  458. warn you about problems and inform you about preventive techniques. We
  459. maintain a CERT advisory mailing list, which is also distributed via the
  460. USENET newsgroup comp.security.announce. If you are unable to receive the
  461. newsgroup comp.security.announce and would like to be added to the advisory
  462. mailing list, send mail to
  463.  
  464.      cert-advisory-request@cert.org
  465.  
  466. Past advisories and bulletins, information about FIRST representatives, and
  467. other information related to computer security are available for anonymous
  468. FTP from info.cert.org.
  469.  
  470. Copyright 1995 Carnegie Mellon University
  471.  
  472. This material may be reproduced and distributed without permission provided
  473. it is used for noncommercial purposes and the copyright statement is
  474. included.
  475.  
  476. CERT is a service mark of Carnegie Mellon University.
  477.  
  478. The CERT Coordination Center is sponsored by the Advanced Research Projects
  479. Agency (ARPA). The Software Engineering Institute is sponsored by the U.S.
  480. Department of Defense.
  481.  
  482.                          Back to the Security-Page
  483.