home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / infoguide / advanced / security / unix-secure.txt < prev   
Text File  |  1997-12-01  |  154KB  |  4,687 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                                        Final Report + April 1990
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                     IMPROVING THE SECURITY OF YOUR      UNIX SYSTEM
  14.  
  15.  
  16.                     David A. Curry, Systems Programmer
  17.                     Information and Telecommunications Sciences and Technology Division
  18.  
  19.                     ITSTD-721-FR-90-21
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.                     Approved:
  44.  
  45.                     Paul K. Hyder, Manager
  46.                     Computer Facility
  47.  
  48.                     Boyd C. Fair, General Manager
  49.                     Division Operations Section
  50.  
  51.                     Michael S. Frankel, Vice President
  52.                     Information and Telecommunications Sciences and Technology Division
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.           SRI International  333 Ravenswood Avenue + Menlo Park, CA 94025-3493 + (415) 326-6200 + FAX: (415) 326-5512 + Telex: 334486
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.                                        SECTION 1
  75.  
  76.                                      INTRODUCTION
  77.  
  78.  
  79.           1.1   UNIX SECURITY
  80.  
  81.  
  82.  
  83.                  The UNIX operating system, although now in widespread  use
  84.             in  environments  concerned  about  security,  was  not  really
  85.             designed with security in mind [Ritc75].  This  does  not  mean
  86.             that  UNIX  does  not  provide any security mechanisms; indeed,
  87.             several very good ones are available.  However, most  ``out  of
  88.             the  box''  installation  procedures from companies such as Sun
  89.             Microsystems still install the operating  system  in  much  the
  90.             same  way  as it was installed 15 years ago:  with little or no
  91.             security enabled.
  92.  
  93.                  The reasons for this state of affairs are largely histori-
  94.             cal.   UNIX  was  originally designed by programmers for use by
  95.             other programmers.  The environment in which it  was  used  was
  96.             one of open cooperation, not one of privacy.  Programmers typi-
  97.             cally collaborated with each other on projects, and hence  pre-
  98.             ferred  to be able to share their files with each other without
  99.             having to climb over security hurdles.  Because the first sites
  100.             outside  of  Bell  Laboratories to install UNIX were university
  101.             research laboratories, where a similar environment existed,  no
  102.             real need for greater security was seen until some time later.
  103.  
  104.                  In the early 1980s, many universities began to move  their
  105.             UNIX systems out of the research laboratories and into the com-
  106.             puter centers, allowing (or forcing) the user population  as  a
  107.             whole  to  use  this new and wonderful system.  Many businesses
  108.             and government sites began to install  UNIX  systems  as  well,
  109.             particularly  as  desktop workstations became more powerful and
  110.             affordable.  Thus, the UNIX operating system is no longer being
  111.             used only in environments where open collaboration is the goal.
  112.             Universities require their students to use the system for class
  113.             assignments,  yet  they  do not want the students to be able to
  114.             copy from each other.  Businesses use their  UNIX  systems  for
  115.             confidential  tasks  such  as bookkeeping and payroll.  And the
  116.             government uses UNIX systems for various unclassified yet  sen-
  117.             sitive purposes.
  118.  
  119.                  To complicate matters, new features  have  been  added  to
  120.             UNIX  over  the  years,  making security even more difficult to
  121.             control.  Perhaps  the  most  problematic  features  are  those
  122.           _________________________
  123.           UNIX is a registered trademark of AT&T.  VAX is  a  trademark  of
  124.           Digital  Equipment  Corporation.  Sun-3 and NFS are trademarks of
  125.           Sun Microsystems.  Annex is a trademark of Xylogics, Inc.
  126.  
  127.  
  128.  
  129.                                           1
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.             relating to networking:  remote login,  remote  command  execu-
  142.             tion,  network  file  systems, diskless workstations, and elec-
  143.             tronic mail.  All of these features have increased the  utility
  144.             and  usability  of UNIX by untold amounts.  However, these same
  145.             features, along with the widespread connection of UNIX  systems
  146.             to  the  Internet  and  other networks, have opened up many new
  147.             areas of vulnerability to unauthorized abuse of the system.
  148.  
  149.  
  150.           1.2   THE INTERNET WORM
  151.  
  152.  
  153.  
  154.                  On the evening of November  2,  1988,  a  self-replicating
  155.             program,  called  a worm, was released on the Internet [Seel88,
  156.             Spaf88, Eich89].  Overnight, this  program  had  copied  itself
  157.             from  machine  to  machine, causing the machines it infected to
  158.             labor under huge loads, and denying service  to  the  users  of
  159.             those  machines.   Although the program only infected two types
  160.             of computers,* it spread quickly, as did  the  concern,  confu-
  161.             sion,  and  sometimes  panic  of  system  administrators  whose
  162.             machines were affected.  While many system administrators  were
  163.             aware that something like this could theoretically happen - the
  164.             security holes exploited by the worm  were  well  known  -  the
  165.             scope  of the worm's break-ins came as a great surprise to most
  166.             people.
  167.  
  168.                  The worm itself did  not  destroy  any  files,  steal  any
  169.             information  (other  than account passwords), intercept private
  170.             mail, or plant other destructive software  [Seel88].   However,
  171.             it did manage to severely disrupt the operation of the network.
  172.             Several sites, including parts of  MIT,  NASA's  Ames  Research
  173.             Center  and  Goddard  Space  Flight  Center, the Jet Propulsion
  174.             Laboratory, and the U. S. Army Ballistic  Research  Laboratory,
  175.             disconnected themselves from the Internet to avoid recontamina-
  176.             tion.  In addition, the Defense Communications  Agency  ordered
  177.             the  connections  between the MILNET and ARPANET shut down, and
  178.             kept them down for nearly 24 hours  [Eich89,  Elme88].   Ironi-
  179.             cally,  this was perhaps the worst thing to do, since the first
  180.             fixes to combat the  worm  were  distributed  via  the  network
  181.             [Eich89].
  182.  
  183.                  This incident was perhaps the most widely  described  com-
  184.             puter  security  problem  ever.   The  worm was covered in many
  185.             newspapers and magazines around the country including  the  New
  186.             York  Times,  Wall  Street  Journal,  Time  and  most computer-
  187.           _________________________
  188.             * Sun-3 systems from Sun  Microsystems  and  VAX  systems  from
  189.           Digital  Equipment  Corp.,  both running variants of 4.x BSD UNIX
  190.           from the University of California at Berkeley.
  191.  
  192.  
  193.  
  194.  
  195.                                           2
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.             oriented technical publications, as well as on all three  major
  208.             television  networks, the Cable News Network, and National Pub-
  209.             lic Radio.  In January 1990, a  United  States  District  Court
  210.             jury found Robert Tappan Morris, the author of the worm, guilty
  211.             of charges brought against him under a  1986  federal  computer
  212.             fraud  and  abuse law.  Morris faces up to five years in prison
  213.             and a $250,000 fine [Schu90].  Sentencing is scheduled for  May
  214.             4, 1990.
  215.  
  216.  
  217.           1.3   SPIES AND ESPIONAGE
  218.  
  219.  
  220.  
  221.                  In August  1986,  the  Lawrence  Berkeley  Laboratory,  an
  222.             unclassified  research laboratory at the University of Califor-
  223.             nia at Berkeley,  was  attacked  by  an  unauthorized  computer
  224.             intruder  [Stol88, Stol89].  Instead of immediately closing the
  225.             holes the intruder was using, the system  administrator,  Clif-
  226.             ford  Stoll,  elected  to  watch  the intruder and document the
  227.             weaknesses he  exploited.   Over  the  next  10  months,  Stoll
  228.             watched  the  intruder  attack  over  400  computers around the
  229.             world, and successfully enter about 30.  The  computers  broken
  230.             into  were located at universities, military bases, and defense
  231.             contractors [Stol88].
  232.  
  233.                  Unlike many intruders seen on the Internet, who  typically
  234.             enter  systems  and  browse  around  to see what they can, this
  235.             intruder was looking for something specific.   Files  and  data
  236.             dealing  with the Strategic Defense Initiative, the space shut-
  237.             tle, and other military topics all  seemed  to  be  of  special
  238.             interest.  Although it is unlikely that the intruder would have
  239.             found any truly classified  information  (the  Internet  is  an
  240.             unclassified  network),  it  was  highly probable that he could
  241.             find a wealth of sensitive material [Stol88].
  242.  
  243.                  After a year of tracking the intruder (eventually  involv-
  244.             ing  the FBI, CIA, National Security Agency, Air Force Intelli-
  245.             gence, and authorities in West Germany), five men in  Hannover,
  246.             West  Germany  were  arrested.   In  March  1989, the five were
  247.             charged with espionage:  they had  been  selling  the  material
  248.             they  found  during their exploits to the KGB.  One of the men,
  249.             Karl Koch (``Hagbard''), was later found burned to death in  an
  250.             isolated  forest  outside  Hannover.  No suicide note was found
  251.             [Stol89].  In February 1990, three  of  the  intruders  (Markus
  252.             Hess,  Dirk  Bresinsky,  and  Peter  Carl)  were  convicted  of
  253.             espionage in a German court  and  sentenced  to  prison  terms,
  254.             fines, and the loss of their rights to participate in elections
  255.             [Risk90].  The last of the intruders, Hans Hubner  (``Pengo''),
  256.             still faces trial in Berlin.
  257.  
  258.  
  259.  
  260.  
  261.                                           3
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.           1.4   OTHER BREAK-INS
  274.  
  275.  
  276.  
  277.                  Numerous other computer security problems have occurred in
  278.             recent  years,  with  varying levels of publicity.  Some of the
  279.             more widely known incidents include break-ins  on  NASA's  SPAN
  280.             network [McLe87], the IBM ``Christmas Virus'' [Risk87], a virus
  281.             at Mitre Corp. that caused the MILNET to  be  temporarily  iso-
  282.             lated from other networks [Risk88], a worm that penetrated DEC-
  283.             NET networks [Risk89a], break-ins on  U.  S.  banking  networks
  284.             [Risk89b], and a multitude of viruses, worms, and trojan horses
  285.             affecting personal computer users.
  286.  
  287.  
  288.           1.5   SECURITY IS IMPORTANT
  289.  
  290.  
  291.  
  292.                  As the previous stories demonstrate, computer security  is
  293.             an  important  topic.   This  document  describes  the security
  294.             features provided by the UNIX operating system,  and  how  they
  295.             should  be  used.  The discussion centers around version 4.x of
  296.             SunOS, the version of UNIX sold by Sun Microsystems.   Most  of
  297.             the  information  presented  applies equally well to other UNIX
  298.             systems.  Although there is no way  to  make  a  computer  com-
  299.             pletely  secure against unauthorized use (other than to lock it
  300.             in a room and turn it off), by following  the  instructions  in
  301.             this  document  you  can  make  your  system impregnable to the
  302.             ``casual'' system cracker,* and make it more difficult for  the
  303.             sophisticated cracker to penetrate.
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.           _________________________
  314.  
  315.             * The term ``hacker,'' as applied to computer users, originally
  316.           had an honorable connotation:  ``a person who enjoys learning the
  317.           details  of  programming  systems  and  how  to   stretch   their
  318.           capabilities  - as opposed to most users of computers, who prefer
  319.           to  learn  only  the   minimum   amount   necessary''   [Stee88].
  320.           Unfortunately,  the media has distorted this definition and given
  321.           it a dishonorable meaning.  In deference to the true hackers,  we
  322.           will use the term ``cracker'' throughout this document.
  323.  
  324.  
  325.  
  326.  
  327.                                           4
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.                                        SECTION 2
  341.  
  342.                                   IMPROVING SECURITY
  343.  
  344.  
  345.  
  346.                  UNIX system security can be divided into three main  areas
  347.             of  concern.   Two of these areas, account security and network
  348.             security, are primarily  concerned  with  keeping  unauthorized
  349.             users  from gaining access to the system.  The third area, file
  350.             system security,  is  concerned  with  preventing  unauthorized
  351.             access,  either  by  legitimate  users or crackers, to the data
  352.             stored in the system.  This section describes the UNIX security
  353.             tools  provided to make each of these areas as secure as possi-
  354.             ble.
  355.  
  356.  
  357.           2.1   ACCOUNT SECURITY
  358.  
  359.  
  360.  
  361.                  One of the easiest ways for a cracker to get into a system
  362.             is by breaking into someone's account.  This is usually easy to
  363.             do, since many systems have old accounts whose users have  left
  364.             the organization, accounts with easy-to-guess passwords, and so
  365.             on.  This section describes methods that can be used  to  avoid
  366.             these problems.
  367.  
  368.  
  369.           2.1.1   Passwords
  370.  
  371.  
  372.  
  373.                  The password is the most vital part of UNIX account  secu-
  374.             rity.  If a cracker can discover a user's password, he can then
  375.             log in to the system and operate with all the  capabilities  of
  376.             that user.  If the password obtained is that of the super-user,
  377.             the problem is more serious:  the cracker will  have  read  and
  378.             write  access  to  every  file on the system.  For this reason,
  379.             choosing secure passwords is extremely important.
  380.  
  381.                  The UNIX passwd program [Sun88a, 379] places very few res-
  382.             trictions  on  what  may  be used as a password.  Generally, it
  383.             requires that passwords contain five or more lowercase letters,
  384.             or  four  characters  if a nonalphabetic or uppercase letter is
  385.             included.  However, if the  user  ``insists''  that  a  shorter
  386.             password be used (by entering it three times), the program will
  387.             allow it.  No checks  for  obviously  insecure  passwords  (see
  388.             below)  are  performed.   Thus, it is incumbent upon the system
  389.             administrator to ensure that the passwords in use on the system
  390.  
  391.  
  392.  
  393.                                           5
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.             are secure.
  406.  
  407.                  In [Morr78], the authors describe experiments conducted to
  408.             determine typical users' habits in the choice of passwords.  In
  409.             a collection of 3,289 passwords, 16% of  them  contained  three
  410.             characters or less, and an astonishing 86% were what could gen-
  411.             erally be described as  insecure.   Additional  experiments  in
  412.             [Gram84]  show  that  by  trying  three  simple guesses on each
  413.             account - the login name, the login name in  reverse,  and  the
  414.             two  concatenated  together  -  a  cracker can expect to obtain
  415.             access to between 8 and 30 percent of the accounts on a typical
  416.             system.   A second experiment showed that by trying the 20 most
  417.             common female first names, followed by a single digit (a  total
  418.             of  200  passwords), at least one password was valid on each of
  419.             several dozen machines surveyed.   Further  experimentation  by
  420.             the  author  has  found  that by trying variations on the login
  421.             name, user's first and last names, and a list  of  nearly  1800
  422.             common  first  names, up to 50  percent of the passwords on any
  423.             given system can be cracked in a matter of two or three days.
  424.  
  425.  
  426.           2.1.1.1   Selecting Passwords
  427.  
  428.  
  429.  
  430.                  The object when choosing a password is to make it as  dif-
  431.             ficult as possible for a cracker to make educated guesses about
  432.             what you've chosen.  This  leaves  him  no  alternative  but  a
  433.             brute-force   search,  trying  every  possible  combination  of
  434.             letters, numbers, and punctuation.  A search of this sort, even
  435.             conducted on a machine that could try one million passwords per
  436.             second (most  machines  can  try  less  than  one  hundred  per
  437.             second),  would require, on the average, over one hundred years
  438.             to complete.  With this as our goal, and by using the  informa-
  439.             tion  in  the  preceding text, a set of guidelines for password
  440.             selection can be constructed:
  441.  
  442.                  +    Don't  use  your  login  name  in  any  form  (as-is,
  443.                       reversed, capitalized, doubled, etc.).
  444.  
  445.                  +    Don't use your first or last name in any form.
  446.  
  447.                  +    Don't use your spouse's or child's name.
  448.  
  449.                  +    Don't use other  information  easily  obtained  about
  450.                       you.   This includes license plate numbers, telephone
  451.                       numbers, social security numbers, the brand  of  your
  452.                       automobile, the name of the street you live on, etc.
  453.  
  454.                  +    Don't use a password of all digits, or all  the  same
  455.                       letter.  This significantly decreases the search time
  456.  
  457.  
  458.  
  459.                                           6
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.                       for a cracker.
  472.  
  473.                  +    Don't use a word contained  in  (English  or  foreign
  474.                       language)  dictionaries,  spelling  lists,  or  other
  475.                       lists of words.
  476.  
  477.                  +    Don't use a password shorter than six characters.
  478.  
  479.                  +    Do use a password with mixed-case alphabetics.
  480.  
  481.                  +    Do use  a  password  with  nonalphabetic  characters,
  482.                       e.g., digits or punctuation.
  483.  
  484.                  +    Do use a password that is easy to  remember,  so  you
  485.                       don't have to write it down.
  486.  
  487.                  +    Do use a password that you can type quickly,  without
  488.                       having to look at the keyboard.  This makes it harder
  489.                       for someone to steal your password by  watching  over
  490.                       your shoulder.
  491.  
  492.                  Although this list may seem to restrict  passwords  to  an
  493.             extreme,  there  are several methods for choosing secure, easy-
  494.             to-remember passwords that obey the above rules.  Some of these
  495.             include the following:
  496.  
  497.                  +    Choose a line or two from a song or poem, and use the
  498.                       first  letter of each word.  For example, ``In Xanadu
  499.                       did Kubla  Kahn  a  stately  pleasure  dome  decree''
  500.                       becomes ``IXdKKaspdd.''
  501.  
  502.                  +    Alternate  between  one  consonant  and  one  or  two
  503.                       vowels,  up  to eight characters.  This provides non-
  504.                       sense words that are usually pronounceable, and  thus
  505.                       easily  remembered.   Examples  include  ``routboo,''
  506.                       ``quadpop,'' and so on.
  507.  
  508.                  +    Choose two short words and concatenate them  together
  509.                       with  a punctation character between them.  For exam-
  510.                       ple: ``dog;rain,'' ``book+mug,'' ``kid?goat.''
  511.  
  512.                  The importance of obeying these password  selection  rules
  513.             cannot  be  overemphasized.   The Internet worm, as part of its
  514.             strategy for breaking into new  machines,  attempted  to  crack
  515.             user  passwords.   First, the worm tried simple choices such as
  516.             the login name, user's first and last names, and so on.   Next,
  517.             the  worm  tried each word present in an internal dictionary of
  518.             432 words (presumably  Morris  considered  these  words  to  be
  519.             ``good''  words  to  try).   If all else failed, the worm tried
  520.             going through the system  dictionary,  /usr/dict/words,  trying
  521.             each   word  [Spaf88].   The  password  selection  rules  above
  522.  
  523.  
  524.  
  525.                                           7
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.             successfully guard against all three of these strategies.
  538.  
  539.  
  540.           2.1.1.2   Password Policies
  541.  
  542.  
  543.  
  544.                  Although asking users to select secure passwords will help
  545.             improve  security,  by  itself  it  is  not enough.  It is also
  546.             important to form a set of password  policies  that  all  users
  547.             must obey, in order to keep the passwords secure.
  548.  
  549.                  First and foremost, it is important to  impress  on  users
  550.             the  need  to  keep their passwords in their minds only.  Pass-
  551.             words should never be written down on desk blotters, calendars,
  552.             and  the like.  Further, storing passwords in files on the com-
  553.             puter must be prohibited.  In either case, by writing the pass-
  554.             word  down  on  a  piece  of paper or storing it in a file, the
  555.             security of the user's account  is  totally  dependent  on  the
  556.             security  of  the paper or file, which is usually less than the
  557.             security offered by the password encryption software.
  558.  
  559.                  A second important policy is that users  must  never  give
  560.             out  their  passwords to others.  Many times, a user feels that
  561.             it is easier to give someone else his password in order to copy
  562.             a  file,  rather  than to set up the permissions on the file so
  563.             that it can be copied.  Unfortunately, by giving out the  pass-
  564.             word  to  another person, the user is placing his trust in this
  565.             other person not to distribute the password further,  write  it
  566.             down, and so on.
  567.  
  568.                  Finally, it is important to establish a policy that  users
  569.             must  change  their  passwords  from  time to time, say twice a
  570.             year.  This is difficult to enforce  on  UNIX,  since  in  most
  571.             implementations, a password-expiration scheme is not available.
  572.             However, there are ways to implement  this  policy,  either  by
  573.             using  third-party  software  or by sending a memo to the users
  574.             requesting that they change their passwords.
  575.  
  576.                  This set of policies should be printed and distributed  to
  577.             all  current  users  of the system.  It should also be given to
  578.             all new users when they receive  their  accounts.   The  policy
  579.             usually  carries  more  weight  if you can get it signed by the
  580.             most ``impressive'' person  in  your  organization  (e.g.,  the
  581.             president of the company).
  582.  
  583.  
  584.           2.1.1.3   Checking Password Security
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                           8
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.                  The procedures and policies described in the previous sec-
  604.             tions,  when  properly  implemented,  will  greatly  reduce the
  605.             chances of a cracker breaking into your  system  via  a  stolen
  606.             account.   However,  as  with all security measures, you as the
  607.             system administrator must periodically check to  be  sure  that
  608.             the  policies  and procedures are being adhered to.  One of the
  609.             unfortunate truisms of password security  is  that,  ``left  to
  610.             their own ways, some people will still use cute doggie names as
  611.             passwords'' [Gram84].
  612.  
  613.                  The best way to check the security  of  the  passwords  on
  614.             your  system  is to use a password-cracking program much like a
  615.             real cracker would use.  If you succeed in cracking  any  pass-
  616.             words,  those  passwords  should be changed immediately.  There
  617.             are a few freely available password cracking  programs  distri-
  618.             buted  via various source archive sites; these are described in
  619.             more detail in Section 4.  A fairly extensive cracking  program
  620.             is  also  available  from  the  author.  Alternatively, you can
  621.             write your own cracking program, and  tailor  it  to  your  own
  622.             site.   For  a  list  of  things  to check for, see the list of
  623.             guidelines above.
  624.  
  625.  
  626.           2.1.2   Expiration Dates
  627.  
  628.  
  629.  
  630.                  Many sites, particularly those  with  a  large  number  of
  631.             users,  typically  have several old accounts lying around whose
  632.             owners have since left the organization.  These accounts are  a
  633.             major  security  hole:  not only can they be broken into if the
  634.             password is insecure, but because nobody is using  the  account
  635.             anymore, it is unlikely that a break-in will be noticed.
  636.  
  637.                  The simplest way to prevent unused accounts  from  accumu-
  638.             lating  is to place an expiration date on every account.  These
  639.             expiration dates should be near enough in the future  that  old
  640.             accounts  will  be  deleted  in a timely manner, yet far enough
  641.             apart that the users will not become annoyed.  A good figure is
  642.             usually one year from the date the account was installed.  This
  643.             tends to spread the expirations out over the year, rather  than
  644.             clustering  them  all  at the beginning or end.  The expiration
  645.             date can easily be stored in the password  file  (in  the  full
  646.             name field).  A simple shell script can be used to periodically
  647.             check that all accounts have expiration dates, and that none of
  648.             the dates has passed.
  649.  
  650.                  On the first day of each month, any user whose account has
  651.             expired  should be contacted to be sure he is still employed by
  652.             the organization, and that he is actively  using  the  account.
  653.             Any  user  who  cannot  be  contacted,  or who has not used his
  654.  
  655.  
  656.  
  657.                                           9
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.             account recently, should be deleted from the system.  If a user
  670.             is  unavailable  for some reason (e.g., on vacation) and cannot
  671.             be contacted, his account should be disabled by  replacing  the
  672.             encrypted  password in the password file entry with an asterisk
  673.             (*).  This makes it impossible to log in to  the  account,  yet
  674.             leaves  the  account  available  to be re-enabled on the user's
  675.             return.
  676.  
  677.  
  678.           2.1.3   Guest Accounts
  679.  
  680.  
  681.  
  682.                  Guest accounts present still another  security  hole.   By
  683.             their  nature,  these  accounts are rarely used, and are always
  684.             used by people who should only have access to the  machine  for
  685.             the  short period of time they are guests.  The most secure way
  686.             to handle guest accounts is to install  them  on  an  as-needed
  687.             basis,  and delete them as soon as the people using them leave.
  688.             Guest accounts should never be given simple passwords  such  as
  689.             ``guest'' or ``visitor,'' and should never be allowed to remain
  690.             in the password file when they are not being used.
  691.  
  692.  
  693.           2.1.4   Accounts Without Passwords
  694.  
  695.  
  696.  
  697.                  Some sites have installed  accounts  with  names  such  as
  698.             ``who,''  ``date,'' ``lpq,'' and so on that execute simple com-
  699.             mands.  These accounts are intended to allow users  to  execute
  700.             these  commands without having to log in to the machine.  Typi-
  701.             cally these accounts have no password associated with them, and
  702.             can  thus  be used by anyone.  Many of the accounts are given a
  703.             user id of zero, so that they execute with  super-user  permis-
  704.             sions.
  705.  
  706.                  The problem with these accounts is that they  open  poten-
  707.             tial  security  holes.  By not having passwords on them, and by
  708.             having  super-user  permissions,  these  accounts   practically
  709.             invite  crackers  to  try  to  penetrate them.  Usually, if the
  710.             cracker can  gain  access  to  the  system,  penetrating  these
  711.             accounts  is  simple, because each account executes a different
  712.             command.  If the cracker can replace any one of these  commands
  713.             with one of his own, he can then use the unprotected account to
  714.             execute his program with super-user permissions.
  715.  
  716.                  Simply put,  accounts  without  passwords  should  not  be
  717.             allowed on any UNIX system.
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                                          10
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.           2.1.5   Group Accounts and Groups
  736.  
  737.  
  738.  
  739.                  Group accounts have become popular at many sites, but  are
  740.             actually  a  break-in  waiting to happen.  A group account is a
  741.             single account shared by several people, e.g., by all the  col-
  742.             laborators  on a project.  As mentioned in the section on pass-
  743.             word security, users should not share  passwords  -  the  group
  744.             account  concept directly violates this policy.  The proper way
  745.             to allow users to share information, rather than giving them  a
  746.             group  account  to  use,  is to place these users into a group.
  747.             This is done by editing the  group  file,  /etc/group  [Sun88a,
  748.             1390;  Sun88b, 66], and creating a new group with the users who
  749.             wish to collaborate listed as members.
  750.  
  751.                  A line in the group file looks like
  752.  
  753.                     groupname:password:groupid:user1,user2,user3,...
  754.  
  755.             The groupname is the name assigned to the group,  much  like  a
  756.             login  name.   It  may  be the same as someone's login name, or
  757.             different.  The maximum length of a group name is eight charac-
  758.             ters.   The password field is unused in BSD-derived versions of
  759.             UNIX, and should contain an asterisk (*).   The  groupid  is  a
  760.             number  from 0 to 65535 inclusive.  Generally, numbers below 10
  761.             are reserved for special  purposes,  but  you  may  choose  any
  762.             unused number.  The last field is a comma-separated (no spaces)
  763.             list of the login names of the users in the group.  If no login
  764.             names  are  listed, then the group has no members.  To create a
  765.             group called ``hackers'' with Huey, Duey, and Louie as members,
  766.             you would add a line such as this to the group file:
  767.  
  768.                     hackers:*:100:huey,duey,louie
  769.  
  770.  
  771.                  After the group has been created,  the  files  and  direc-
  772.             tories  the  members  wish to share can then be changed so that
  773.             they are owned by this group, and the group permission bits  on
  774.             the  files  and  directories can be set to allow sharing.  Each
  775.             user retains his own account, with his own password, thus  pro-
  776.             tecting the security of the system.
  777.  
  778.                  For example, to change Huey's ``programs'' directory to be
  779.             owned  by  the new group and properly set up the permissions so
  780.             that all members of the group may  access  it,  the  chgrp  and
  781.             chmod commands would be used as follows [Sun88a, 63-66]:
  782.  
  783.                     # chgrp hackers ~huey/programs
  784.                     # chmod -R g+rw ~huey/programs
  785.  
  786.  
  787.  
  788.  
  789.                                          11
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.           2.1.6   Yellow Pages
  802.  
  803.  
  804.  
  805.                  The Sun Yellow Pages system [Sun88b, 349-374] allows  many
  806.             hosts to share password files, group files, and other files via
  807.             the network, while the files are stored on only a single  host.
  808.             Unfortunately, Yellow Pages also contains a few potential secu-
  809.             rity holes.
  810.  
  811.                  The principal way Yellow Pages works is to have a  special
  812.             line  in  the  password or group file that begins with a ``+''.
  813.             In the password file, this line looks like
  814.  
  815.                     +::0:0:::
  816.  
  817.             and in the group file, it looks like
  818.  
  819.                     +:
  820.  
  821.             These lines should only be present in the files stored on  Yel-
  822.             low  Pages  client machines.  They should not be present in the
  823.             files on the Yellow Pages master machine(s).   When  a  program
  824.             reads  the  password  or group file and encounters one of these
  825.             lines, it goes through the network and requests the information
  826.             it wants from the Yellow Pages server instead of trying to find
  827.             it in the local file.  In this way, the data does not  have  to
  828.             be  maintained on every host.  Since the master machine already
  829.             has all the information, there is no need for this special line
  830.             to be present there.
  831.  
  832.                  Generally speaking, the Yellow  Pages  service  itself  is
  833.             reasonably  secure.   There are a few openings that a sophisti-
  834.             cated (and dedicated) cracker could exploit, but Sun is rapidly
  835.             closing  these.   The  biggest problem with Yellow Pages is the
  836.             ``+'' line in the password file.  If the ``+'' is deleted  from
  837.             the  front of the line, then this line loses its special Yellow
  838.             Pages meaning.  It instead becomes a regular password file line
  839.             for an account with a null login name, no password, and user id
  840.             zero (super-user).  Thus, if a  careless  system  administrator
  841.             accidentally  deletes the ``+''.  the whole system is wide open
  842.             to any attack.*
  843.  
  844.                  Yellow Pages is too useful a service to suggest turning it
  845.             off,  although  turning  it  off  would  make  your system more
  846.             secure.  Instead, it is recommended that you read carefully the
  847.             information  in  the  Sun manuals in order to be fully aware of
  848.           _________________________
  849.             * Actually, a line like this without a ``+''  is  dangerous  in
  850.           any password file, regardless of whether Yellow Pages is in use.
  851.  
  852.  
  853.  
  854.  
  855.                                          12
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.             Yellow Pages' abilities and its limitations.
  868.  
  869.  
  870.           2.2   NETWORK SECURITY
  871.  
  872.  
  873.  
  874.                  As trends  toward  internetworking  continue,  most  sites
  875.             will, if they haven't already, connect themselves to one of the
  876.             numerous regional networks springing  up  around  the  country.
  877.             Most  of these regional networks are also interconnected, form-
  878.             ing the Internet [Hind83, Quar86].  This means that  the  users
  879.             of  your  machine  can  access other hosts and communicate with
  880.             other users around the world.   Unfortunately,  it  also  means
  881.             that  other  hosts  and  users from around the world can access
  882.             your machine, and attempt to break into it.
  883.  
  884.                  Before internetworking became  commonplace,  protecting  a
  885.             system  from  unauthorized  access  simply  meant  locking  the
  886.             machine in a room by itself.  Now that machines  are  connected
  887.             by networks, however, security is much more complex.  This sec-
  888.             tion describes the tools and methods  available  to  make  your
  889.             UNIX networks as secure as possible.
  890.  
  891.  
  892.           2.2.1   Trusted Hosts
  893.  
  894.  
  895.  
  896.                  One of the most convenient features of the  Berkeley  (and
  897.             Sun)  UNIX  networking  software  is the concept of ``trusted''
  898.             hosts.  The software allows the specification  of  other  hosts
  899.             (and  possibly users) who are to be considered trusted - remote
  900.             logins and remote command executions from these hosts  will  be
  901.             permitted without requiring the user to enter a password.  This
  902.             is very convenient, because users do not  have  to  type  their
  903.             password  every  time they use the network.  Unfortunately, for
  904.             the same  reason,  the  concept  of  a  trusted  host  is  also
  905.             extremely insecure.
  906.  
  907.                  The Internet worm made extensive use of the  trusted  host
  908.             concept to spread itself throughout the network [Seel88].  Many
  909.             sites that had already disallowed trusted hosts did fairly well
  910.             against  the  worm  compared  with  those  sites that did allow
  911.             trusted hosts.  Even though it is a security  hole,  there  are
  912.             some  valid  uses  for  the trusted host concept.  This section
  913.             describes how to properly implement the trusted hosts  facility
  914.             while preserving as much security as possible.
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                          13
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.           2.2.1.1   The hosts.equiv File
  934.  
  935.  
  936.  
  937.                  The file /etc/hosts.equiv [Sun88a, 1397] can  be  used  by
  938.             the  system  administrator  to  indicate  trusted  hosts.  Each
  939.             trusted host is listed in the file, one host per  line.   If  a
  940.             user  attempts  to  log  in (using rlogin) or execute a command
  941.             (using  rsh)  remotely  from  one  of  the  systems  listed  in
  942.             hosts.equiv,  and  that user has an account on the local system
  943.             with the same login name, access is permitted without requiring
  944.             a password.
  945.  
  946.                  Provided adequate care is taken to allow only local  hosts
  947.             in  the hosts.equiv file, a reasonable compromise between secu-
  948.             rity and convenience can be achieved.  Nonlocal hosts  (includ-
  949.             ing  hosts  at  remote  sites  of the same organization) should
  950.             never be trusted.  Also, if there  are  any  machines  at  your
  951.             organization that are installed in ``public'' areas (e.g., ter-
  952.             minal rooms) as opposed to  private  offices,  you  should  not
  953.             trust these hosts.
  954.  
  955.                  On Sun systems, hosts.equiv is controlled with the  Yellow
  956.             Pages  software.   As distributed, the default hosts.equiv file
  957.             distributed by Sun contains a single line:
  958.  
  959.                     +
  960.  
  961.             This indicates that every known host (i.e., the  complete  con-
  962.             tents  of  the  host file) should be considered a trusted host.
  963.             This is totally incorrect and  a  major  security  hole,  since
  964.             hosts  outside  the local organization should never be trusted.
  965.             A  correctly  configured  hosts.equiv  should  never  list  any
  966.             ``wildcard''  hosts  (such  as  the  ``+''); only specific host
  967.             names should be used.  When installing a new  system  from  Sun
  968.             distribution  tapes,  you  should be sure to either replace the
  969.             Sun default hosts.equiv with a  correctly  configured  one,  or
  970.             delete the file altogether.
  971.  
  972.  
  973.           2.2.1.2   The .rhosts File
  974.  
  975.  
  976.  
  977.                  The .rhosts file [Sun88a, 1397] is similar in concept  and
  978.             format  to the hosts.equiv file, but allows trusted access only
  979.             to specific host-user combinations, rather  than  to  hosts  in
  980.             general.*  Each user may create a  .rhosts  file  in  his  home
  981.           _________________________
  982.             * Actually,  hosts.equiv  may  be  used  to  specify  host-user
  983.           combinations as well, but this is rarely done.
  984.  
  985.  
  986.  
  987.                                          14
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.             directory, and allow access to her account without a  password.
  1000.             Most  people use this mechanism to allow trusted access between
  1001.             accounts they have on systems owned by different  organizations
  1002.             who  do  not  trust  each other's hosts in hosts.equiv.  Unfor-
  1003.             tunately, this file presents a major security  problem:   While
  1004.             hosts.equiv is under the system administrator's control and can
  1005.             be managed effectively, any user  may  create  a  .rhosts  file
  1006.             granting  access  to  whomever  he  chooses, without the system
  1007.             administrator's knowledge.
  1008.  
  1009.                  The only secure way to manage .rhosts  files  is  to  com-
  1010.             pletely  disallow them on the system.  The system administrator
  1011.             should check the system often for  violations  of  this  policy
  1012.             (see  Section 3.3.1.4).  One possible exception to this rule is
  1013.             the ``root'' account; a .rhosts file may be necessary to  allow
  1014.             network backups and the like to be completed.
  1015.  
  1016.  
  1017.           2.2.2   Secure Terminals
  1018.  
  1019.  
  1020.  
  1021.                  Under newer versions of UNIX, the concept of a  ``secure''
  1022.             terminal  has  been  introduced.   Simply  put,  the super-user
  1023.             (``root'') may not log in on a nonsecure terminal, even with  a
  1024.             password.   (Authorized  users  may still use the su command to
  1025.             become super-user, however.)   The  file  /etc/ttytab  [Sun88a,
  1026.             1478]  is  used  to  control  which  terminals  are  considered
  1027.             secure.| A short excerpt from this file is shown below.
  1028.  
  1029.                     console  "/usr/etc/getty std.9600"  sun      off secure
  1030.                     ttya     "/usr/etc/getty std.9600"  unknown  off secure
  1031.                     ttyb     "/usr/etc/getty std.9600"  unknown  off secure
  1032.                     ttyp0    none                       network  off secure
  1033.                     ttyp1    none                       network  off secure
  1034.                     ttyp2    none                       network  off secure
  1035.  
  1036.             The keyword ``secure'' at the end of each line  indicates  that
  1037.             the terminal is considered secure.  To remove this designation,
  1038.             simply edit the file and delete the ``secure'' keyword.   After
  1039.             saving the file, type the command (as super-user):
  1040.  
  1041.                     # kill -HUP 1
  1042.  
  1043.             This tells the init process to reread the ttytab file.
  1044.  
  1045.           _________________________
  1046.  
  1047.             | Under non-Sun versions of Berkeley UNIX, this file is  called
  1048.           /etc/ttys.
  1049.  
  1050.  
  1051.  
  1052.  
  1053.                                          15
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.                  The Sun default configuration for ttytab  is  to  consider
  1066.             all  terminals  secure,  including ``pseudo'' terminals used by
  1067.             the remote login software.  This means that ``root'' may log in
  1068.             remotely  from  any  host on the network.  A more secure confi-
  1069.             guration would consider as secure only directly connected  ter-
  1070.             minals,  or  perhaps only the console device.  This is how file
  1071.             servers and other machines with disks should be set up.
  1072.  
  1073.                  The most secure configuration is to remove the  ``secure''
  1074.             designation  from  all terminals, including the console device.
  1075.             This requires that those users with super-user authority  first
  1076.             log in as themselves, and then become the super-user via the su
  1077.             command.  It also requires the ``root'' password to be  entered
  1078.             when  rebooting  in single-user mode, in order to prevent users
  1079.             from rebooting their desktop workstations and obtaining  super-
  1080.             user  access.   This is how all diskless client machines should
  1081.             be set up.
  1082.  
  1083.  
  1084.           2.2.3   The Network File System
  1085.  
  1086.  
  1087.  
  1088.                  The Network File System  (NFS)  [Sun88d]  is  designed  to
  1089.             allow  several  hosts  to share files over the network.  One of
  1090.             the most common uses of NFS is to allow  diskless  workstations
  1091.             to be installed in offices, while keeping all disk storage in a
  1092.             central location.  As distributed by Sun, NFS has  no  security
  1093.             features enabled.  This means that any host on the Internet may
  1094.             access your files via NFS, regardless of whether you trust them
  1095.             or not.
  1096.  
  1097.                  Fortunately, there are several easy ways to make NFS  more
  1098.             secure.   The  more commonly used methods are described in this
  1099.             section, and these can be used to make your files quite  secure
  1100.             from  unauthorized  access  via NFS.  Secure NFS, introduced in
  1101.             SunOS Release 4.0,  takes  security  one  step  further,  using
  1102.             public-key  encryption  techniques to ensure authorized access.
  1103.             Discussion of secure NFS is deferred until Section 4.
  1104.  
  1105.  
  1106.           2.2.3.1   The exports File
  1107.  
  1108.  
  1109.  
  1110.                  The file /etc/exports [Sun88a, 1377] is perhaps one of the
  1111.             most  important  parts  of  NFS configuration.  This file lists
  1112.             which file systems are exported (made available  for  mounting)
  1113.             to  other  systems.  A typical exports file as installed by the
  1114.             Sun installation procedure looks something like this:
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                          16
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.                     /usr
  1133.                     /home
  1134.                     /var/spool/mail
  1135.                     #
  1136.                     /export/root/client1    -access=client1,root=client1
  1137.                     /export/swap/client1    -access=client1,root=client1
  1138.                     #
  1139.                     /export/root/client2    -access=client2,root=client2
  1140.                     /export/swap/client2    -access=client2,root=client2
  1141.  
  1142.             The root= keyword specifies the list of hosts that are  allowed
  1143.             to  have  super-user access to the files in the named file sys-
  1144.             tem.  This keyword is discussed in detail in  Section  2.2.3.3.
  1145.             The  access=  keyword specifies the list of hosts (separated by
  1146.             colons) that are allowed to mount the named file system.  If no
  1147.             access=  keyword  is specified for a file system, any host any-
  1148.             where on the network may mount that file system via NFS.
  1149.  
  1150.                  Obviously, this presents a major security  problem,  since
  1151.             anyone  who can mount your file systems via NFS can then peruse
  1152.             them at her leisure.  Thus, it is important that all file  sys-
  1153.             tems  listed in exports have an access= keyword associated with
  1154.             them.  If you have only a few hosts which  must  mount  a  file
  1155.             system, you can list them individually in the file:
  1156.  
  1157.                     /usr    -access=host1:host2:host3:host4:host5
  1158.  
  1159.             However, because the maximum number of hosts that can be listed
  1160.             this  way is ten, the access= keyword will also allow netgroups
  1161.             to be specified.  Netgroups are described in the next section.
  1162.  
  1163.                  After making any changes to the exports file,  you  should
  1164.             run the command
  1165.  
  1166.                     # exportfs -a
  1167.  
  1168.             in order to make the changes take effect.
  1169.  
  1170.  
  1171.           2.2.3.2   The netgroup File
  1172.  
  1173.  
  1174.  
  1175.                  The file /etc/netgroup [Sun88a, 1407] is  used  to  define
  1176.             netgroups.   This  file is controlled by Yellow Pages, and must
  1177.             be rebuilt in the Yellow Pages maps whenever  it  is  modified.
  1178.             Consider the following sample netgroup file:
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                          17
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.                     A_Group      (servera,,) (clienta1,,) (clienta2,,)
  1199.  
  1200.                     B_Group      (serverb,,) (clientb1,,) (clientb2,,)
  1201.  
  1202.                     AdminStaff   (clienta1,mary,) (clientb3,joan,)
  1203.  
  1204.                     AllSuns      A_Group B_Group
  1205.  
  1206.             This file defines  four  netgroups,  called  A_Group,  B_Group,
  1207.             AdminStaff,  and  AllSuns.   The AllSuns netgroup is actually a
  1208.             ``super group'' containing all the members of the  A_Group  and
  1209.             B_Group netgroups.
  1210.  
  1211.                  Each member of a netgroup is defined as a  triple:  (host,
  1212.             user,  domain).  Typically, the domain field is never used, and
  1213.             is simply left blank.  If either the host or user field is left
  1214.             blank,  then any host or user is considered to match.  Thus the
  1215.             triple (host,,) matches any user on the named host,  while  the
  1216.             triple (,user,) matches the named user on any host.
  1217.  
  1218.                  Netgroups are useful when restricting access to  NFS  file
  1219.             systems via the exports file.  For example, consider this modi-
  1220.             fied version of the file from the previous section:
  1221.  
  1222.                     /usr                    -access=A_Group
  1223.                     /home                   -access=A_Group:B_Group
  1224.                     /var/spool/mail         -access=AllSuns
  1225.                     #
  1226.                     /export/root/client1    -access=client1,root=client1
  1227.                     /export/swap/client1    -access=client1,root=client1
  1228.                     #
  1229.                     /export/root/client2    -access=client2,root=client2
  1230.                     /export/swap/client2    -access=client2,root=client2
  1231.  
  1232.             The /usr file system may now only be mounted by  the  hosts  in
  1233.             the A_Group netgroup, that is, servera, clienta1, and clienta2.
  1234.             Any other host that  tries  to  mount  this  file  system  will
  1235.             receive  an ``access denied'' error.  The /home file system may
  1236.             be mounted by any of the hosts in either the A_Group or B_Group
  1237.             netgroups.   The /var/spool/mail file system is also restricted
  1238.             to these hosts, but in this example we used the ``super group''
  1239.             called AllSuns.
  1240.  
  1241.                  Generally, the best way to configure the netgroup file  is
  1242.             to make a single netgroup for each file server and its clients,
  1243.             and then to make other super groups,  such  as  AllSuns.   This
  1244.             allows  you  the  flexibility  to specify the smallest possible
  1245.             group of hosts for each file system in /etc/exports.
  1246.  
  1247.                  Netgroups can also be used in the password file  to  allow
  1248.  
  1249.  
  1250.  
  1251.                                          18
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.             access  to a given host to be restricted to the members of that
  1264.             group, and they can be used in the hosts.equiv file to central-
  1265.             ize  maintenance  of the list of trusted hosts.  The procedures
  1266.             for doing this are defined in more detail in the Sun manual.
  1267.  
  1268.  
  1269.           2.2.3.3   Restricting Super-User Access
  1270.  
  1271.  
  1272.  
  1273.                  Normally, NFS translates the super-user id to a special id
  1274.             called ``nobody'' in order to prevent a user with ``root'' on a
  1275.             remote workstation from accessing other people's  files.   This
  1276.             is  good  for  security,  but  sometimes  a nuisance for system
  1277.             administration, since you  cannot  make  changes  to  files  as
  1278.             ``root'' through NFS.
  1279.  
  1280.                  The exports file  also  allows  you  to  grant  super-user
  1281.             access  to  certain file systems for certain hosts by using the
  1282.             root= keyword.  Following this keyword a  colon-separated  list
  1283.             of  up  to  ten  hosts  may  be  specified; these hosts will be
  1284.             allowed to access the file system as  ``root''  without  having
  1285.             the  user  id  converted  to  ``nobody.''  Netgroups may not be
  1286.             specified to the root= keyword.
  1287.  
  1288.                  Granting ``root'' access to a  host  should  not  be  done
  1289.             lightly.   If a host has ``root'' access to a file system, then
  1290.             the super-user on that host will have complete  access  to  the
  1291.             file system, just as if you had given him the ``root'' password
  1292.             on the server.  Untrusted hosts should never be given  ``root''
  1293.             access to NFS file systems.
  1294.  
  1295.  
  1296.           2.2.4   FTP
  1297.  
  1298.  
  1299.  
  1300.                  The File Transfer Protocol, implemented  by  the  ftp  and
  1301.             ftpd  programs  [Sun88a,  195-201,  1632-1634], allows users to
  1302.             connect to remote systems and transfer files  back  and  forth.
  1303.             Unfortunately,  older  versions  of  these  programs  also  had
  1304.             several bugs in them that allowed crackers to break into a sys-
  1305.             tem.   These bugs have been fixed by Berkeley, and new versions
  1306.             are available.  If your  ftpd*  was  obtained  before  December
  1307.             1988, you should get a newer version (see Section 4).
  1308.  
  1309.           _________________________
  1310.  
  1311.             * On Sun systems, ftpd is stored in the file  /usr/etc/in.ftpd.
  1312.           On most other systems, it is called /etc/ftpd.
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                          19
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.                  One  of  the  more  useful  features   of   FTP   is   the
  1330.             ``anonymous''  login.   This  special login allows users who do
  1331.             not have an account on your machine to have  restricted  access
  1332.             in  order to transfer files from a specific directory.  This is
  1333.             useful if you wish to distribute  software  to  the  public  at
  1334.             large  without  giving  each  person  who wants the software an
  1335.             account on your machine.  In order to securely set up anonymous
  1336.             FTP you should follow the specific instructions below:
  1337.  
  1338.                  1.   Create  an  account  called  ``ftp.''   Disable   the
  1339.                       account  by  placing  an asterisk (*) in the password
  1340.                       field.  Give the account a  special  home  directory,
  1341.                       such as /usr/ftp or /usr/spool/ftp.
  1342.  
  1343.                  2.   Make the home directory owned by ``ftp'' and  unwrit-
  1344.                       able by anyone:
  1345.  
  1346.                               # chown ftp ~ftp
  1347.                               # chmod 555 ~ftp
  1348.  
  1349.  
  1350.                  3.   Make the directory ~ftp/bin, owned by the  super-user
  1351.                       and  unwritable  by  anyone.   Place a copy of the ls
  1352.                       program in this directory:
  1353.  
  1354.                               # mkdir ~ftp/bin
  1355.                               # chown root ~ftp/bin
  1356.                               # chmod 555 ~ftp/bin
  1357.                               # cp -p /bin/ls ~ftp/bin
  1358.                               # chmod 111 ~ftp/bin/ls
  1359.  
  1360.  
  1361.                  4.   Make the directory ~ftp/etc, owned by the  super-user
  1362.                       and  unwritable by anyone.  Place copies of the pass-
  1363.                       word and group files in this directory, with all  the
  1364.                       password  fields  changed  to asterisks (*).  You may
  1365.                       wish to delete all but a  few  of  the  accounts  and
  1366.                       groups  from  these files; the only account that must
  1367.                       be present is ``ftp.''
  1368.  
  1369.                               # mkdir ~ftp/etc
  1370.                               # chown root ~ftp/etc
  1371.                               # chmod 555 ~ftp/etc
  1372.                               # cp -p /etc/passwd /etc/group ~ftp/etc
  1373.                               # chmod 444 ~ftp/etc/passwd ~ftp/etc/group
  1374.  
  1375.  
  1376.                  5.   Make the directory ~ftp/pub,  owned  by  ``ftp''  and
  1377.                       world-writable.   Users may then place files that are
  1378.                       to be accessible via anonymous FTP in this directory:
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                          20
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.                               # mkdir ~ftp/pub
  1397.                               # chown ftp ~ftp/pub
  1398.                               # chmod 777 ~ftp/pub
  1399.  
  1400.  
  1401.                  Because the anonymous FTP feature allows anyone to  access
  1402.             your  system  (albeit  in a very limited way), it should not be
  1403.             made available on every host  on  the  network.   Instead,  you
  1404.             should  choose  one  machine (preferably a server or standalone
  1405.             host) on which to allow this service.   This  makes  monitoring
  1406.             for  security  violations  much easier.  If you allow people to
  1407.             transfer files to your machine (using  the  world-writable  pub
  1408.             directory,  described  above),  you should check often the con-
  1409.             tents of the directories into which they are allowed to  write.
  1410.             Any suspicious files you find should be deleted.
  1411.  
  1412.  
  1413.           2.2.4.1   Trivial FTP
  1414.  
  1415.  
  1416.  
  1417.                  The Trivial File Transfer Protocol, TFTP, is used  on  Sun
  1418.             workstations  (and others) to allow diskless hosts to boot from
  1419.             the network.  Basically, TFTP is a stripped-down version of FTP
  1420.             -  there is no user authentication, and the connection is based
  1421.             on the User Datagram Protocol instead of the Transmission  Con-
  1422.             trol  Protocol.  Because they are so stripped-down, many imple-
  1423.             mentations of TFTP have security holes.  You should check  your
  1424.             hosts by executing the command sequence shown below.
  1425.  
  1426.                     % tftp
  1427.                     tftp> connect yourhost
  1428.                     tftp> get /etc/motd tmp
  1429.                     Error code 1: File not found
  1430.                     tftp> quit
  1431.                     %
  1432.  
  1433.             If your version does not respond with ``File not  found,''  and
  1434.             instead  transfers the file, you should replace your version of
  1435.             tftpd* with a newer one.   In  particular,  versions  of  SunOS
  1436.             prior to release 4.0 are known to have this problem.
  1437.  
  1438.  
  1439.  
  1440.           _________________________
  1441.  
  1442.             * On   Sun   systems,   tftpd   is   stored   in    the    file
  1443.           /usr/etc/in.tftpd.    On   most   other  systems,  it  is  called
  1444.           /etc/tftpd.
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                          21
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.           2.2.5   Mail
  1462.  
  1463.  
  1464.  
  1465.                  Electronic mail is one of the main reasons for  connecting
  1466.             to outside networks.  On most versions of Berkeley-derived UNIX
  1467.             systems,  including  those  from  Sun,  the  sendmail   program
  1468.             [Sun88a,  1758-1760;  Sun88b,  441-488]  is  used to enable the
  1469.             receipt and delivery of mail.  As with the FTP software,  older
  1470.             versions of sendmail have several bugs that allow security vio-
  1471.             lations.  One of these bugs was used with great success by  the
  1472.             Internet  worm  [Seel88, Spaf88].  The current version of send-
  1473.             mail from Berkeley is version 5.61, of January 1989.   Sun  is,
  1474.             as  of  this  writing, still shipping version 5.59, which has a
  1475.             known security problem.  They have, however, made a fixed  ver-
  1476.             sion  available.   Section  4 details how to obtain these newer
  1477.             versions.
  1478.  
  1479.                  Generally, with the exception of the security  holes  men-
  1480.             tioned  above,  sendmail is reasonably secure when installed by
  1481.             most vendors' installation procedures.  There are,  however,  a
  1482.             few  precautions  that  should be taken to ensure secure opera-
  1483.             tion:
  1484.  
  1485.                  1.   Remove the ``decode'' alias  from  the  aliases  file
  1486.                       (/etc/aliases or /usr/lib/aliases).
  1487.  
  1488.                  2.   If you create aliases that allow messages to be  sent
  1489.                       to  programs, be absolutely sure that there is no way
  1490.                       to obtain a shell or send commands to  a  shell  from
  1491.                       these programs.
  1492.  
  1493.                  3.   Make sure the ``wizard'' password is disabled in  the
  1494.                       configuration  file, sendmail.cf.  (Unless you modify
  1495.                       the distributed configuration files,  this  shouldn't
  1496.                       be a problem.)
  1497.  
  1498.                  4.   Make  sure  your  sendmail  does  not   support   the
  1499.                       ``debug'' command.  This can be done with the follow-
  1500.                       ing commands:
  1501.  
  1502.                       % telnet localhost 25
  1503.                       220 yourhost Sendmail 5.61 ready at 9 Mar 90 10:57:36 PST
  1504.                       debug
  1505.                       500 Command unrecognized
  1506.                       quit
  1507.                       %
  1508.  
  1509.  
  1510.                       If your sendmail responds to  the  ``debug''  command
  1511.                       with  ``200  Debug  set,'' then you are vulnerable to
  1512.  
  1513.  
  1514.  
  1515.                                          22
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.                       attack and should replace your sendmail with a  newer
  1528.                       version.
  1529.  
  1530.             By following the procedures above, you can be  sure  that  your
  1531.             mail system is secure.
  1532.  
  1533.  
  1534.           2.2.6   Finger
  1535.  
  1536.  
  1537.  
  1538.                  The ``finger'' service, provided  by  the  finger  program
  1539.             [Sun88a,  186-187],  allows  you  to obtain information about a
  1540.             user such as her full name, home directory,  last  login  time,
  1541.             and  in  some cases when she last received mail and/or read her
  1542.             mail.  The fingerd  program  [Sun88a,  1625]  allows  users  on
  1543.             remote hosts to obtain this information.
  1544.  
  1545.                  A bug in fingerd was also exercised with  success  by  the
  1546.             Internet worm [Seel88, Spaf88].  If your version of fingerd* is
  1547.             older than November 5, 1988, it should be replaced with a newer
  1548.             version.  New  versions  are  available  from  several  of  the
  1549.             sources described in Section 4.
  1550.  
  1551.  
  1552.           2.2.7   Modems and Terminal Servers
  1553.  
  1554.  
  1555.  
  1556.                  Modems and  terminal  servers  (terminal  switches,  Annex
  1557.             boxes,  etc.) present still another potential security problem.
  1558.             The main problem with these devices is one of  configuration  -
  1559.             misconfigured hardware can allow security breaches.  Explaining
  1560.             how to configure every brand of modem and terminal server would
  1561.             require  volumes.   However,  the  following  items  should  be
  1562.             checked for on any modems or terminal servers installed at your
  1563.             site:
  1564.  
  1565.                  1.   If a user dialed up to a modem hangs  up  the  phone,
  1566.                       the  system should log him out.  If it doesn't, check
  1567.                       the hardware connections and the kernel configuration
  1568.                       of the serial ports.
  1569.  
  1570.                  2.   If a user logs off, the system should force the modem
  1571.                       to hang up.  Again, check the hardware connections if
  1572.                       this doesn't work.
  1573.           _________________________
  1574.  
  1575.             * On Sun systems, fingerd is stored in /usr/etc/in.fingerd.  On
  1576.           most other systems, it is called /etc/fingerd.
  1577.  
  1578.  
  1579.  
  1580.  
  1581.                                          23
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.                  3.   If the connection from a terminal server to the  sys-
  1594.                       tem is broken, the system should log the user off.
  1595.  
  1596.                  4.   If the terminal server is connected  to  modems,  and
  1597.                       the  user hangs up, the terminal server should inform
  1598.                       the system that the user has hung up.
  1599.  
  1600.                  Most modem and terminal server manuals cover in detail how
  1601.             to  properly connect these devices to your system.  In particu-
  1602.             lar you should pay close attention to the  ``Carrier  Detect,''
  1603.             ``Clear to Send,'' and ``Request to Send'' connections.
  1604.  
  1605.  
  1606.           2.2.8   Firewalls
  1607.  
  1608.  
  1609.  
  1610.                  One of the newer ideas in network security is  that  of  a
  1611.             firewall.   Basically,  a  firewall is a special host that sits
  1612.             between  your  outside-world  network  connection(s)  and  your
  1613.             internal  network(s).   This  host  does  not  send out routing
  1614.             information about your internal network, and thus the  internal
  1615.             network is ``invisible'' from the outside.  In order to config-
  1616.             ure a firewall machine, the following considerations need to be
  1617.             taken:
  1618.  
  1619.                  1.   The firewall does not advertise routes.   This  means
  1620.                       that users on the internal network must log in to the
  1621.                       firewall in order to access hosts on remote networks.
  1622.                       Likewise,  in order to log in to a host on the inter-
  1623.                       nal network from the outside, a user must  first  log
  1624.                       in  to  the  firewall machine.  This is inconvenient,
  1625.                       but more secure.
  1626.  
  1627.                  2.   All electronic mail sent by your users must  be  for-
  1628.                       warded  to  the  firewall  machine  if  it  is  to be
  1629.                       delivered  outside  your   internal   network.    The
  1630.                       firewall  must  receive all incoming electronic mail,
  1631.                       and then redistribute it.  This can  be  done  either
  1632.                       with aliases for each user or by using name server MX
  1633.                       records.
  1634.  
  1635.                  3.   The firewall machine should not mount any  file  sys-
  1636.                       tems  via NFS, or make any of its file systems avail-
  1637.                       able to be mounted.
  1638.  
  1639.                  4.   Password security on the  firewall  must  be  rigidly
  1640.                       enforced.
  1641.  
  1642.                  5.   The firewall host should not trust  any  other  hosts
  1643.                       regardless  of  where  they  are.   Furthermore,  the
  1644.  
  1645.  
  1646.  
  1647.                                          24
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.                       firewall should not be trusted by any other host.
  1660.  
  1661.                  6.   Anonymous FTP and other similar services should  only
  1662.                       be  provided  by  the firewall host, if they are pro-
  1663.                       vided at all.
  1664.  
  1665.                  The purpose of the firewall is to  prevent  crackers  from
  1666.             accessing other hosts on your network.  This means, in general,
  1667.             that you must maintain strict and rigidly enforced security  on
  1668.             the  firewall,  but  the  other  hosts are less vulnerable, and
  1669.             hence security may be somewhat lax.  But  it  is  important  to
  1670.             remember  that  the  firewall  is  not  a complete cure against
  1671.             crackers - if a cracker can break into the firewall machine, he
  1672.             can then try to break into any other host on your network.
  1673.  
  1674.  
  1675.           2.3   FILE SYSTEM SECURITY
  1676.  
  1677.  
  1678.  
  1679.                  The last defense against system crackers are  the  permis-
  1680.             sions  offered  by the file system.  Each file or directory has
  1681.             three sets of permission bits associated with it:  one set  for
  1682.             the  user who owns the file, one set for the users in the group
  1683.             with which the file is associated, and one set  for  all  other
  1684.             users  (the  ``world''  permissions).   Each set contains three
  1685.             identical permission bits, which control the following:
  1686.  
  1687.                  read     If set, the file or directory may  be  read.   In
  1688.                           the  case  of  a  directory, read access allows a
  1689.                           user to see the  contents  of  a  directory  (the
  1690.                           names of the files contained therein), but not to
  1691.                           access them.
  1692.  
  1693.                  write    If set, the file  or  directory  may  be  written
  1694.                           (modified).   In  the  case of a directory, write
  1695.                           permission implies the ability to create, delete,
  1696.                           and  rename  files.   Note  that  the  ability to
  1697.                           remove a file is not controlled  by  the  permis-
  1698.                           sions  on the file, but rather the permissions on
  1699.                           the directory containing the file.
  1700.  
  1701.                  execute  If set, the file or  directory  may  be  executed
  1702.                           (searched).   In the case of a directory, execute
  1703.                           permission implies the ability  to  access  files
  1704.                           contained in that directory.
  1705.  
  1706.                  In addition, a fourth permission bit is available in  each
  1707.             set  of  permissions.  This bit has a different meaning in each
  1708.             set of permission bits:
  1709.  
  1710.  
  1711.  
  1712.  
  1713.                                          25
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.                  setuid  If set in the owner permissions, this bit controls
  1726.                          the  ``set  user  id''  (setuid) status of a file.
  1727.                          Setuid status means that when a  program  is  exe-
  1728.                          cuted,  it  executes  with  the permissions of the
  1729.                          user owning the program, in addition to  the  per-
  1730.                          missions  of  the user executing the program.  For
  1731.                          example, sendmail is setuid ``root,'' allowing  it
  1732.                          to  write files in the mail queue area, which nor-
  1733.                          mal users are not allowed  to  do.   This  bit  is
  1734.                          meaningless on nonexecutable files.
  1735.  
  1736.                  setgid  If set in the group permissions, this bit controls
  1737.                          the  ``set  group  id'' (setgid) status of a file.
  1738.                          This behaves in exactly the same way as the setuid
  1739.                          bit, except that the group id is affected instead.
  1740.                          This bit is meaningless  on  non-executable  files
  1741.                          (but see below).
  1742.  
  1743.                  sticky  If set in the world  permissions,  the  ``sticky''
  1744.                          bit  tells  the  operating  system  to  do special
  1745.                          things with the text image of an executable  file.
  1746.                          It  is  mostly  a  holdover from older versions of
  1747.                          UNIX, and has little if any use today.   This  bit
  1748.                          is  also  meaningless  on nonexecutable files (but
  1749.                          see below).
  1750.  
  1751.  
  1752.           2.3.1   Setuid Shell Scripts
  1753.  
  1754.  
  1755.  
  1756.                Shell scripts that have the setuid or  setgid  bits  set  on
  1757.           them  are not secure, regardless of how many safeguards are taken
  1758.           when writing them.  There are numerous software  packages  avail-
  1759.           able  that  claim  to  make  shell  scripts secure, but every one
  1760.           released so far has not managed to solve all the problems.
  1761.  
  1762.                Setuid and setgid shell scripts should never be  allowed  on
  1763.           any UNIX system.
  1764.  
  1765.  
  1766.           2.3.2   The Sticky Bit on Directories
  1767.  
  1768.  
  1769.  
  1770.                Newer versions of UNIX have attached a new  meaning  to  the
  1771.           sticky  bit.   When this bit is set on a directory, it means that
  1772.           users may not delete or rename other users' files in this  direc-
  1773.           tory.   This  is  typically  useful for the /tmp directory.  Nor-
  1774.           mally, /tmp  is  world-writable,  enabling  any  user  to  delete
  1775.           another  user's  files.  By setting the sticky bit on /tmp, users
  1776.  
  1777.  
  1778.  
  1779.                                          26
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.           may only delete their own files from this directory.
  1792.  
  1793.                To set the sticky bit on a directory, use the command
  1794.  
  1795.                   # chmod o+t directory
  1796.  
  1797.  
  1798.  
  1799.           2.3.3   The Setgid Bit on Directories
  1800.  
  1801.  
  1802.  
  1803.                In SunOS 4.0, the setgid bit was also given a  new  meaning.
  1804.           Two  rules can be used for assigning group ownership to a file in
  1805.           SunOS:
  1806.  
  1807.                1.   The System V mechanism, which says that a  user's  pri-
  1808.                     mary  group id (the one listed in the password file) is
  1809.                     assigned to any file he creates.
  1810.  
  1811.                2.   The Berkeley mechanism, which says that the group id of
  1812.                     a file is set to the group id of the directory in which
  1813.                     it is created.
  1814.  
  1815.                If the setgid bit  is  set  on  a  directory,  the  Berkeley
  1816.           mechanism  is  enabled.   Otherwise,  the  System  V mechanism is
  1817.           enabled.  Normally, the Berkeley mechanism is used; this  mechan-
  1818.           ism must be used if creating directories for use by more than one
  1819.           member of a group (see Section 2.1.5).
  1820.  
  1821.                To set the setgid bit on a directory, use the command
  1822.  
  1823.                   # chmod g+s directory
  1824.  
  1825.  
  1826.  
  1827.           2.3.4   The umask Value
  1828.  
  1829.  
  1830.  
  1831.                When a file is created by a program, say a text editor or  a
  1832.           compiler,  it  is typically created with all permissions enabled.
  1833.           Since this is rarely desirable (you don't want other users to  be
  1834.           able  to write your files), the umask value is used to modify the
  1835.           set of permissions a file is created with.  Simply put, while the
  1836.           chmod  command  [Sun88a,  65-66]  specifies  what  bits should be
  1837.           turned on, the umask value specifies what bits should  be  turned
  1838.           off.
  1839.  
  1840.                For example, the default umask on most systems is 022.  This
  1841.           means  that  write  permission  for the group and world should be
  1842.  
  1843.  
  1844.  
  1845.                                          27
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.           turned off whenever a file is created.  If instead you wanted  to
  1858.           turn  off all group and world permission bits, such that any file
  1859.           you created would not be readable,  writable,  or  executable  by
  1860.           anyone except yourself, you would set your umask to 077.
  1861.  
  1862.                The umask value is specified in the .cshrc or .profile files
  1863.           read  by  the  shell  using the umask command [Sun88a, 108, 459].
  1864.           The ``root'' account should have the line
  1865.  
  1866.                   umask 022
  1867.  
  1868.           in its /.cshrc file, in order to prevent the accidental  creation
  1869.           of world-writable files owned by the super-user.
  1870.  
  1871.  
  1872.           2.3.5   Encrypting Files
  1873.  
  1874.  
  1875.  
  1876.                The standard UNIX crypt command [Sun88a, 95] is not  at  all
  1877.           secure.  Although it is reasonable to expect that crypt will keep
  1878.           the casual ``browser'' from reading a file, it will present noth-
  1879.           ing  more  than  a  minor  inconvenience to a determined cracker.
  1880.           Crypt implements a one-rotor machine along the lines of the  Ger-
  1881.           man  Enigma  (broken  in World War II).  The methods of attack on
  1882.           such a machine are well known, and a sufficiently large file  can
  1883.           usually  be  decrypted  in  a few hours even without knowledge of
  1884.           what the file contains [Reed84].   In  fact,  publicly  available
  1885.           packages  of  programs designed to ``break'' files encrypted with
  1886.           crypt have been around for several years.
  1887.  
  1888.                There are software implementations of another algorithm, the
  1889.           Data  Encryption  Standard  (DES),  available  on  some  systems.
  1890.           Although this algorithm is much more secure than  crypt,  it  has
  1891.           never  been  proven  that  it  is totally secure, and many doubts
  1892.           about its security have been raised in recent years.
  1893.  
  1894.                Perhaps the best thing to say about encrypting  files  on  a
  1895.           computer system is this:  if you think you have a file whose con-
  1896.           tents are important enough to encrypt, then that file should  not
  1897.           be stored on the computer in the first place.  This is especially
  1898.           true of systems with limited security, such as UNIX  systems  and
  1899.           personal computers.
  1900.  
  1901.                It  is  important  to  note  that  UNIX  passwords  are  not
  1902.           encrypted  with  the  crypt program.  Instead, they are encrypted
  1903.           with a modified version of the DES that generates one-way encryp-
  1904.           tions  (that is, the password cannot be decrypted).  When you log
  1905.           in, the system does  not  decrypt  your  password.   Instead,  it
  1906.           encrypts  your  attempted  password, and if this comes out to the
  1907.           same result as encrypting your real password, you are allowed  to
  1908.  
  1909.  
  1910.  
  1911.                                          28
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.           log in.
  1924.  
  1925.  
  1926.           2.3.6   Devices
  1927.  
  1928.  
  1929.  
  1930.                The security of devices is an important issue in UNIX.  Dev-
  1931.           ice files (usually residing in /dev) are used by various programs
  1932.           to access the data on the disk drives or  in  memory.   If  these
  1933.           device files are not properly protected, your system is wide open
  1934.           to a cracker.  The entire list of devices is too long to go  into
  1935.           here, since it varies widely from system to system.  However, the
  1936.           following guidelines apply to all systems:
  1937.  
  1938.                1.   The files /dev/kmem,  /dev/mem,  and  /dev/drum  should
  1939.                     never  be  readable  by the world.  If your system sup-
  1940.                     ports the notion of the ``kmem'' group (most newer sys-
  1941.                     tems  do) and utilities such as ps are setgid ``kmem,''
  1942.                     then these files should be owned by user  ``root''  and
  1943.                     group ``kmem,'' and should be mode 640.  If your system
  1944.                     does not support the notion of the ``kmem'' group,  and
  1945.                     utilities  such  as  ps are setuid ``root,'' then these
  1946.                     files should be owned by user ``root'' and mode 600.
  1947.  
  1948.                2.   The disk devices, such as /dev/sd0a, /dev/rxy1b,  etc.,
  1949.                     should  be  owned  by  user ``root'' and group ``opera-
  1950.                     tor,'' and should be mode 640.  Note that each disk has
  1951.                     eight  partitions  and two device files for each parti-
  1952.                     tion.  Thus, the disk ``sd0'' would have the  following
  1953.                     device files associated with it in /dev:
  1954.  
  1955.                             sd0a     sd0e     rsd0a     rsd0e
  1956.                             sd0b     sd0f     rsd0b     rsd0f
  1957.                             sd0c     sd0g     rsd0c     rsd0g
  1958.                             sd0d     sd0h     rsd0d     rsd0h
  1959.  
  1960.  
  1961.                3.   With very few exceptions, all other devices  should  be
  1962.                     owned  by  user  ``root.''  One exception is terminals,
  1963.                     which are changed to be owned  by  the  user  currently
  1964.                     logged  in on them.  When the user logs out, the owner-
  1965.                     ship of the terminal is automatically changed  back  to
  1966.                     ``root.''
  1967.  
  1968.  
  1969.           2.4   SECURITY IS YOUR RESPONSIBILITY
  1970.  
  1971.  
  1972.  
  1973.                This section  has  detailed  numerous  tools  for  improving
  1974.  
  1975.  
  1976.  
  1977.                                          29
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.           security  provided by the UNIX operating system.  The most impor-
  1990.           tant thing to note about these tools is that  although  they  are
  1991.           available,  they  are  typically not put to use in most installa-
  1992.           tions.  Therefore, it is incumbent on you, the system administra-
  1993.           tor,  to take the time and make the effort to enable these tools,
  1994.           and thus to protect your system from unauthorized access.
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.                                          30
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.                                       SECTION 3
  2057.  
  2058.                                  MONITORING SECURITY
  2059.  
  2060.  
  2061.  
  2062.                One of the most important tasks in keeping any computer sys-
  2063.           tem  secure  is  monitoring  the  security  of  the system.  This
  2064.           involves examining system log files for unauthorized accesses  of
  2065.           the  system, as well as monitoring the system itself for security
  2066.           holes.  This section describes the procedures for doing this.  An
  2067.           additional  part  of monitoring security involves keeping abreast
  2068.           of security problems found by others; this is described  in  Sec-
  2069.           tion 5.
  2070.  
  2071.  
  2072.           3.1   ACCOUNT SECURITY
  2073.  
  2074.  
  2075.  
  2076.                Account security should be monitored periodically  in  order
  2077.           to  check for two things: users logged in when they ``shouldn't''
  2078.           be (e.g., late at night, when they're  on  vacation,  etc.),  and
  2079.           users  executing  commands  they wouldn't normally be expected to
  2080.           use.  The commands described in  this  section  can  be  used  to
  2081.           obtain this information from the system.
  2082.  
  2083.  
  2084.           3.1.1   The lastlog File
  2085.  
  2086.  
  2087.  
  2088.                The file /usr/adm/lastlog [Sun88a, 1485]  records  the  most
  2089.           recent  login  time  for  each  user  of the system.  The message
  2090.           printed each time you log in, e.g.,
  2091.  
  2092.                   Last login: Sat Mar 10 10:50:48 from spam.itstd.sri.c
  2093.  
  2094.           uses the time stored in the lastlog file.  Additionally, the last
  2095.           login  time reported by the finger command uses this time.  Users
  2096.           should be told to carefully examine this time whenever  they  log
  2097.           in,  and  to report unusual login times to the system administra-
  2098.           tor.  This is an easy way to detect account break-ins, since each
  2099.           user should remember the last time she logged into the system.
  2100.  
  2101.  
  2102.           3.1.2   The utmp and wtmp Files
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                          31
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.                The file /etc/utmp [Sun88a, 1485] is used to record  who  is
  2122.           currently  logged  into  the  system.  This file can be displayed
  2123.           using the who command [Sun88a, 597]:
  2124.  
  2125.                   % who
  2126.                   hendra   tty0c   Mar 13 12:31
  2127.                   heidari  tty14   Mar 13 13:54
  2128.                   welgem   tty36   Mar 13 12:15
  2129.                   reagin   ttyp0   Mar 13 08:54   (aaifs.itstd.sri.)
  2130.                   ghg      ttyp1   Mar  9 07:03   (hydra.riacs.edu)
  2131.                   compion  ttyp2   Mar  1 03:01   (ei.ecn.purdue.ed)
  2132.  
  2133.           For each user, the login name, terminal being used,  login  time,
  2134.           and  remote  host  (if the user is logged in via the network) are
  2135.           displayed.
  2136.  
  2137.                The file /usr/adm/wtmp [Sun88a, 1485] records each login and
  2138.           logout  time  for  every  user.   This file can also be displayed
  2139.           using the who command:
  2140.  
  2141.                   % who /usr/adm/wtmp
  2142.                   davy     ttyp4    Jan  7 12:42 (annex01.riacs.ed)
  2143.                            ttyp4    Jan  7 15:33
  2144.                   davy     ttyp4    Jan  7 15:33 (annex01.riacs.ed)
  2145.                            ttyp4    Jan  7 15:35
  2146.                   hyder    ttyp3    Jan  8 09:07 (triceratops.itst)
  2147.                            ttyp3    Jan  8 11:43
  2148.  
  2149.           A line that contains a login name indicates  the  time  the  user
  2150.           logged  in; a line with no login name indicates the time that the
  2151.           terminal was logged off.  Unfortunately,  the  output  from  this
  2152.           command  is  rarely as simple as in the example above; if several
  2153.           users log in at once, the login and logout times  are  all  mixed
  2154.           together and must be matched up by hand using the terminal name.
  2155.  
  2156.                The wtmp file may also be examined using  the  last  command
  2157.           [Sun88a,  248].   This command sorts out the entries in the file,
  2158.           matching up login and logout  times.   With  no  arguments,  last
  2159.           displays  all  information  in the file.  By giving the name of a
  2160.           user or terminal, the output can be restricted to the information
  2161.           about  the  user or terminal in question.  Sample output from the
  2162.           last command is shown below.
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                          32
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.                   % last
  2189.                   davy      ttyp3  intrepid.itstd.s Tue Mar 13 10:55 - 10:56 (00:00)
  2190.                   hyder     ttyp3  clyde.itstd.sri. Mon Mar 12 15:31 - 15:36 (00:04)
  2191.                   reboot    ~                       Mon Mar 12 15:16
  2192.                   shutdown  ~                       Mon Mar 12 15:16
  2193.                   arms      ttyp3  clyde0.itstd.sri Mon Mar 12 15:08 - 15:12 (00:04)
  2194.                   hyder     ttyp3  spam.itstd.sri.c Sun Mar 11 21:08 - 21:13 (00:04)
  2195.                   reboot    ~                       Sat Mar 10 20:05
  2196.                   davy      ftp    hydra.riacs.edu  Sat Mar 10 13:23 - 13:30 (00:07)
  2197.  
  2198.           For each login session, the user name, terminal used, remote host
  2199.           (if  the user logged in via the network), login and logout times,
  2200.           and session duration are shown.  Additionally, the times  of  all
  2201.           system  shutdowns  and  reboots  (generated  by  the shutdown and
  2202.           reboot commands  [Sun88a,  1727,  1765])  are  recorded.   Unfor-
  2203.           tunately,  system crashes are not recorded.  In newer versions of
  2204.           the operating system, pseudo logins such as  those  via  the  ftp
  2205.           command  are  also  recorded;  an example of this is shown in the
  2206.           last line of the sample output, above.
  2207.  
  2208.  
  2209.           3.1.3   The acct File
  2210.  
  2211.  
  2212.  
  2213.                The file /usr/adm/acct [Sun88a, 1344-1345] records each exe-
  2214.           cution of a command on the system, who executed it, when, and how
  2215.           long it took.  This information is logged  each  time  a  command
  2216.           completes,  but only if your kernel was compiled with the SYSACCT
  2217.           option enabled (the option is enabled in  some  GENERIC  kernels,
  2218.           but is usually disabled by default).
  2219.  
  2220.                The acct file can be displayed using  the  lastcomm  command
  2221.           [Sun88a,  249].   With  no  arguments, all the information in the
  2222.           file is displayed.  However, by giving a command name, user name,
  2223.           or  terminal name as an argument, the output can be restricted to
  2224.           information about the given command, user, or  terminal.   Sample
  2225.           output from lastcomm is shown below.
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.                                          33
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.                   % lastcomm
  2255.                   sh         S     root     __         0.67 secs Tue Mar 13 12:45
  2256.                   atrun            root     __         0.23 secs Tue Mar 13 12:45
  2257.                   lpd         F    root     __         1.06 secs Tue Mar 13 12:44
  2258.                   lpr        S     burwell  tty09      1.23 secs Tue Mar 13 12:44
  2259.                   troff            burwell  tty09     12.83 secs Tue Mar 13 12:44
  2260.                   eqn              burwell  tty09      1.44 secs Tue Mar 13 12:44
  2261.                   df               kindred  ttyq7      0.78 secs Tue Mar 13 12:44
  2262.                   ls               kindred  ttyq7      0.28 secs Tue Mar 13 12:44
  2263.                   cat              kindred  ttyq7      0.05 secs Tue Mar 13 12:44
  2264.                   stty             kindred  ttyq7      0.05 secs Tue Mar 13 12:44
  2265.                   tbl              burwell  tty09      1.08 secs Tue Mar 13 12:44
  2266.                   rlogin     S     jones    ttyp3      5.66 secs Tue Mar 13 12:38
  2267.                   rlogin      F    jones    ttyp3      2.53 secs Tue Mar 13 12:41
  2268.                   stty             kindred  ttyq7      0.05 secs Tue Mar 13 12:44
  2269.  
  2270.           The first column indicates the name of  the  command.   The  next
  2271.           column displays certain flags on the command:  an ``F'' means the
  2272.           process spawned a child process, ``S'' means the process ran with
  2273.           the  set-user-id  bit  set, ``D'' means the process exited with a
  2274.           core dump, and ``X'' means the  process  was  killed  abnormally.
  2275.           The  remaining columns show the name of the user who ran the pro-
  2276.           gram, the terminal he ran it from (if applicable), the amount  of
  2277.           CPU  time used by the command (in seconds), and the date and time
  2278.           the process started.
  2279.  
  2280.  
  2281.           3.2   NETWORK SECURITY
  2282.  
  2283.  
  2284.  
  2285.                Monitoring network security is more difficult, because there
  2286.           are  so many ways for a cracker to attempt to break in.  However,
  2287.           there are some programs available to aid you in this task.  These
  2288.           are described in this section.
  2289.  
  2290.  
  2291.           3.2.1   The syslog Facility
  2292.  
  2293.  
  2294.  
  2295.                The syslog facility  [Sun88a,  1773]  is  a  mechanism  that
  2296.           enables  any command to log error messages and informational mes-
  2297.           sages to the system console, as well as to  a  log  file.   Typi-
  2298.           cally,  error  messages  are logged in the file /usr/adm/messages
  2299.           along with the date, time, name of the program sending  the  mes-
  2300.           sage, and (usually) the process id of the program.  A sample seg-
  2301.           ment of the messages file is shown below.
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.                                          34
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.                   Mar 12 14:53:37 sparkyfs login: ROOT LOGIN ttyp3 FROM setekfs.itstd.sr
  2321.                   Mar 12 15:18:08 sparkyfs login: ROOT LOGIN ttyp3 FROM setekfs.itstd.sr
  2322.                   Mar 12 16:50:25 sparkyfs login: ROOT LOGIN ttyp4 FROM pongfs.itstd.sri
  2323.                   Mar 12 16:52:20 sparkyfs vmunix: sd2c:  read failed, no retries
  2324.                   Mar 13 06:01:18 sparkyfs vmunix: /: file system full
  2325.                   Mar 13 08:02:03 sparkyfs login: ROOT LOGIN ttyp4 FROM triceratops.itst
  2326.                   Mar 13 08:28:52 sparkyfs su: davy on /dev/ttyp3
  2327.                   Mar 13 08:38:03 sparkyfs login: ROOT LOGIN ttyp4 FROM triceratops.itst
  2328.                   Mar 13 10:56:54 sparkyfs automount[154]: host aaifs not responding
  2329.                   Mar 13 11:30:42 sparkyfs login: REPEATED LOGIN FAILURES ON ttyp3 FROM
  2330.                                   intrepid.itstd.s, daemon
  2331.  
  2332.           Of particular interest in this sample are the messages  from  the
  2333.           login  and  su  programs.   Whenever someone logs in as ``root,''
  2334.           login logs this information.  Generally, logging in  as  ``root''
  2335.           directly,   rather   than   using   the  su  command,  should  be
  2336.           discouraged, as it is hard to  track  which  person  is  actually
  2337.           using  the  account.   Once  this  ability  has been disabled, as
  2338.           described  in  Section  2.2.2,  detecting  a  security  violation
  2339.           becomes  a simple matter of searching the messages file for lines
  2340.           of this type.
  2341.  
  2342.                Login also logs any case of someone repeatedly trying to log
  2343.           in  to  an account and failing.  After three attempts, login will
  2344.           refuse to let the person try anymore.  Searching for  these  mes-
  2345.           sages  in the messages file can alert you to a cracker attempting
  2346.           to guess someone's password.
  2347.  
  2348.                Finally, when someone uses the su command, either to  become
  2349.           ``root'' or someone  else, su logs the success or failure of this
  2350.           operation.  These messages can be used to check for users sharing
  2351.           their  passwords, as well as for a cracker who has penetrated one
  2352.           account and is trying to penetrate others.
  2353.  
  2354.  
  2355.           3.2.2   The showmount Command
  2356.  
  2357.  
  2358.  
  2359.                The showmount command [Sun88a, 1764] can be used on  an  NFS
  2360.           file server to display the names of all hosts that currently have
  2361.           something mounted from the server.  With no options, the  program
  2362.           simply  displays  a  list  of  all the hosts.  With the -a and -d
  2363.           options, the output is somewhat more useful.  The  first  option,
  2364.           -a,  causes showmount to list all the host and directory combina-
  2365.           tions.  For example,
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.                                          35
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.                   bronto.itstd.sri.com:/usr/share
  2387.                   bronto.itstd.sri.com:/usr/local.new
  2388.                   bronto.itstd.sri.com:/usr/share/lib
  2389.                   bronto.itstd.sri.com:/var/spool/mail
  2390.                   cascades.itstd.sri.com:/sparky/a
  2391.                   clyde.itstd.sri.com:/laser_dumps
  2392.                   cm1.itstd.sri.com:/sparky/a
  2393.                   coco0.itstd.sri.com:/sparky/a
  2394.  
  2395.           There will be one line of output for each directory mounted by  a
  2396.           host.   With  the  -d  option,  showmount  displays a list of all
  2397.           directories that are presently mounted by some host.
  2398.  
  2399.                The output from showmount should be checked for two  things.
  2400.           First,  only  machines  local  to your organization should appear
  2401.           there.  If you have set up proper netgroups as described in  Sec-
  2402.           tion  2.2.3,  this  should not be a problem.  Second, only ``nor-
  2403.           mal'' directories should be mounted.  If you find unusual  direc-
  2404.           tories  being  mounted,  you should find out who is mounting them
  2405.           and why - although it is probably innocent, it may indicate some-
  2406.           one trying to get around your security mechanisms.
  2407.  
  2408.  
  2409.           3.3   FILE SYSTEM SECURITY
  2410.  
  2411.  
  2412.  
  2413.                Checking for security holes in the file  system  is  another
  2414.           important part of making your system secure.  Primarily, you need
  2415.           to check for files that can be modified  by  unauthorized  users,
  2416.           files  that  can  inadvertently grant users too many permissions,
  2417.           and files that can inadvertently grant access to crackers.  It is
  2418.           also important to be able to detect unauthorized modifications to
  2419.           the file system, and to recover  from  these  modifications  when
  2420.           they are made.
  2421.  
  2422.  
  2423.           3.3.1   The find Command
  2424.  
  2425.  
  2426.  
  2427.                The find command [Sun88a, 183-185] is a general-purpose com-
  2428.           mand  for  searching  the  file system.  Using various arguments,
  2429.           complex matching patterns based on a  file's  name,  type,  mode,
  2430.           owner,  modification time, and other characteristics, can be con-
  2431.           structed.  The names of files that are found using these patterns
  2432.           can then be printed out, or given as arguments to other UNIX com-
  2433.           mands.  The general format of a find command is
  2434.  
  2435.                   % find directories options
  2436.  
  2437.  
  2438.  
  2439.                                          36
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.           where directories is a list of directory names to  search  (e.g.,
  2452.           /usr),  and options contains the options to control what is being
  2453.           searched for.  In general, for the examples in this section,  you
  2454.           will  always want to search from the root of the file system (/),
  2455.           in order to find all files matching the patterns presented.
  2456.  
  2457.                This section describes how to use find to  search  for  four
  2458.           possible security problems that were described in Section 2.
  2459.  
  2460.  
  2461.           3.3.1.1   Finding Setuid and Setgid Files
  2462.  
  2463.  
  2464.  
  2465.                It is important to check the system often  for  unauthorized
  2466.           setuid and setgid programs.  Because these programs grant special
  2467.           privileges to the user who is executing them, it is necessary  to
  2468.           ensure that insecure programs are not installed.  Setuid ``root''
  2469.           programs should be closely guarded - a  favorite  trick  of  many
  2470.           crackers  is to break into ``root'' once, and leave a setuid pro-
  2471.           gram hidden somewhere that will enable them to regain  super-user
  2472.           powers even if the original hole is plugged.
  2473.  
  2474.                The command to search for setuid and setgid files is
  2475.  
  2476.                   # find / -type f -a \( -perm -4000 -o -perm -2000 \) -print
  2477.  
  2478.           The options to this command have the following meanings:
  2479.  
  2480.                /    The name of the directory  to  be  searched.   In  this
  2481.                     case,  we  want to search the entire file system, so we
  2482.                     specify /.  You might instead restrict  the  search  to
  2483.                     /usr or /home.
  2484.  
  2485.                -type f
  2486.                     Only examine files whose type is ``f,''  regular  file.
  2487.                     Other  options  include  ``d'' for directory, ``l'' for
  2488.                     symbolic link, ``c'' for character-special devices, and
  2489.                     ``b'' for block-special devices.
  2490.  
  2491.                -a   This specifies ``and.''  Thus, we want  to  know  about
  2492.                     files whose type is ``regular file,'' and whose permis-
  2493.                     sions bits match the other part of this expression.
  2494.  
  2495.                \( -perm -4000 -o -perm -2000 \)
  2496.                     The parentheses in this part of the  command  are  used
  2497.                     for  grouping.   Thus,  everything  in this part of the
  2498.                     command matches a single pattern, and is treated as the
  2499.                     other half of the ``and'' clause described above.
  2500.  
  2501.                     -perm -4000
  2502.  
  2503.  
  2504.  
  2505.                                          37
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.                          This specifies a match if the ``4000'' bit (speci-
  2518.                          fied as an octal number) is set in the file's per-
  2519.                          mission modes.  This is the set-user-id bit.
  2520.  
  2521.                     -o   This specifies ``or.''  Thus, we want to match  if
  2522.                          the  file  has  the  set-user-id  bit  or the set-
  2523.                          group-id bit set.
  2524.  
  2525.                     -perm -2000
  2526.                          This specifies a match if the ``2000'' bit (speci-
  2527.                          fied as an octal number) is set in the file's per-
  2528.                          mission modes.  This is the set-group-id bit.
  2529.  
  2530.                -printThis indicates that for  any  file  that  matches  the
  2531.                     specified  expression  (is  a  regular file and has the
  2532.                     setuid or setgid bits set in  its  permissions),  print
  2533.                     its name on the screen.
  2534.  
  2535.                After executing this command (depending  on  how  much  disk
  2536.           space  you have, it can take anywhere from 15 minutes to a couple
  2537.           of hours to complete), you will have a list of  files  that  have
  2538.           setuid  or setgid bits set on them.  You should then examine each
  2539.           of these programs, and determine  whether  they  should  actually
  2540.           have  these  permissions.  You should be especially suspicious of
  2541.           programs that are not in one of the directories (or  a  subdirec-
  2542.           tory) shown below.
  2543.  
  2544.                   /bin
  2545.                   /etc
  2546.                   /usr/bin
  2547.                   /usr/ucb
  2548.                   /usr/etc
  2549.  
  2550.  
  2551.                One file distributed with SunOS, /usr/etc/restore,  is  dis-
  2552.           tributed  with  the  setuid  bit  set  on  it, and should not be,
  2553.           because of a security hole.  You should be  sure  to  remove  the
  2554.           setuid bit from this program by executing the command
  2555.  
  2556.                   # chmod u-s /usr/etc/restore
  2557.  
  2558.  
  2559.  
  2560.           3.3.1.2   Finding World-Writable Files
  2561.  
  2562.  
  2563.  
  2564.                World-writable files, particularly system files,  can  be  a
  2565.           security  hole if a cracker gains access to your system and modi-
  2566.           fies  them.    Additionally,   world-writable   directories   are
  2567.           dangerous,  since  they allow a cracker to add or delete files as
  2568.  
  2569.  
  2570.  
  2571.                                          38
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.           he wishes.  The find command to find all world-writable files is
  2584.  
  2585.                   # find / -perm -2 -print
  2586.  
  2587.           In this case, we do not use the  -type  option  to  restrict  the
  2588.           search,  since  we  are  interested in directories and devices as
  2589.           well as files.  The -2 specifies the world write bit (in octal).
  2590.  
  2591.                This list of files will be fairly  long,  and  will  include
  2592.           some files that should be world writable.  You should not be con-
  2593.           cerned if terminal devices  in  /dev  are  world  writable.   You
  2594.           should  also  not be concerned about line printer error log files
  2595.           being world writable.  Finally, symbolic links may be world writ-
  2596.           able  -  the permissions on a symbolic link, although they exist,
  2597.           have no meaning.
  2598.  
  2599.  
  2600.           3.3.1.3   Finding Unowned Files
  2601.  
  2602.  
  2603.  
  2604.                Finding files that are owned by nonexistent users can  often
  2605.           be  a clue that a cracker has gained access to your system.  Even
  2606.           if this is not the case, searching for these files gives  you  an
  2607.           opportunity  to  clean  up files that should have been deleted at
  2608.           the same time the user herself was deleted.  The command to  find
  2609.           unowned files is
  2610.  
  2611.                   # find / -nouser -print
  2612.  
  2613.           The -nouser option matches files that are owned by a user id  not
  2614.           contained   in  the  /etc/passwd  database.   A  similar  option,
  2615.           -nogroup, matches files owned by nonexistent groups.  To find all
  2616.           files  owned by nonexistent users or groups, you would use the -o
  2617.           option as follows:
  2618.  
  2619.                   # find / -nouser -o -nogroup -print
  2620.  
  2621.  
  2622.  
  2623.           3.3.1.4   Finding .rhosts Files
  2624.  
  2625.  
  2626.  
  2627.                As mentioned in Section 2.2.1.2, users should be  prohibited
  2628.           from having .rhosts files in their accounts.  To search for this,
  2629.           it is only necessary to search the parts of the file system  that
  2630.           contain home directories (i.e., you can skip / and /usr):
  2631.  
  2632.                   # find /home -name .rhosts -print
  2633.  
  2634.  
  2635.  
  2636.  
  2637.                                          39
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.           The -name option indicates that the complete  name  of  any  file
  2650.           whose name matches .rhosts should be printed on the screen.
  2651.  
  2652.  
  2653.           3.3.2   Checklists
  2654.  
  2655.  
  2656.  
  2657.                Checklists can be a useful tool for discovering unauthorized
  2658.           changes  made  to  system  directories.  They aren't practical on
  2659.           file systems that contain users'  home  directories  since  these
  2660.           change  all  the time.  A checklist is a listing of all the files
  2661.           contained in a group of directories:  their sizes, owners, modif-
  2662.           ication dates, and so on.  Periodically, this information is col-
  2663.           lected and compared with the information in the master checklist.
  2664.           Files  that  do  not  match in all attributes can be suspected of
  2665.           having been changed.
  2666.  
  2667.                There are several utilities that implement checklists avail-
  2668.           able from public software sites (see Section 4).  However, a sim-
  2669.           ple utility can be constructed using only the  standard  UNIX  ls
  2670.           and diff commands.
  2671.  
  2672.                First, use the ls command [Sun88a, 285] to generate a master
  2673.           list.  This is best done immediately after installing the operat-
  2674.           ing system, but can be done at any time provided you're confident
  2675.           about the correctness of the files on the disk.  A sample command
  2676.           is shown below.
  2677.  
  2678.                   # ls -aslgR /bin /etc /usr > MasterChecklist
  2679.  
  2680.           The file MasterChecklist now contains a complete list of all  the
  2681.           files  in  these  directories.  You will probably want to edit it
  2682.           and delete the lines for files you know will  be  changing  often
  2683.           (e.g.,   /etc/utmp,  /usr/adm/acct).   The  MasterChecklist  file
  2684.           should be stored somewhere safe where a cracker  is  unlikely  to
  2685.           find  it  (since  he could otherwise just change the data in it):
  2686.           either on a different computer system, or on magnetic tape.
  2687.  
  2688.                To search for changes in the file system, run the  above  ls
  2689.           command  again,  saving  the  output  in  some  other  file,  say
  2690.           CurrentList.  Now use the diff command [Sun88a, 150]  to  compare
  2691.           the two files:
  2692.  
  2693.                   # diff MasterChecklist CurrentList
  2694.  
  2695.           Lines that are only in the master checklist will be printed  pre-
  2696.           ceded  by  a  ``<,''  and lines that are only in the current list
  2697.           will be preceded by a ``>.''  If there is one line  for  a  file,
  2698.           preceded  by  a  ``<,'' this means that the file has been deleted
  2699.           since the master checklist was created.  If there is one line for
  2700.  
  2701.  
  2702.  
  2703.                                          40
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.           a  file,  preceded  by a ``>,'' this means that the file has been
  2716.           created since the master checklist was created.  If there are two
  2717.           lines  for  a single file, one preceded by ``<'' and the other by
  2718.           ``>,'' this indicates that some attribute of the file has changed
  2719.           since the master checklist was created.
  2720.  
  2721.                By carefully  constructing  the  master  checklist,  and  by
  2722.           remembering  to update it periodically (you can replace it with a
  2723.           copy of CurrentList, once you're sure the differences between the
  2724.           lists are harmless), you can easily monitor your system for unau-
  2725.           thorized changes.  The software packages available from the  pub-
  2726.           lic  software  distribution  sites  implement  basically the same
  2727.           scheme as the one here, but offer many more options for  control-
  2728.           ling what is examined and reported.
  2729.  
  2730.  
  2731.           3.3.3   Backups
  2732.  
  2733.  
  2734.  
  2735.                It is impossible to overemphasize the need for a good backup
  2736.           strategy.   File  system backups not only protect you in the even
  2737.           of hardware failure or accidental deletions, but they  also  pro-
  2738.           tect  you  against  unauthorized  file  system  changes made by a
  2739.           cracker.
  2740.  
  2741.                A good backup strategy will dump the entire system at  level
  2742.           zero  (a  ``full''  dump)  at  least  once  a month.  Partial (or
  2743.           ``incremental'') dumps should be done at least twice a week,  and
  2744.           ideally  they  should  be  done daily.  The dump command [Sun88a,
  2745.           1612-1614] is recommended over other programs  such  as  tar  and
  2746.           cpio.   This is because only dump is capable of creating a backup
  2747.           that can be used to restore a disk to the exact state it  was  in
  2748.           when  it was dumped.  The other programs do not take into account
  2749.           files deleted or renamed between dumps, and do  not  handle  some
  2750.           specialized database files properly.
  2751.  
  2752.  
  2753.           3.4   KNOW YOUR SYSTEM
  2754.  
  2755.  
  2756.  
  2757.                Aside from running large monitoring programs such  as  those
  2758.           described in the previous sections, simple everyday UNIX commands
  2759.           can also be useful for spotting security violations.  By  running
  2760.           these  commands often, whenever you have a free minute (for exam-
  2761.           ple, while waiting for someone to answer  the  phone),  you  will
  2762.           become  used  to  seeing  a specific pattern of output.  By being
  2763.           familiar with the processes normally running on your system,  the
  2764.           times different users typically log in, and so on, you can easily
  2765.           detect when something is out of the ordinary.
  2766.  
  2767.  
  2768.  
  2769.                                          41
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.           3.4.1   The ps Command
  2782.  
  2783.  
  2784.  
  2785.                The ps command [Sun88a, 399-402]  displays  a  list  of  the
  2786.           processes  running  on your system.  Ps has numerous options, too
  2787.           many to list here.  Generally, however, for the purpose of  moni-
  2788.           toring, the option string -alxww is the most useful.*  On  a  Sun
  2789.           system  running  SunOS 4.0, you should expect to see at least the
  2790.           following:
  2791.  
  2792.                swapper, pagedaemon
  2793.                     System programs that help the virtual memory system.
  2794.  
  2795.                /sbin/init
  2796.                     The init process, which  is  responsible  for  numerous
  2797.                     tasks,  including bringing up login processes on termi-
  2798.                     nals.
  2799.  
  2800.                portmap, ypbind, ypserv
  2801.                     Parts of the Yellow Pages system.
  2802.  
  2803.                biod, nfsd, rpc.mountd, rpc.quotad, rpc.lockd
  2804.                     Parts of the Network File System (NFS).  If the  system
  2805.                     you  are  looking  at  is  not  a file server, the nfsd
  2806.                     processes probably won't exist.
  2807.  
  2808.                rarpd, rpc.bootparamd
  2809.                     Part of the system  that  allows  diskless  clients  to
  2810.                     boot.
  2811.  
  2812.                Other commands you should expect to  see  are  update  (file
  2813.           system  updater);  getty  (one  per terminal and one for the con-
  2814.           sole); lpd (line printer daemon);  inetd  (Internet  daemon,  for
  2815.           starting other network servers); sh and csh (the Bourne shell and
  2816.           C shell, one or more per logged in user).  In addition, if  there
  2817.           are  users  logged in, you'll probably see invocations of various
  2818.           compilers, text editors, and word processing programs.
  2819.  
  2820.  
  2821.           3.4.2   The who and w Commands
  2822.  
  2823.  
  2824.  
  2825.                The who command, as mentioned previously, displays the  list
  2826.           of  users  currently  logged  in  on the system.  By running this
  2827.           periodically, you can learn at what times during the day  various
  2828.           _________________________
  2829.             * This  is  true  for  Berkeley-based  systems.   On  System  V
  2830.           systems, the option string -elf should be used instead.
  2831.  
  2832.  
  2833.  
  2834.  
  2835.                                          42
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.           users log in.  Then, when you see someone logged  in  at  a  dif-
  2848.           ferent  time, you can investigate and make sure that it's legiti-
  2849.           mate.
  2850.  
  2851.                The w command [Sun88a, 588] is somewhat of a  cross  between
  2852.           who  and  ps.   Not  only does it show a list of who is presently
  2853.           logged in, but it also displays how  long  they  have  been  idle
  2854.           (gone  without  typing  anything),  and  what  command  they  are
  2855.           currently running.
  2856.  
  2857.  
  2858.           3.4.3   The ls Command
  2859.  
  2860.  
  2861.  
  2862.                Simple as its function is, ls is actually  very  useful  for
  2863.           detecting  file system problems.  Periodically, you should use ls
  2864.           on the  various  system  directories,  checking  for  files  that
  2865.           shouldn't be there.  Most of the time, these files will have just
  2866.           ``landed'' somewhere by accident.  However, by  keeping  a  close
  2867.           watch on things, you will be able to detect a cracker long before
  2868.           you might have otherwise.
  2869.  
  2870.                When using ls to check for oddities, be sure to use  the  -a
  2871.           option,  which  lists  files whose names begin with a period (.).
  2872.           Be particularly alert for files or directories named ``...'',  or
  2873.           ``..(space)'',  which  many  crackers  like  to use.  (Of course,
  2874.           remember that ``.'' and ``..'' are supposed to be there.)
  2875.  
  2876.  
  2877.           3.5   KEEP YOUR EYES OPEN
  2878.  
  2879.  
  2880.  
  2881.                Monitoring for security breaches is every bit  as  important
  2882.           as  preventing  them  in the first place.  Because it's virtually
  2883.           impossible to make a system totally secure, there is  always  the
  2884.           chance,  no matter how small, that a cracker will be able to gain
  2885.           access.  Only by monitoring can this be detected and remedied.
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.                                          43
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.                                          44
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.                                       SECTION 4
  2981.  
  2982.                            SOFTWARE FOR IMPROVING SECURITY
  2983.  
  2984.  
  2985.  
  2986.                Because security is of great concern to many sites, a wealth
  2987.           of software has been developed for improving the security of UNIX
  2988.           systems.  Much of this software has been developed  at  universi-
  2989.           ties and other public institutions, and is available free for the
  2990.           asking.   This  section  describes  how  this  software  can   be
  2991.           obtained, and mentions some of the more important programs avail-
  2992.           able.
  2993.  
  2994.  
  2995.           4.1   OBTAINING FIXES AND NEW VERSIONS
  2996.  
  2997.  
  2998.  
  2999.                Several sites on the Internet maintain large repositories of
  3000.           public-domain  and  freely  distributable software, and make this
  3001.           material available for anonymous  FTP.   This  section  describes
  3002.           some of the larger repositories.
  3003.  
  3004.  
  3005.           4.1.1   Sun Fixes on UUNET
  3006.  
  3007.  
  3008.  
  3009.                Sun Microsystems has contracted  with  UUNET  Communications
  3010.           Services,  Inc.  to make fixes for bugs in Sun software available
  3011.           via anonymous FTP.  You can access these fixes by using  the  ftp
  3012.           command  [Sun88a,  195-201]  to  connect  to the host ftp.uu.net.
  3013.           Then change into the directory sun-fixes, and obtain a  directory
  3014.           listing, as shown in the example on the following page.
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.                                          45
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.           % ftp ftp.uu.net
  3047.           Connected to uunet.UU.NET.
  3048.           220 uunet FTP server (Version 5.93 Tue Mar 20 11:01:52 EST 1990) ready.
  3049.           Name (ftp.uu.net:davy): anonymous
  3050.           331 Guest login ok, send ident as password.
  3051.           Password:               enter your mail address yourname@yourhost here
  3052.           230 Guest login ok, access restrictions apply.
  3053.           ftp> cd sun-fixes
  3054.           250 CWD command successful.
  3055.           ftp> dir
  3056.           200 PORT command successful.
  3057.           150 Opening ASCII mode data connection for /bin/ls.
  3058.           total 2258
  3059.           -rw-r--r--  1 38       22           4558 Aug 31  1989 README
  3060.           -rw-r--r--  1 38       22         484687 Dec 14  1988 ddn.tar.Z
  3061.           -rw-r--r--  1 38       22         140124 Jan 13  1989 gated.sun3.Z
  3062.           -rwxr-xr-x  1 38       22          22646 Dec 14  1988 in.ftpd.sun3.Z
  3063.           .....
  3064.           .....
  3065.           -rw-r--r--  1 38       22          72119 Aug 31  1989 sendmail.sun3.Z
  3066.           -rwxr-xr-x  1 38       22          99147 Aug 31  1989 sendmail.sun4.Z
  3067.           -rw-r--r--  1 38       22           3673 Jul 11  1989 wall.sun3.Z
  3068.           -rw-r--r--  1 38       22           4099 Jul 11  1989 wall.sun4.Z
  3069.           -rwxr-xr-x  1 38       22           7955 Jan 18  1989 ypbind.sun3.Z
  3070.           -rwxr-xr-x  1 38       22           9237 Jan 18  1989 ypbind.sun4.Z
  3071.           226 Transfer complete.
  3072.           1694 bytes received in 0.39 seconds (4.2 Kbytes/s)
  3073.           ftp> quit
  3074.           221 Goodbye.
  3075.           %
  3076.  
  3077.           The file README contains a brief description of what each file in
  3078.           this directory contains, and what is required to install the fix.
  3079.  
  3080.  
  3081.           4.1.2   Berkeley Fixes
  3082.  
  3083.  
  3084.  
  3085.                The University of California at Berkeley  also  makes  fixes
  3086.           available via anonymous FTP; these fixes pertain primarily to the
  3087.           current release of BSD UNIX (currently  release  4.3).   However,
  3088.           even if you are not running their software, these fixes are still
  3089.           important, since many vendors (Sun, DEC,  Sequent  ,  etc.)  base
  3090.           their software on the Berkeley releases.
  3091.  
  3092.                The Berkeley fixes are available for anonymous FTP from  the
  3093.           host  ucbarpa.berkeley.edu  in  the directory 4.3/ucb-fixes.  The
  3094.           file INDEX in this directory describes what each file contains.
  3095.  
  3096.  
  3097.  
  3098.  
  3099.                                          46
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.                Berkeley also distributes new versions of sendmail and named
  3112.           [Sun88a,  1758-1760,  1691-1692] from this machine.  New versions
  3113.           of these commands are stored in the 4.3 directory, usually in the
  3114.           files sendmail.tar.Z and bind.tar.Z, respectively.
  3115.  
  3116.  
  3117.           4.1.3   Simtel-20 and UUNET
  3118.  
  3119.  
  3120.  
  3121.                The two largest general-purpose software repositories on the
  3122.           Internet are the hosts wsmr-simtel20.army.mil and ftp.uu.net.
  3123.  
  3124.                wsmr-simtel20.army.mil is a TOPS-20 machine operated by  the
  3125.           U.  S. Army at White Sands Missile Range, New Mexico.  The direc-
  3126.           tory pd2:<unix-c> contains a large amount of UNIX software,  pri-
  3127.           marily  taken  from  the  comp.sources newsgroups.  The file 000-
  3128.           master-index.txt contains a master list and description  of  each
  3129.           piece  of  software  available  in the repository.  The file 000-
  3130.           intro-unix-sw.txt contains information on the mailing  list  used
  3131.           to  announce  new software, and describes the procedures used for
  3132.           transferring files from the archive with FTP.
  3133.  
  3134.                ftp.uu.net is operated  by  UUNET  Communications  Services,
  3135.           Inc.  in Falls Church, Virginia.  This company sells Internet and
  3136.           USENET access to sites all over  the  country  (and  internation-
  3137.           ally).   The software posted to the following USENET source news-
  3138.           groups is stored here, in directories of the same name:
  3139.  
  3140.                   comp.sources.games
  3141.                   comp.sources.misc
  3142.                   comp.sources.sun
  3143.                   comp.sources.unix
  3144.                   comp.sources.x
  3145.  
  3146.           Numerous other distributions, such as all the  freely  distribut-
  3147.           able  Berkeley  UNIX  source  code, Internet Request for Comments
  3148.           (RFCs), and so on are also stored on this machine.
  3149.  
  3150.  
  3151.           4.1.4   Vendors
  3152.  
  3153.  
  3154.  
  3155.                Many vendors make fixes for bugs in their software available
  3156.           electronically,  either  via  mailing lists or via anonymous FTP.
  3157.           You should contact your vendor to find out  if  they  offer  this
  3158.           service,  and  if  so, how to access it.  Some vendors that offer
  3159.           these services include  Sun  Microsystems  (see  above),  Digital
  3160.           Equipment  Corp.,  the  University of California at Berkeley (see
  3161.           above), and Apple Computer.
  3162.  
  3163.  
  3164.  
  3165.                                          47
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.           4.2   THE NPASSWD COMMAND
  3178.  
  3179.  
  3180.  
  3181.                The npasswd  command,  developed  by  Clyde  Hoover  at  the
  3182.           University  of  Texas  at Austin, is intended to be a replacement
  3183.           for the standard UNIX passwd command [Sun88a, 379],  as  well  as
  3184.           the  Sun yppasswd command [Sun88a, 611].  npasswd makes passwords
  3185.           more secure by refusing to allow users to select  insecure  pass-
  3186.           words.  The following capabilities are provided by npasswd:
  3187.  
  3188.                +    Configurable minimum password length
  3189.  
  3190.                +    Configurable to force users to use mixed case or digits
  3191.                     and punctuation
  3192.  
  3193.                +    Checking for ``simple'' passwords such  as  a  repeated
  3194.                     letter
  3195.  
  3196.                +    Checking against the host name and other  host-specific
  3197.                     information
  3198.  
  3199.                +    Checking against the login name, first and last  names,
  3200.                     and so on
  3201.  
  3202.                +    Checking for words in various  dictionaries,  including
  3203.                     the system dictionary.
  3204.  
  3205.                The npasswd distribution is available for anonymous FTP from
  3206.           emx.utexas.edu in the directory pub/npasswd.
  3207.  
  3208.  
  3209.           4.3   THE COPS PACKAGE
  3210.  
  3211.  
  3212.  
  3213.  
  3214.                COPS is a  security  tool  for  system  administrators  that
  3215.           checks  for  numerous  common  security problems on UNIX systems,
  3216.           including many of the things described in this document.  COPS is
  3217.           a  collection  of shell scripts and C programs that can easily be
  3218.           run on almost any UNIX variant.  Among other  things,  it  checks
  3219.           the  following items and sends the results to the system adminis-
  3220.           trator:
  3221.  
  3222.                +    Checks  /dev/kmem   and   other   devices   for   world
  3223.                     read/writability.
  3224.  
  3225.                +    Checks  special/important  files  and  directories  for
  3226.                     ``bad'' modes (world writable, etc.).
  3227.  
  3228.  
  3229.  
  3230.  
  3231.                                          48
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.                +    Checks for easily guessed passwords.
  3244.  
  3245.                +    Checks for duplicate user ids, invalid  fields  in  the
  3246.                     password file, etc.
  3247.  
  3248.                +    Checks for duplicate group ids, invalid fields  in  the
  3249.                     group file, etc.
  3250.  
  3251.                +    Checks all users' home directories  and  their  .cshrc,
  3252.                     .login,  .profile, and .rhosts files for security prob-
  3253.                     lems.
  3254.  
  3255.                +    Checks all  commands  in  the  /etc/rc  files  [Sun88a,
  3256.                     1724-1725] and cron files [Sun88a, 1606-1607] for world
  3257.                     writability.
  3258.  
  3259.                +    Checks for bad ``root'' paths, NFS file system exported
  3260.                     to the world, etc.
  3261.  
  3262.                +    Includes an expert system that checks to see if a given
  3263.                     user  (usually ``root'') can be compromised, given that
  3264.                     certain rules are true.
  3265.  
  3266.                +    Checks for changes in the setuid status of programs  on
  3267.                     the system.
  3268.  
  3269.                The COPS package is  available  from  the  comp.sources.unix
  3270.           archive  on  ftp.uu.net,  and  also  from the repository on wsmr-
  3271.           simtel20.army.mil.
  3272.  
  3273.  
  3274.           4.4   SUN C2 SECURITY FEATURES
  3275.  
  3276.  
  3277.  
  3278.                With the release of SunOS 4.0,  Sun  has  included  security
  3279.           features  that  allow  the system to operate at a higher level of
  3280.           security, patterned after the C2* classification.  These features
  3281.           can be installed as one of the options when installing the system
  3282.           from the distribution tapes.  The security features added by this
  3283.           option include
  3284.  
  3285.                +    Audit trails that record all login  and  logout  times,
  3286.                     the  execution of administrative commands, and the exe-
  3287.                     cution of privileged (setuid) operations.
  3288.           _________________________
  3289.  
  3290.             * C2 is one of several security classifications defined by  the
  3291.           National  Computer Security Center, and is described in [NCSC85],
  3292.           the ``orange book.''
  3293.  
  3294.  
  3295.  
  3296.  
  3297.                                          49
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.  
  3308.  
  3309.                +    A more secure password file mechanism  (``shadow  pass-
  3310.                     word  file'')  that  prevents crackers from obtaining a
  3311.                     list of the encrypted passwords.
  3312.  
  3313.                +    DES encryption capability.
  3314.  
  3315.                +    A (more) secure NFS implementation that uses public-key
  3316.                     encryption  to authenticate the users of the system and
  3317.                     the hosts on the network, to be sure  they  really  are
  3318.                     who they claim to be.
  3319.  
  3320.           These security features are described in detail in [Sun88c].
  3321.  
  3322.  
  3323.           4.5   KERBEROS
  3324.  
  3325.  
  3326.  
  3327.                Kerberos [Stei88] is an authentication system  developed  by
  3328.           the  Athena Project at the Massachusetts Institute of Technology.
  3329.           Kerberos  is  a  third-party  authentication  service,  which  is
  3330.           trusted by other network services.  When a user logs in, Kerberos
  3331.           authenticates that user (using a password), and provides the user
  3332.           with a way to prove her identity to other servers and hosts scat-
  3333.           tered around the network.
  3334.  
  3335.                This authentication is then used by programs such as  rlogin
  3336.           [Sun88a,  418-419]  to  allow  the  user to log in to other hosts
  3337.           without a password (in place of the .rhosts file).  The authenti-
  3338.           cation is also used by the mail system in order to guarantee that
  3339.           mail is delivered to the correct person, as well as to  guarantee
  3340.           that  the sender is who he claims to be.  NFS has also been modi-
  3341.           fied by M.I.T. to work with Kerberos, thereby making  the  system
  3342.           much more secure.
  3343.  
  3344.                The overall effect of installing Kerberos and  the  numerous
  3345.           other  programs  that  go  with  it is to virtually eliminate the
  3346.           ability of users to ``spoof'' the system into believing they  are
  3347.           someone   else.    Unfortunately,  installing  Kerberos  is  very
  3348.           intrusive, requiring the modification or replacement of  numerous
  3349.           standard  programs.  For this reason, a source license is usually
  3350.           necessary.  There are plans to make Kerberos a part of 4.4BSD, to
  3351.           be  released by the University of California at Berkeley sometime
  3352.           in 1990.
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.                                          50
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.                                       SECTION 5
  3377.  
  3378.                              KEEPING ABREAST OF THE BUGS
  3379.  
  3380.  
  3381.  
  3382.                One of the hardest things about keeping a system  secure  is
  3383.           finding  out  about the security holes before a cracker does.  To
  3384.           combat this, there are several sources of information you can and
  3385.           should make use of on a regular basis.
  3386.  
  3387.  
  3388.           5.1   THE COMPUTER EMERGENCY RESPONSE TEAM
  3389.  
  3390.  
  3391.  
  3392.                The Computer Emergency Response Team (CERT) was  established
  3393.           in December 1988 by the Defense Advanced Research Projects Agency
  3394.           to address computer security concerns of research  users  of  the
  3395.           Internet.   It  is operated by the Software Engineering Institute
  3396.           at Carnegie-Mellon University.  The CERT serves as a focal  point
  3397.           for  the  reporting of security violations, and the dissemination
  3398.           of security advisories to the Internet community.   In  addition,
  3399.           the  team works with vendors of various systems in order to coor-
  3400.           dinate the fixes for security problems.
  3401.  
  3402.                The CERT sends out security advisories to the  cert-advisory
  3403.           mailing  list  whenever appropriate.  They also operate a 24-hour
  3404.           hotline that can be called to  report  security  problems  (e.g.,
  3405.           someone  breaking into your system), as well as to obtain current
  3406.           (and accurate) information about rumored security problems.
  3407.  
  3408.                To join the cert-advisory mailing list, send  a  message  to
  3409.           cert@cert.sei.cmu.edu  and  ask  to be added to the mailing list.
  3410.           Past advisories are available for anonymous  FTP  from  the  host
  3411.           cert.sei.cmu.edu.  The 24-hour hotline number is (412) 268-7090.
  3412.  
  3413.  
  3414.           5.2   DDN MANAGEMENT BULLETINS
  3415.  
  3416.  
  3417.  
  3418.                The DDN Management Bulletin is distributed electronically by
  3419.           the  Defense  Data Network (DDN) Network Information Center under
  3420.           contract to the Defense Communications Agency.  It is a means  of
  3421.           communicating  official policy, procedures, and other information
  3422.           of concern to management personnel at DDN facilities.
  3423.  
  3424.                The DDN Security Bulletin is distributed  electronically  by
  3425.           the  DDN  SCC (Security Coordination Center), also under contract
  3426.  
  3427.  
  3428.  
  3429.                                          51
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.  
  3440.  
  3441.           to DCA, as a means of communicating information  on  network  and
  3442.           host  security  exposures,  fixes,  and  concerns to security and
  3443.           management personnel at DDN facilities.
  3444.  
  3445.                Anyone may join the mailing lists for these two bulletins by
  3446.           sending  a  message to nic@nic.ddn.mil and asking to be placed on
  3447.           the mailing lists.
  3448.  
  3449.  
  3450.           5.3   SECURITY-RELATED MAILING LISTS
  3451.  
  3452.  
  3453.  
  3454.                There are several other mailing lists operated on the Inter-
  3455.           net  that  pertain  directly  or  indirectly  to various security
  3456.           issues.  Some of the more useful ones are described below.
  3457.  
  3458.  
  3459.           5.3.1   Security
  3460.  
  3461.  
  3462.  
  3463.                The UNIX Security  mailing  list  exists  to  notify  system
  3464.           administrators  of  security  problems  before they become common
  3465.           knowledge, and to provide security enhancement  information.   It
  3466.           is a restricted-access list, open only to people who can be veri-
  3467.           fied as being principal systems people at a  site.   Requests  to
  3468.           join  the  list must be sent by either the site contact listed in
  3469.           the Network Information Center's  WHOIS  database,  or  from  the
  3470.           ``root''  account  on  one  of the major site machines.  You must
  3471.           include the destination address you want on the list, an  indica-
  3472.           tion  of  whether  you  want  to be on the mail reflector list or
  3473.           receive weekly digests, the electronic  mail  address  and  voice
  3474.           telephone  number  of  the  site contact if it isn't you, and the
  3475.           name, address, and telephone number of your  organization.   This
  3476.           information should be sent to security-request@cpd.com.
  3477.  
  3478.  
  3479.           5.3.2   RISKS
  3480.  
  3481.  
  3482.  
  3483.                The RISKS digest is a component of the ACM Committee on Com-
  3484.           puters and Public Policy, moderated by Peter G. Neumann.  It is a
  3485.           discussion forum on risks to the public in computers and  related
  3486.           systems,  and along with discussing computer security and privacy
  3487.           issues, has discussed such subjects as the  Stark  incident,  the
  3488.           shooting  down of the Iranian airliner in the Persian Gulf (as it
  3489.           relates to the computerized weapons systems), problems in air and
  3490.           railroad  traffic  control  systems, software engineering, and so
  3491.           on.   To  join  the  mailing  list,  send  a  message  to  risks-
  3492.  
  3493.  
  3494.  
  3495.                                          52
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.           request@csl.sri.com.   This  list is also available in the USENET
  3508.           newsgroup comp.risks.
  3509.  
  3510.  
  3511.           5.3.3   TCP-IP
  3512.  
  3513.  
  3514.  
  3515.                The TCP-IP list is intended to act as a discussion forum for
  3516.           developers  and maintainers of implementations of the TCP/IP pro-
  3517.           tocol suite.  It also discusses network-related security problems
  3518.           when  they  involve  programs providing network services, such as
  3519.           sendmail.  To join the TCP-IP list, send  a  message  to  tcp-ip-
  3520.           request@nic.ddn.mil.   This  list is also available in the USENET
  3521.           newsgroup comp.protocols.tcp-ip.
  3522.  
  3523.  
  3524.           5.3.4   SUN-SPOTS, SUN-NETS, SUN-MANAGERS
  3525.  
  3526.  
  3527.  
  3528.                The SUN-SPOTS, SUN-NETS, and SUN-MANAGERS lists are all dis-
  3529.           cussion  groups  for users and administrators of systems supplied
  3530.           by Sun Microsystems.  SUN-SPOTS is a fairly  general  list,  dis-
  3531.           cussing  everything  from  hardware configurations to simple UNIX
  3532.           questions.   To  subscribe,  send   a   message   to   sun-spots-
  3533.           request@rice.edu.   This  list  is  also  available in the USENET
  3534.           newsgroup comp.sys.sun.
  3535.  
  3536.                SUN-NETS is a discussion list for items pertaining  to  net-
  3537.           working  on  Sun  systems.   Much of the discussion is related to
  3538.           NFS, Yellow Pages, and name servers.  To subscribe, send  a  mes-
  3539.           sage to sun-nets-request@umiacs.umd.edu.
  3540.  
  3541.                SUN-MANAGERS is a discussion list for Sun system administra-
  3542.           tors  and  covers  all  aspects of Sun system administration.  To
  3543.           subscribe, send a message to sun-managers-request@eecs.nwu.edu.
  3544.  
  3545.  
  3546.           5.3.5   VIRUS-L
  3547.  
  3548.  
  3549.  
  3550.                The VIRUS-L list is a forum for the discussion  of  computer
  3551.           virus  experiences, protection software, and related topics.  The
  3552.           list is open to the public, and is implemented as a mail  reflec-
  3553.           tor,  not  a  digest.  Most of the information is related to per-
  3554.           sonal computers, although some of it may be applicable to  larger
  3555.           systems.  To subscribe, send the line
  3556.  
  3557.                   SUB VIRUS-L your full name
  3558.  
  3559.  
  3560.  
  3561.                                          53
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.           to the address listserv%lehiibm1.bitnet@mitvma.mit.edu.
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.                                          54
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.                                       SECTION 6
  3641.  
  3642.                                   SUGGESTED READING
  3643.  
  3644.  
  3645.  
  3646.                This section suggests some alternate sources of  information
  3647.           pertaining to the security and administration of the UNIX operat-
  3648.           ing system.
  3649.  
  3650.           UNIX System Administration Handbook
  3651.           Evi Nemeth, Garth Snyder, Scott Seebass
  3652.           Prentice Hall, 1989, $26.95
  3653.  
  3654.                This is perhaps the best general-purpose book on UNIX system
  3655.                administration  currently on the market.  It covers Berkeley
  3656.                UNIX, SunOS, and System V.  The 26 chapters  and  17  appen-
  3657.                dices  cover numerous topics, including booting and shutting
  3658.                down the system, the file system,  configuring  the  kernel,
  3659.                adding  a  disk,  the line printer spooling system, Berkeley
  3660.                networking, sendmail, and uucp.  Of particular interest  are
  3661.                the  chapters  on  running  as  the super-user, backups, and
  3662.                security.
  3663.  
  3664.           UNIX Operating System Security
  3665.           F. T. Grammp and R. H. Morris
  3666.           AT&T Bell Laboratories Technical Journal
  3667.           October 1984
  3668.  
  3669.                This is an excellent discussion of some of the  more  common
  3670.                security  problems in UNIX and how to avoid them, written by
  3671.                two of Bell Labs' most prominent security experts.
  3672.  
  3673.           Password Security: A Case History
  3674.           Robert Morris and Ken Thompson
  3675.           Communications of the ACM
  3676.           November 1979
  3677.  
  3678.                An excellent discussion on the problem of password security,
  3679.                and  some interesting information on how easy it is to crack
  3680.                passwords and why.  This document is  usually  reprinted  in
  3681.                most vendors' UNIX documentation.
  3682.  
  3683.           On the Security of UNIX
  3684.           Dennis M. Ritchie
  3685.           May 1975
  3686.  
  3687.                A discussion on UNIX security from one of the original crea-
  3688.                tors  of  the system.  This document is usually reprinted in
  3689.                most vendors' UNIX documentation.
  3690.  
  3691.  
  3692.  
  3693.                                          55
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.           The Cuckoo's Egg
  3706.           Clifford Stoll
  3707.           Doubleday, 1989, $19.95
  3708.  
  3709.                An excellent story of Stoll's experiences tracking down  the
  3710.                German  crackers who were breaking into his systems and sel-
  3711.                ling the data they found to the KGB.   Written  at  a  level
  3712.                that nontechnical users can easily understand.
  3713.  
  3714.           System and Network Administration
  3715.           Sun Microsystems
  3716.           May, 1988
  3717.  
  3718.                Part of the SunOS documentation,  this  manual  covers  most
  3719.                aspects  of  Sun  system  administration, including security
  3720.                issues.  A must for anyone operating a  Sun  system,  and  a
  3721.                pretty good reference for other UNIX systems as well.
  3722.  
  3723.           Security Problems in the TCP/IP Protocol Suite
  3724.           S. M. Bellovin
  3725.           ACM Computer Communications Review
  3726.           April, 1989
  3727.  
  3728.                An interesting discussion of some of the  security  problems
  3729.                with  the  protocols  in  use on the Internet and elsewhere.
  3730.                Most of these problems are far beyond  the  capabilities  of
  3731.                the  average  cracker, but it is still important to be aware
  3732.                of them.  This article is technical in nature,  and  assumes
  3733.                familiarity with the protocols.
  3734.  
  3735.           A Weakness in the 4.2BSD UNIX TCP/IP Software
  3736.           Robert T. Morris
  3737.           AT&T Bell Labs Computer Science Technical Report 117
  3738.           February, 1985
  3739.  
  3740.                An interesting article from the author of the Internet worm,
  3741.                which  describes  a  method  that  allows  remote  hosts  to
  3742.                ``spoof'' a host into believing they  are  trusted.   Again,
  3743.                this article is technical in nature, and assumes familiarity
  3744.                with the protocols.
  3745.  
  3746.           Computer Viruses and Related Threats: A Management Guide
  3747.           John P. Wack and Lisa J. Carnahan
  3748.           National Institute of Standards and Technology
  3749.           Special Publication 500-166
  3750.  
  3751.                This document  provides  a  good  introduction  to  viruses,
  3752.                worms,  trojan horses, and so on, and explains how they work
  3753.                and how they are used to attack computer  systems.   Written
  3754.                for the nontechnical user, this is a good starting point for
  3755.                learning about these security problems.  This  document  can
  3756.  
  3757.  
  3758.  
  3759.                                          56
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769.  
  3770.  
  3771.                be  ordered  for  $2.50  from  the U. S. Government Printing
  3772.                Office, document number 003-003-02955-6.
  3773.  
  3774.  
  3775.  
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.                                          57
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.                                          58
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.                                       SECTION 7
  3905.  
  3906.                                      CONCLUSIONS
  3907.  
  3908.  
  3909.  
  3910.                Computer security is playing an increasingly important  role
  3911.           in our lives as more and more operations become computerized, and
  3912.           as computer networks become more widespread.  In order to protect
  3913.           your  systems  from snooping and vandalism by unauthorized crack-
  3914.           ers, it is necessary to enable  the  numerous  security  features
  3915.           provided by the UNIX system.
  3916.  
  3917.                In this document, we have covered the major areas  that  can
  3918.           be made more secure:
  3919.  
  3920.                +    Account security
  3921.  
  3922.                +    Network security
  3923.  
  3924.                +    File system security.
  3925.  
  3926.           Additionally, we have discussed how to monitor for security  vio-
  3927.           lations, where to obtain security-related software and bug fixes,
  3928.           and numerous mailing lists for finding out about  security  prob-
  3929.           lems that have been discovered.
  3930.  
  3931.                Many crackers are not interested in breaking  into  specific
  3932.           systems, but rather will break into any system that is vulnerable
  3933.           to the attacks they know.  Eliminating these well-known holes and
  3934.           monitoring  the  system  for other security problems will usually
  3935.           serve as adequate defense against all  but  the  most  determined
  3936.           crackers.   By using the procedures and sources described in this
  3937.           document, you can make your system more secure.
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.                                          59
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.                                          60
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.  
  4033.  
  4034.  
  4035.                                      REFERENCES
  4036.  
  4037.  
  4038.  
  4039.           [Eich89]  Eichin, Mark W., and Jon A. Rochlis.   With  Microscope
  4040.                     and  Tweezers:   An  Analysis  of the Internet Virus of
  4041.                     November 1988.  Massachusetts Institute of  Technology.
  4042.                     February 1989.
  4043.  
  4044.           [Elme88]  Elmer-DeWitt, Philip.   ``  `The  Kid  Put  Us  Out  of
  4045.                     Action.' '' Time, 132 (20): 76, November 14, 1988.
  4046.  
  4047.           [Gram84]  Grammp, F. T., and R. H. Morris.  ``UNIX Operating Sys-
  4048.                     tem Security.''  AT&T Bell Laboratories Technical Jour-
  4049.                     nal, 63 (8): 1649-1672, October 1984.
  4050.  
  4051.           [Hind83]  Hinden, R., J. Haverty, and A. Sheltzer.   ``The  DARPA
  4052.                     Internet:  Interconnecting  Heterogeneous Computer Net-
  4053.                     works with Gateways.''  IEEE Computer Magazine, 16 (9):
  4054.                     33-48, September 1983.
  4055.  
  4056.           [McLe87]  McLellan, Vin.  ``NASA Hackers:  There's  More  to  the
  4057.                     Story.''  Digital Review, November 23, 1987, p. 80.
  4058.  
  4059.           [Morr78]  Morris, Robert, and Ken Thompson.  ``Password Security:
  4060.                     A  Case History.''  Communications of the ACM, 22 (11):
  4061.                     594-597,  November  1979.   Reprinted  in  UNIX  System
  4062.                     Manager's  Manual,  4.3 Berkeley Software Distribution.
  4063.                     University of California, Berkeley.  April 1986.
  4064.  
  4065.           [NCSC85]  National  Computer  Security  Center.   Department   of
  4066.                     Defense  Trusted  Computer  System Evaluation Criteria,
  4067.                     Department  of  Defense   Standard   DOD   5200.28-STD,
  4068.                     December, 1985.
  4069.  
  4070.           [Quar86]  Quarterman, J. S., and J. C. Hoskins.   ``Notable  Com-
  4071.                     puter  Networks.''  Communications of the ACM, 29 (10):
  4072.                     932-971, October 1986.
  4073.  
  4074.           [Reed84]  Reeds, J. A., and P. J.  Weinberger.   ``File  Security
  4075.                     and the UNIX System Crypt Command.''  AT&T Bell Labora-
  4076.                     tories Technical Journal, 63  (8):  1673-1683,  October
  4077.                     1984.
  4078.  
  4079.           [Risk87]  Forum on Risks to the Public in Computers  and  Related
  4080.                     Systems.  ACM Committee on Computers and Public Policy,
  4081.                     Peter G. Neumann, Moderator.   Internet  mailing  list.
  4082.                     Issue 5.73, December 13, 1987.
  4083.  
  4084.           [Risk88]  Forum on Risks to the Public in Computers  and  Related
  4085.                     Systems.  ACM Committee on Computers and Public Policy,
  4086.  
  4087.  
  4088.  
  4089.                                          61
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.                     Peter G. Neumann, Moderator.   Internet  mailing  list.
  4102.                     Issue 7.85, December 1, 1988.
  4103.  
  4104.           [Risk89a] Forum on Risks to the Public in Computers  and  Related
  4105.                     Systems.  ACM Committee on Computers and Public Policy,
  4106.                     Peter G. Neumann, Moderator.   Internet  mailing  list.
  4107.                     Issue 8.2, January 4, 1989.
  4108.  
  4109.           [Risk89b] Forum on Risks to the Public in Computers  and  Related
  4110.                     Systems.  ACM Committee on Computers and Public Policy,
  4111.                     Peter G. Neumann, Moderator.   Internet  mailing  list.
  4112.                     Issue 8.9, January 17, 1989.
  4113.  
  4114.           [Risk90]  Forum on Risks to the Public in Computers  and  Related
  4115.                     Systems.  ACM Committee on Computers and Public Policy,
  4116.                     Peter G. Neumann, Moderator.   Internet  mailing  list.
  4117.                     Issue 9.69, February 20, 1990.
  4118.  
  4119.           [Ritc75]  Ritchie, Dennis M.  ``On the Security of  UNIX.''   May
  4120.                     1975.   Reprinted  in UNIX System Manager's Manual, 4.3
  4121.                     Berkeley Software Distribution.  University of Califor-
  4122.                     nia, Berkeley.  April 1986.
  4123.  
  4124.           [Schu90]  Schuman, Evan.  ``Bid to Unhook Worm.''   UNIX  Today!,
  4125.                     February 5, 1990, p. 1.
  4126.  
  4127.           [Seel88]  Seeley, Donn.  A Tour of the Worm.  Department of  Com-
  4128.                     puter Science, University of Utah.  December 1988.
  4129.  
  4130.           [Spaf88]  Spafford, Eugene H.   The  Internet  Worm  Program:  An
  4131.                     Analysis.   Technical Report CSD-TR-823.  Department of
  4132.                     Computer Science, Purdue University.  November 1988.
  4133.  
  4134.           [Stee88]  Steele, Guy L. Jr., Donald R. Woods, Raphael A. Finkel,
  4135.                     Mark  R.  Crispin, Richard M. Stallman, and Geoffrey S.
  4136.                     Goodfellow.  The Hacker's Dictionary.  New York: Harper
  4137.                     and Row, 1988.
  4138.  
  4139.           [Stei88]  Stein, Jennifer G., Clifford  Neuman,  and  Jeffrey  L.
  4140.                     Schiller.   ``Kerberos:  An  Authentication Service for
  4141.                     Open Network Systems.''  USENIX Conference Proceedings,
  4142.                     Dallas, Texas, Winter 1988, pp. 203-211.
  4143.  
  4144.           [Stol88]  Stoll, Clifford.  ``Stalking the Wily  Hacker.''   Com-
  4145.                     munications of the ACM, 31 (5): 484-497, May 1988.
  4146.  
  4147.           [Stol89]  Stoll, Clifford.  The Cuckoo's Egg.  New York:  Double-
  4148.                     day, 1989.
  4149.  
  4150.           [Sun88a]  Sun Microsystems.  SunOS Reference Manual, Part  Number
  4151.                     800-1751-10, May 1988.
  4152.  
  4153.  
  4154.  
  4155.                                          62
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.           [Sun88b]  Sun Microsystems.  System and  Network  Administration,
  4168.                     Part Number 800-1733-10, May 1988.
  4169.  
  4170.           [Sun88c]  Sun Microsystems.  Security Features Guide, Part Number
  4171.                     800-1735-10, May 1988.
  4172.  
  4173.           [Sun88d]  Sun Microsystems.  ``Network  File  System:  Version  2
  4174.                     Protocol  Specification.''   Network  Programming, Part
  4175.                     Number 800-1779-10, May 1988, pp. 165-185.
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.                                          63
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.  
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.                                          64
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.                            APPENDIX A - SECURITY CHECKLIST
  4300.  
  4301.  
  4302.  
  4303.                This checklist summarizes the information presented in  this
  4304.           paper, and can be used to verify that you have implemented every-
  4305.           thing described.
  4306.  
  4307.  
  4308.  
  4309.           Account Security
  4310.                []        Password policy developed and distributed to all users
  4311.                []        All passwords checked against obvious choices
  4312.                []        Expiration dates on all accounts
  4313.                []        No ``idle'' guest accounts
  4314.                []        All accounts have passwords or ``*'' in the password field
  4315.                []        No group accounts
  4316.                []        ``+'' lines in passwd and group checked if running Yellow Pages
  4317.  
  4318.           Network Security
  4319.                []        hosts.equiv contains only local hosts, and no ``+''
  4320.                []        No .rhosts files in users' home directories
  4321.                []        Only local hosts in ``root'' .rhosts file, if any
  4322.                []        Only ``console'' labeled as ``secure'' in ttytab (servers only)
  4323.                []        No terminals labeled as ``secure'' in ttytab (clients only)
  4324.                []        No NFS file systems exported to the world
  4325.                []        ftpd version later than December, 1988
  4326.                []        No ``decode'' alias in the aliases file
  4327.                []        No ``wizard'' password in sendmail.cf
  4328.                []        No ``debug'' command in sendmail
  4329.                []        fingerd version later than November 5, 1988
  4330.                []        Modems and terminal servers handle hangups correctly
  4331.  
  4332.           File System Security
  4333.                []        No setuid or setgid shell scripts
  4334.                []        Check all ``nonstandard'' setuid and setgid programs for security
  4335.                []        Setuid bit removed from /usr/etc/restore
  4336.                []        Sticky bits set on world-writable directories
  4337.                []        Proper umask value on ``root'' account
  4338.                []        Proper modes on devices in /dev
  4339.  
  4340.           Backups
  4341.                []        Level 0 dumps at least monthly
  4342.                []        Incremental dumps at least bi-weekly
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.                                          65
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.  
  4361.  
  4362.  
  4363.  
  4364.  
  4365.                          This page intentionally left blank.
  4366.                                  Just throw it out.
  4367.  
  4368.  
  4369.  
  4370.  
  4371.  
  4372.  
  4373.  
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.                                         lxvi
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.                                       CONTENTS
  4432.  
  4433.  
  4434.  
  4435.           1      INTRODUCTION...........................................  1
  4436.           1.1    UNIX Security..........................................  1
  4437.           1.2    The Internet Worm......................................  2
  4438.           1.3    Spies and Espionage....................................  2
  4439.           1.4    Other Break-Ins........................................  3
  4440.           1.5    Security is Important..................................  3
  4441.  
  4442.           2      IMPROVING SECURITY.....................................  5
  4443.           2.1    Account Security.......................................  5
  4444.           2.1.1  Passwords..............................................  5
  4445.           2.1.1.1                                                       Selecting Passwords6
  4446.           2.1.1.2                                                       Password Policies7
  4447.           2.1.1.3                                                       Checking Password Security7
  4448.           2.1.2  Expiration Dates.......................................  8
  4449.           2.1.3  Guest Accounts.........................................  8
  4450.           2.1.4  Accounts Without Passwords.............................  9
  4451.           2.1.5  Group Accounts and Groups..............................  9
  4452.           2.1.6  Yellow Pages........................................... 10
  4453.           2.2    Network Security....................................... 11
  4454.           2.2.1  Trusted Hosts.......................................... 11
  4455.           2.2.1.1                                                       The hosts.equiv File11
  4456.           2.2.1.2                                                       The .rhosts File12
  4457.           2.2.2  Secure Terminals....................................... 12
  4458.           2.2.3  The Network File System................................ 13
  4459.           2.2.3.1                                                       The exports File13
  4460.           2.2.3.2                                                       The netgroup File14
  4461.           2.2.3.3                                                       Restricting Super-User Access16
  4462.           2.2.4  FTP.................................................... 16
  4463.           2.2.4.1                                                       Trivial FTP17
  4464.           2.2.5  Mail................................................... 18
  4465.           2.2.6  Finger................................................. 19
  4466.           2.2.7  Modems and Terminal Servers............................ 19
  4467.           2.2.8  Firewalls.............................................. 20
  4468.           2.3    File System Security................................... 20
  4469.           2.3.1  Setuid Shell Scripts................................... 21
  4470.           2.3.2  The Sticky Bit on Directories.......................... 22
  4471.           2.3.3  The Setgid Bit on Directories.......................... 22
  4472.           2.3.4  The umask Value........................................ 22
  4473.           2.3.5  Encrypting Files....................................... 23
  4474.           2.3.6  Devices................................................ 23
  4475.           2.4    Security Is Your Responsibility........................ 24
  4476.  
  4477.           3      MONITORING SECURITY.................................... 25
  4478.           3.1    Account Security....................................... 25
  4479.           3.1.1  The lastlog File....................................... 25
  4480.           3.1.2  The utmp and wtmp Files................................ 25
  4481.           3.1.3  The acct File.......................................... 26
  4482.  
  4483.  
  4484.  
  4485.                                          iii
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.  
  4493.  
  4494.  
  4495.  
  4496.  
  4497.  
  4498.                                 CONTENTS (continued)
  4499.  
  4500.  
  4501.  
  4502.           3.2    Network Security.....................................27
  4503.           3.2.1  The syslog Facility..................................27
  4504.           3.2.2  The showmount Command................................28
  4505.           3.3    File System Security.................................29
  4506.           3.3.1  The find Command.....................................29
  4507.           3.3.1.1                      Finding Setuid and Setgid Files29
  4508.           3.3.1.2                         Finding World-Writable Files31
  4509.           3.3.1.3                                Finding Unowned Files31
  4510.           3.3.1.4                                Finding .rhosts Files31
  4511.           3.3.2  Checklists...........................................32
  4512.           3.3.3  Backups..............................................33
  4513.           3.4    Know Your System.....................................33
  4514.           3.4.1  The ps Command.......................................33
  4515.           3.4.2  The who and w Commands...............................34
  4516.           3.4.3  The ls Command.......................................34
  4517.           3.5    Keep Your Eyes Open..................................34
  4518.  
  4519.           4      SOFTWARE FOR IMPROVING SECURITY......................35
  4520.           4.1    Obtaining Fixes and New Versions.....................35
  4521.           4.1.1  Sun Fixes on UUNET...................................35
  4522.           4.1.2  Berkeley Fixes.......................................36
  4523.           4.1.3  Simtel-20 and UUNET..................................37
  4524.           4.1.4  Vendors..............................................37
  4525.           4.2    The npasswd Command..................................37
  4526.           4.3    The COPS Package.....................................38
  4527.           4.4    Sun C2 Security Features.............................38
  4528.           4.5    Kerberos.............................................39
  4529.  
  4530.           5      KEEPING ABREAST OF THE BUGS..........................41
  4531.           5.1    The Computer Emergency Response Team.................41
  4532.           5.2    DDN Management Bulletins.............................41
  4533.           5.3    Security-Related Mailing Lists.......................42
  4534.           5.3.1  Security.............................................42
  4535.           5.3.2  RISKS................................................42
  4536.           5.3.3  TCP-IP...............................................42
  4537.           5.3.4  SUN-SPOTS, SUN-NETS, SUN-MANAGERS....................42
  4538.           5.3.5  VIRUS-L..............................................43
  4539.  
  4540.           6      SUGGESTED READING....................................45
  4541.  
  4542.           7      CONCLUSIONS..........................................47
  4543.  
  4544.           REFERENCES..................................................49
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.                                          iv
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.                                 CONTENTS (concluded)
  4565.  
  4566.  
  4567.  
  4568.           APPENDIX A - SECURITY CHECKLIST.............................51
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.                                           v
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.  
  4625.  
  4626.  
  4627.  
  4628.  
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.  
  4636.  
  4637.  
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.                                          vi
  4684.  
  4685.  
  4686.  
  4687.