home *** CD-ROM | disk | FTP | other *** search
/ Cuteskunk BBS / cuteskunk.zip / cuteskunk / Unix-Hacking-Documents / cops_dan_farmer.txt < prev    next >
Text File  |  2003-06-29  |  36KB  |  955 lines

  1.                       COPS and Robbers
  2.                     UN*X System Security
  3.  
  4.  
  5.  
  6.      In the last few years, computer security has received a
  7. great  deal  more attention than it has in the past.  Compu-
  8. terized break-ins and criminal  activity,  once  merely  the
  9. product  of  the imagination of science fiction writers, has
  10. became a fairly common  occurence  in  both  commercial  and
  11. academic  circles.   In this paper, I will go over the prob-
  12. lems that face any multiuser computing system, then  discuss
  13. how  these  problems  apply  to  UNIX[1]  specifically,  and
  14. finally  present  in  detail  a  suite of programs that were
  15. developed in an attempt to address some of the main problems
  16. that  could  be  solved  via  software.  UNIX, although con-
  17. sidered to be a fairly secure operating system  ([Wood  88],
  18. [Duff  89], etc), has the advantage of having many published
  19. works ([Grampp and Morris 84],  [Bishop  83],  etc)  on  the
  20. problems  that  a computing site can have with security, and
  21. in addition, on how a UNIX system administrator  might  make
  22. his/her  system more secure by monitoring various aspects of
  23. his/her UNIX site.  This, combined with  UNIX's  popularity,
  24. make  it  an  ideal target for a software security system to
  25. operate on.
  26.  
  27.      In this report I am not going to discuss specific  ways
  28. of  breaking  into a given UNIX machine (for a more detailed
  29. description on how to compromise UNIX security,  see  either
  30. [Baldwin88],  [Bishop83],  [Wood & Kochran 86], or [Grampp &
  31. Morris 84]) -- instead, I will concentrate on how to improve
  32. and  strengthen  the  potentially good security of a generic
  33. UNIX system by means of a software toolkit that examines the
  34. weaker  areas  of UNIX that are either traditionally ignored
  35. (due to the time constraints  or  ignorance  of  the  system
  36. administrators) or are simply reoccurring problems that need
  37. to be watched over.  In addition, this report is  not  meant
  38. for  UNIX  neophytes -- although a great deal of proficiency
  39. is not needed to read  this  report  and  use  the  programs
  40. described  herein, a familiarity with basic UNIX features --
  41. the file system and file permission modes for example -- and
  42. commands  such  as awk,grep,sed  as  well  as a working
  43. knowledge of  shell  and  C  programming  are  necessary  to
  44. _________________________
  45.   [1] Although originally designed and developed by Ken
  46. Thompson and Dennis Ritchie of AT&T, UNIX has grown far
  47. beyond its' original design and now numerous  companies
  48. market their own "flavor" of UNIX.  When I use the term
  49. UNIX in this paper, I don't mean merely AT&T's version,
  50. but  instead  I  mean  the majority of the most popular
  51. varieties, made by developers at Berkely,  Sun,  and  a
  52. host of other manufacturers.  I believe UNIX is still a
  53. trademark of Bell Laboratories.
  54.  
  55.  
  56.                      February 19, 1991
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                            - 2 -
  63.  
  64.  
  65. understand the internal  workings  of  the  security  system
  66. described in this paper.
  67.  
  68.      Although there is no reasonable way that  all  security
  69. problems  can  be solved (at least not with a software solu-
  70. tion) on any arbitrary UNIX system, administrators and  sys-
  71. tem  programs  can  be assisted by a software security tool.
  72. The Computer Oracle Password and Security system (COPS) that
  73. will  be described in this paper is just such a device.  The
  74. COPS system is a collection of programs  and  shell  scripts
  75. that  attempt to address as many of these problems as possi-
  76. ble in an efficient, portable, and above all in  a  reliable
  77. and  safe  way.  The main goal of COPS is one of prevention;
  78. it tries to anticipate and eliminate  security  problems  by
  79. making sure people don't get a chance to compromise security
  80. in the first place.  Alerting the administrators of a poten-
  81. tial  intruder  or  that  a virus has infected the system is
  82. beyond the scope of the present system, although  with  work
  83. with  such  capabilities could be added ([Bauer and Koblentz
  84. 88] and [Duff 89].)
  85.  
  86.      To understand the reason COPS might check any  specific
  87. problem,  a look at computer security problems in general is
  88. in order.  The problems listed below are  not  meant  to  be
  89. inclusive,  but  they  are indicative of the myriad types of
  90. dilemmas  a  typical   computer   multiuser   system   might
  91. encounter:
  92.  
  93.      1)  Administrators, system  programmers,  and  computer
  94. operators.   The  very  people  that (should) worry the most
  95. about security are sometimes the ones  that  are  the  least
  96. concerned.  Carelessness is one of the main culprits; a mis-
  97. take by a user might cause little or no  problem,  but  when
  98. someone  with no restrictions (or almost none) on their com-
  99. puter activity makes a mistake, a security hole can  result.
  100. "I  can  trust  my users" is a fine statement to make -- but
  101. can you trust your users' friends?  How about the  users  of
  102. computers  that  are networked to yours?  New software, sys-
  103. tems, or procedures can facilitate extra problems; a comput-
  104. ing  staff  is  often  ill  or completely non-trained on new
  105. techniques and software.   Too  often  "RTFM"  is  the  only
  106. training  that  they  will  ever receive.  Programs that are
  107. created for in-house use are often  ill-documented  and  not
  108. debugged  thoroughly,  and  when users other than the author
  109. start to use/abuse the program, problems can result.   Espe-
  110. cially  misunderstood,  even by experienced UNIX system pro-
  111. grammers, is the SUID program or, worse yet, the SUID  shell
  112. script ([Bishop 83].) When a user says that his/her password
  113. was forgotten (or any other account/security  related  prob-
  114. lem),  what  checks  are  made  to verify that the person is
  115. really the owner of that account?  Are users that are  secu-
  116. rity  problems kept track of, so that repeated abuses of the
  117. system will result in punitive action?  Does your site  even
  118. have  a  security  policy?  And of course, the last straw is
  119.  
  120.  
  121.  
  122.                      February 19, 1991
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                            - 3 -
  129.  
  130.  
  131. that most system administrators simply have too  much  other
  132. work to do than to constantly check the system for potential
  133. security flaws -- let alone to double-check  that  any  work
  134. done  by  other  system programmers has been done correctly.
  135. These are the actions that often get left unsaid and undone.
  136.  
  137.      A UNIX environment has no special defenses against this
  138. kind  of "attack".  Fortunately, a number of these potential
  139. problems  (unless  catastrophic  in  scope)  are  not   only
  140. correctable,  but are easy to detect with a software toolkit
  141. such as COPS.  Even the most careful UNIX guru will periodi-
  142. cally  make  a  mistake;  COPS  has  been designed to aid in
  143. her/his never ending battle against the forces of darkness.
  144.  
  145.      2)  Physical security.  This is perhaps the most  frus-
  146. trating of all possible problems because it effects all com-
  147. puter systems and is often the hardest to safeguard against.
  148. Even  if the software is secure, even if the system adminis-
  149. trators are alert to potential problems, what happens  if  a
  150. user  walks  up to the root console and starts typing?  Does
  151. the night janitorial staff let anyone into the machine  room
  152. without  proper  identification?  Who  has access to the key
  153. that opens up the computing center?  Are terminals that  are
  154. logged on left unguarded or unlocked?  Are passwords written
  155. on or near a users terminal or desk?   No  software  in  the
  156. world   can  help  against  human  nature  or  carelessness.
  157. Reiterating to your staff and users  that  terminals  should
  158. not  be  left  alone  or unguarded and that passwords (espe-
  159. cially root) should not be typed in front of unfriendly (and
  160. in this case, _everyone_ is your enemy) eyes would be a good
  161. start.  A simple analogy: since you  would  never  give  the
  162. keys  to  the  company car away, why on earth would you give
  163. away the keys to your computer, which is certainly  worth  a
  164. hell  of  a lot more time and money (although it may not get
  165. as good mileage on the interstate.)   Common  sense  goes  a
  166. long ways to help prevent this kind of risk.
  167.  
  168.      3)   Authentication.   What  is  authentication?    All
  169. modern computing systems that have capabilities for multiple
  170. users have a means of identifying who is using the  computer
  171. at  any  given time.  A common means of identification is by
  172. using a password; and since the inception of this idea, poor
  173. passwords have been a perennial problem.  People have a ten-
  174. dency to use  their  own  name,  or  their  social  security
  175. number,  or  some  other  common word, name, or phrase for a
  176. password.  The problem then arises when an unauthorized user
  177. wants to access clandestine information, he/she simply tries
  178. one of these simple passwords until a  successful  match  is
  179. found.
  180.  
  181.      Other  problems  with  authentication?   What  computer
  182. hosts  are  "trusted"  and  allow users to log in from other
  183. machines without any further authentication?  Are  incorrect
  184. login   attempts  kept  and/or  monitored  so  as  to  allow
  185.  
  186.  
  187.  
  188.                      February 19, 1991
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                            - 4 -
  195.  
  196.  
  197. administrators to keep track of any unusual activity?   What
  198. about  "Trojan  horses" -- programs that can steal passwords
  199. and the privileges that a user owns -- is there a program or
  200. a administrative method that detects a potential 'horse?
  201.  
  202.      Fortunately UNIX systems again have  some  fairly  good
  203. tools  to  aid in this fight.  Although finding simple pass-
  204. words is indeed a trivial task, forcing the users on a  sys-
  205. tem  to  use  passwords  that  are  harder  to guess is also
  206. trivial, by either modifying the mechanism  that  gets/gives
  207. the  password  to  the  user,  and/or  by  having the system
  208. administrators run a simple password detector  periodically,
  209. and notifying users if their password is deemed too obvious.
  210. The crypt command, although proven  to  be  insecure  for  a
  211. knowledgeable and resourceful attacker ([Reed and Weinberger
  212. 84], [Baldwin 86]), does offer an added shield against  most
  213. unauthorized  users.   Logs  can  be kept of incorrect login
  214. attempts, but as with most security measures, to  be  effec-
  215. tive  someone (usually the site administrator) must take the
  216. time to examine the evidence.
  217.  
  218.      4)  Bugs/Features.  Massive software designs  (such  as
  219. an  operating system) are usually the result of a team or of
  220. teams of developers working together.   It  only  takes  one
  221. programmer to make a mistake, and it will almost always hap-
  222. pen.  "Back doors" that  allow  unauthorized  entrances  are
  223. sometimes  purposefully  coded  in -- for debugging, mainte-
  224. nance, or other reasons.  And there  are  always  unexpected
  225. side effects when thousands of people using the system start
  226. doing strange (stupid?) things.  The best  kind  of  defense
  227. against  this  is to report the problems to the developer as
  228. they are discovered, and if possible, to also report  a  way
  229. to fix the problem.  Unfortunately, in many cases the source
  230. code is needed to make a bug fix,  and  especially  in  non-
  231. academic  areas,  this  is  simply  not available due to the
  232. prohibitive costs involved.  Combining this with the  reluc-
  233. tance of a (usually) commercial developer to admit any prob-
  234. lems with their product, and the end result  is  a  security
  235. hole  that  will not be mended unless some kind of financial
  236. loss or gain is at stake -- for the developer  of  the  pro-
  237. duct, not yours!
  238.  
  239.      5)  Ignorance.  Users who don't know or care can  be  a
  240. problem  as  well.  Even if someone doesn't care about their
  241. own security, they can  unwittingly  compromise  the  entire
  242. system   --   especially  if  they  are  a  user  with  high
  243. privileges.  Administrators and  system  operators  are  not
  244. immune to this either, but hopefully are better informed, or
  245. at least have access to a means of combating  this  dysfunc-
  246. tion.   It  may  also  be due to apathy, an unwillingness to
  247. learn a new system, a lack of time to  explore  all  of  the
  248. features  of  a  large system, or simply not enough computer
  249. savvy to learn more about a very complex system, and no  one
  250. willing  to teach it to the user.  This problem is much like
  251.  
  252.  
  253.  
  254.                      February 19, 1991
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                            - 5 -
  261.  
  262.  
  263. illiteracy; it is a never-ending battle that will  never  go
  264. completely  away.  And while a software toolkit such as COPS
  265. can  help  combat  this  problem  by  calling  attention  to
  266. neglected  or  misunderstood critical areas, by far and away
  267. the best weapon against this is education.  An educated user
  268. will simply not make as many mistakes; and while it may seem
  269. impractical to teach _all_ users about (even) the  fundamen-
  270. tals  of  computer  security,  think  of  all  the  time and
  271. resources wasted tracking down the mistakes that keep recur-
  272. ring time and time again.
  273.  
  274.      6)  Unauthorized permissions or privileges.  Are  users
  275. given _too much_ freedom?  Do new computer accounts have any
  276. default security at all, or are the new  users  expected  to
  277. know  what  to do to protect their programs, data, and other
  278. files.  System  files,  programs,  and  data  are  sometimes
  279. shipped  with  minimal or no protection when gotten straight
  280. from the manufacturer; someone at the installation site must
  281. have  enough  knowledge to "tune" the system to be effective
  282. and safe.  Password, memory, and log files especially should
  283. all be carefully monitored, but unfortunately an experienced
  284. user can often still find out any information they want with
  285. perseverance and a little luck.  This is where a system such
  286. as COPS can really shine.  After a new system is configured,
  287. some  basic  flaws can be uncovered with just a small amount
  288. of effort.  New system problems that  somehow  slip  through
  289. the cracks of the site installers can be caught and modified
  290. before any serious problems result.   The  key  here  is  to
  291. prevent  your system users from getting a denial of computer
  292. service that they need and deserve.  Service could mean any-
  293. thing from CPU time, response time, file space, or any other
  294. commodity that a computer has to offer.
  295.  
  296.      7)  Crackers/Hackers/Evil twin brothers.  Not  much  is
  297. needed  on this subject, save to say that they are often not
  298. the main problem.  Professional  evil-users  are  a  rarity;
  299. often harmful acts are done by users who "just wanted to see
  300. what would happen" or had no idea of  the  ramifications  of
  301. their acts.  Someone who is truly experienced is very diffi-
  302. cult to stop, and is certainly  outside  the  realm  of  any
  303. software  security  tool  as  discussed in this paper.  For-
  304. tunately,  most  evil-doers  are  fairly  inexperienced  and
  305. ignorant,  and when they make a mistake, a watchful adminis-
  306. trator can deal with a problem before it gets out  of  hand.
  307. Sometimes  they  can even reveal security problems that were
  308. previously undiscovered.   COPS  can  help  here  mostly  by
  309. reducing  an  attacker's options; the less holes to exploit,
  310. the better.
  311.  
  312.      The COPS system attempts to help protect as many of the
  313. above  items  as possible for a generic UNIX system.  In the
  314. proper UNIX spirit, instead of having a large  program  that
  315. attempts  to solve every possible problem, it is composed of
  316. several small programs that each check one or more potential
  317.  
  318.  
  319.  
  320.                      February 19, 1991
  321.  
  322.  
  323.  
  324.  
  325.  
  326.                            - 6 -
  327.  
  328.  
  329. UNIX  security  holes.   The  COPS  system uses a variety of
  330. these problems to see if there are any  cracks  in  a  given
  331. UNIX security wall.  These methods correspond to some of the
  332. problems discussed above;  specifically  to  administrators,
  333. system  programmers, and computer operators; authentication;
  334. ignorance;  unauthorized  permissions  or  privileges;   and
  335. finally  crackers/hackers/evil twin brothers (numbers 1,3,5,
  336. and 6.)  It is very difficult, almost a  practical  impossi-
  337. bility  to  give software assistance to problems in physical
  338. security, and finally bugs or features that are present in a
  339. given  UNIX  system  are  possible  to  detect,  but are not
  340. covered in this system (yet).  The design of most of the the
  341. programs  were  at  least described if not outlined from the
  342. following sources:
  343.  
  344. Aho, Kernighan, and Weinberger 88
  345.  
  346. Baldwin 87
  347.  
  348. Fiedler and Hunter 86
  349.  
  350. Grampp and Morris 84
  351.  
  352. Wood and Kochran 86
  353.  
  354.  
  355.      Of course with all of the problems listed below,  look-
  356. ing  at  the  actual  source  code  of  the  program is very
  357. instructive -- each numbered section lists the corresponding
  358. program that is used to perform the check:
  359.  
  360.      1)  COPS Checks "vital" system directories  to  see  if
  361. they are world-writable.  Directories listed as critical are
  362. in a configuration file and are initially:
  363.  
  364. / /etc /usr
  365.  
  366. /bin /Mail /usr/spool
  367.  
  368. /usr/adm /usr/etc /usr/lib
  369.  
  370. /usr/bin /usr/etc /usr/spool/mail
  371.  
  372. /usr/spool/uucp /usr/spool/at
  373.  
  374.      The method COPS uses to detect problems -- read through
  375. a  configuration  file  (dir.chklst)  containing  all of the
  376. potential danger  spots,  and  then  simply  comparing  each
  377. directory  modes with a bit mask to see if it is world writ-
  378. able.  The program that performs this task is dir.chk
  379.  
  380.      2)  Check "vital" system  files  to  see  if  they  are
  381. world-writable.   Files  listed  as critical are in a confi-
  382. guration file (file.chklst) and are initially:
  383.  
  384.  
  385.  
  386.                      February 19, 1991
  387.  
  388.  
  389.  
  390.  
  391.  
  392.                            - 7 -
  393.  
  394.  
  395. /.*
  396.  
  397. /etc/*
  398.  
  399. /bin/*
  400.  
  401. /usr/etc/yp*
  402.  
  403. /usr/lib/crontab /usr/lib/aliases /usr/lib/sendmail
  404.  
  405.  
  406. The wildcards are used like in UNIX, so these would  include
  407. (some of the more important files):
  408.  
  409. /.login /.profile /.cshrc /.crontab /.rhost
  410.  
  411. /etc/passwd /etc/group /etc/inittab /etc/rc
  412.  
  413. /etc/rc.local /etc/rc.boot /etc/hosts.equiv /etc/profile
  414.  
  415. /etc/syslog.conf /etc/export
  416.  
  417. As well as the executable command files (among others):
  418.  
  419. sh,csh, and ls.
  420.  
  421.  
  422.      Method -- again read through a configuration file list-
  423. ing  all  of the files to be checked, comparing each in turn
  424. with a write mask.  The program that performs this  task  is
  425. file.chk
  426.  
  427.      3)  Check "vital" system  files  to  see  if  they  are
  428. world-readable,  plus  check  for  a NFS file system with no
  429. restriction.  These critical files are:
  430.  
  431. /dev/kmem /dev/mem
  432.  
  433. All file systems found in /etc/fstab
  434.  
  435. Plus a small number of user selectable  files  --  initially
  436. set to include /.netrc, /usr/adm/sulog, and /etc/btmp.
  437.  
  438. Method -- checking each in turn  against  a  read  mask  for
  439. their  read  status.   The  file  system names are read from
  440. /etc/fstab, the selectable files are  kept  in  a  variable.
  441. The program that performs this task is dev.chk
  442.  
  443.      4)  Check all files in system for SUID status,  notify-
  444. ing the COPS user of any changes in SUID status.
  445.  
  446. Method -- Use the "find" command on the root directory (this
  447. must  be  done by root to avoid missing any files unreadable
  448. but still dangerous.) The previous run will  create  a  file
  449.  
  450.  
  451.  
  452.                      February 19, 1991
  453.  
  454.  
  455.  
  456.  
  457.  
  458.                            - 8 -
  459.  
  460.  
  461. that can be checked against the current run to keep track of
  462. changes in SUID status and any new SUID files.  The  program
  463. that performs this task is suid.chk and was written by Pren-
  464. tiss Riddle.
  465.  
  466.      5)  Check the /etc/passwd file (and  the  yellow  pages
  467. password   database,  if  applicable)  for  null  passwords,
  468. improper #  of  fields,  non-unique  user-id's,  non-numeric
  469. group id's, blank lines, and non-alphanumeric user-id's.
  470.  
  471. Method -- Read through password file, flag  any  differences
  472. with  normal password file, as documented in "man 5 passwd".
  473. Fortunately, the syntax of the password file  is  relatively
  474. simple  and  rigid.  The  program that performs this task is
  475. passwd.chk
  476.  
  477.  
  478.      6)  Check the /etc/group file  (and  the  yellow  pages
  479. database, if applicable) for groups with passwords, improper
  480. # of fields, duplicate users in  groups,  blank  lines,  and
  481. non-unique group-id's.
  482.  
  483. Method -- Read through group file, flag any differences with
  484. normal  group  file  as documented in "man 5 group".  Again,
  485. the syntax of this file is fairly simple.  The program  that
  486. performs this task is group.chk
  487.  
  488.      7)  Check passwords of users on system.
  489.  
  490. Method -- using  the  stock  "crypt"  command,  compare  the
  491. encrypted password found in the /etc/passwd file against the
  492. following (encrypted) guesses:
  493.  
  494. The login id (uid), information in the gecos field, and  all
  495. single letter passwords.
  496.  
  497. The program that performs this  task  is  pass.chk  and  was
  498. written  by  Craig  Leres  and  was modified by Seth Alford,
  499. Roger Southwick, Steve Dum, and Rick Lindsley.
  500.  
  501.      8)  Check the root path,  umask,  and  if  root  is  in
  502. /etc/ftpuser.
  503.  
  504. Method -- look inside the /.profile  and  /.cshrc  files  to
  505. ensure  that  all  of  the  directories listed are not world
  506. writable, that "." isn't anywhere in the path, and that  the
  507. umask  is  not set to create world writable files.  The pro-
  508. gram that performs this task is root.chk
  509.  
  510.      9)  Examine the commands in  /etc/rc*  to  ensure  that
  511. none of the files or paths used are world-writable.
  512.  
  513. Method -- grep through the files  and  examine  any  strings
  514. that  start  with  "/"  for  writability.   The program that
  515.  
  516.  
  517.  
  518.                      February 19, 1991
  519.  
  520.  
  521.  
  522.  
  523.  
  524.                            - 9 -
  525.  
  526.  
  527. performs this task is rc.chk
  528.  
  529.      10)  Examine the commands in /usr/lib/crontab to ensure
  530. that none of the files or paths used are world-writable.
  531.  
  532. Method -- grep through the  crontab  file  and  examine  any
  533. strings  after field five (first five are not files, but how
  534. crontab is to be run) that start with "/"  for  writability.
  535. The  program  that performs this task is cron.chk 11)  Check
  536. all of the user home directories  to  ensure  they  are  not
  537. world writable.
  538.  
  539. Method -- get all of the home directories using  the  system
  540. call  getpwent()  and  then  for every home directory found,
  541. check the write permissions of of the home directory against
  542. a bit mask.  The program that performs this task is home.chk
  543. and it was written by John Owens.
  544.  
  545.      12) Check important user files in  user's  home  direc-
  546. tories  to  ensure  they  are not world writable.  The files
  547. checked (all in the individual users'  home  directory,  all
  548. with the prefix "."):
  549.  
  550. rhost profile login cshrc kshrc tcshr crhost
  551.  
  552. netrc forward dbxinit distfile exrc emacsrc
  553.  
  554. Method -- using the same system call as #10, determine  user
  555. home  directory.   Then  simply check all of the above files
  556. against a bit mask.  The program that performs this task  is
  557. user.chk
  558.  
  559.      13) Given a goal to compromise, such as user root,  and
  560. a list of user and group id's that can be used in an attempt
  561. to achieve the goal, this security tool will search  through
  562. the  system until it verifies that the goal is compromisible
  563. or not.  The program that performs this tricky task is  part
  564. of the U-Kuang (rhymes with "twang") system.  Robert Baldwin
  565. was kind enough to allow me to include this security checker
  566. (a fine security machine in it's own right) within this dis-
  567. tribution.  For more information on this  fascinating  secu-
  568. rity  checker,  see  kuang.man.ms  and [Baldwin 87].  I have
  569. rewritten it in Bourne shell (it was in C-Shell) for further
  570. portability.
  571.  
  572.      None of programs listed above certain cover all of  the
  573. possible  areas  that can harm a system, but if run together
  574. they can aid an overworked administrator to locate  some  of
  575. the  potential  trouble spots.  The COPS system is not meant
  576. to be a panacea against  all  UNIX  security  woes,  but  an
  577. administrator who examines the security toolbox programs and
  578. this research paper might reduce the danger  of  their  UNIX
  579. system being compromised -- and that's all any security tool
  580. can ever hope to do.  The COPS system could never replace  a
  581.  
  582.  
  583.  
  584.                      February 19, 1991
  585.  
  586.  
  587.  
  588.  
  589.  
  590.                            - 10 -
  591.  
  592.  
  593. vigilant  administration  staffed with knowledgeable people,
  594. but hopefully, as administrators look into the package, more
  595. comprehensive  programs  will come into being, covering more
  596. of the problems that will continue as the latest versions of
  597. UNIX continue to grow.
  598.  
  599.      Design Notes:
  600.  
  601.      The programs that are described here were  designed  to
  602. address the problems discussed above, but still be usable on
  603. as many UNIX "flavors" as possible.   Speed  was  sacrificed
  604. for  simplicity/portability;  hopefully  the tools here will
  605. either be replaced or modified, as by no means are they  the
  606. final  word  or solution to _any_ of these problems; indeed,
  607. it is my hope that  after  other  programmers/administrators
  608. see  this  report,  they will create newer, better, and more
  609. general tools that can be re-distributed periodically.  None
  610. of the programs need to be run by root to be effective, with
  611. the exception of the SUID checker (to ensure that all  files
  612. are  checked.) Some of the tools were written by myself, the
  613. others were written by other programmers on the network  and
  614. (with their permission) presented here.  All of the programs
  615. in this report are in the public domain, with the  exception
  616. of Robert Baldwin's U-Kuang system; they all exist solely to
  617. be used and modified to fit your needs.   If  they  are  re-
  618. distributed,  please keep them in their original form unless
  619. it is clearly stated that they were modified.  Any  improve-
  620. ments (that might not be too hard :-), suggestions, or other
  621. security programs that you would like  to  see  get  further
  622. distribution can be sent to:
  623.  
  624.      df@medusa.cs.purdue.edu
  625.  
  626.      (That's me)
  627.  
  628.      or
  629.  
  630.      spaf@uther.cs.purdue.edu
  631.  
  632.      (Dr. Eugene Spafford)
  633.  
  634.      Note that the COPS system is still in an infancy  stage
  635. --  although it has been tested on a variety of computers at
  636. Purdue, it has not undergone any serious trials.
  637.  
  638.      Enhancements I envision include:
  639.  
  640. i) Improved speed and portability without sacrificing  func-
  641. tionality (pretty obvious, I guess....)
  642.  
  643. ii) A level of severity assigned to each  warning;  anything
  644. that  could  compromise root instantly (root having no pass-
  645. word, for example) might have a level 0 priority, while sim-
  646. ply  having a user with a writable home directory might only
  647.  
  648.  
  649.  
  650.                      February 19, 1991
  651.  
  652.  
  653.  
  654.  
  655.  
  656.                            - 11 -
  657.  
  658.  
  659. be level 3.  This way the system could be run at  a  certain
  660. threshold  level, or simply have the set of warnings priori-
  661. tized for a less sophisticated administrator.
  662.  
  663. iii) Better handling of SUID programs.  The current  program
  664. needs  more  work  to be done on it to be run effectively by
  665. most people; many will not be willing to put the time needed
  666. to  go  through  the list of SUID files by hand to decide if
  667. they are needed or not.  Perhaps also an alarm  would  sound
  668. if a shell script is SUID; doubly so if root owned.
  669.  
  670. iv) A CRC checker that would check a file  system  (possibly
  671. just  the  most  important  programs  (such as this :-)) and
  672. report if any of the executable files were changed -- possi-
  673. bly signalling a viral infection.
  674.  
  675. v) The eradication of any design flaws or coding errors that
  676. are in the COPS system.
  677.  
  678.      The main purpose of creating the COPS system  was  two-
  679. fold;  the first was to foster an understanding of the secu-
  680. rity problems common to most UNIX systems,  and  the  second
  681. was  to  try  to  create and apply software tools that, when
  682. run, will inform system administrators of potential problems
  683. present in their system.  No attempt is made by the tools to
  684. correct any problems because a potential security problem at
  685. one  site  may  be  standard policy/practice at another.  An
  686. emphasis on furthering education and knowledge about UNIX in
  687. general is the key to good security practices, not following
  688. blindly what an unintelligent tool might say.
  689.  
  690.      Some of the advantages to using a system such  as  COPS
  691. are:
  692.  
  693. i)  Nearly  Continuous  monitoring  of  traditional  problem
  694. areas.
  695.  
  696. ii) A new system can be checked before being put  into  pro-
  697. duction.
  698.  
  699. iii) New or inexperienced administrators can not  only  stop
  700. some  of  their  problems in security they may have, but can
  701. also raise their consciousness about the potential for secu-
  702. rity dilemmas.
  703.  
  704.      And a couple of disadvantages:
  705.  
  706. i) An administrator could get a false sense of security from
  707. running  these  programs.  Caveat emptor (ok, they are free,
  708. but still beware.)
  709.  
  710. ii) A specific path to the elimination of the problem is not
  711. presented.   This  could  also be construed as an advantage,
  712. when considering the third point.
  713.  
  714.  
  715.  
  716.                      February 19, 1991
  717.  
  718.  
  719.  
  720.  
  721.  
  722.                            - 12 -
  723.  
  724.  
  725. iii) Badguys can get these tools.  You know -- the guys with
  726. black hats.  What happens when they get a copy of this pack-
  727. age?  With any sensitive subject like security, knowledge is
  728. zealously   guarded.    People   are  afraid  that  absolute
  729. knowledge corrupts -- who knows, they may be right.   But  I
  730. staunchly  stand by the tree of knowledge.  Let the bad guys
  731. taste the fruit, and they may see the light,  so  to  speak.
  732. In  addition,  the  system  does  not say how to exploit the
  733. hole, just that it exists.
  734.  
  735.      Results of Running COPS:
  736.  
  737.      Not surprisingly, the results when COPS was run  varied
  738. significantly  depending  on what system and site it was run
  739. on.  Here at Purdue, it was run on a Sequent  Symmetry  run-
  740. ning DYNIX 3.0.12, on a pair of Suns (a 3/280 and 3/50) run-
  741. ning UNIX 4.2 release 3.4, a  VAX  11/780  running  4.3  BSD
  742. UNIX,  a  VAX  8600  running  Ultrix 2.2, and finally a NeXT
  743. machine running their 0.9 O/S version of UNIX.  The  results
  744. of  the  COPS  system showed a reasonable amount of security
  745. concern on all of the machines; the  faculty  only  machines
  746. showed  the  weakest security, followed by the machines used
  747. by the graduate  students,  and  finally  the  undergraduate
  748. machines  had  the  strongest  security  (our administrators
  749. _know_ that  you  can't  trust  those  (us?)  young  folks.)
  750. Whether  this was showing that Purdue has a good administra-
  751. tion, or that the UNIX vendors have a fairly good  grasp  on
  752. potential  security problems, or if it was merely showcasing
  753. the shortcomings of this system wasn't clear to me from  the
  754. results.
  755.  
  756.      The security results probably will  vary  significantly
  757. from  machine  to  machine  --  this is not a fault of UNIX;
  758. merely having the same machine and software  does  not  mean
  759. that  two  sites will not have completely different security
  760. concerns.  In addition, different vendors and administrators
  761. have  significantly varying opinions on how a machine should
  762. be set up.  There is no fundamental reason  why  any  system
  763. cannot  pass  all  or nearly all of these tests, but what is
  764. standard policy at one sites may be an unthinkable  risk  at
  765. another,  depending  upon the nature of the work being done,
  766. the information stored on the computer, and the users of the
  767. system.
  768.  
  769.      When I first started researching this report, I thought
  770. it  would  be  a  fairly  easy  task.  Go to a few computing
  771. sites, read some theoretical papers, gather all the programs
  772. everyone  had written, and write a brief summary paper.  But
  773. what I found was an tremendous  lack  of  communication  and
  774. concerted  effort towards the subject of security.  AT&T had
  775. written a couple of programs ([Kaplilow and Cherepov 88], as
  776. had   Hewlett   Packard   ([Spence   89]),   but  they  were
  777. proprietary.  I heard rumors that the government was  either
  778. working on or had such a security system, but they certainly
  779.  
  780.  
  781.  
  782.                      February 19, 1991
  783.  
  784.  
  785.  
  786.  
  787.  
  788.                            - 13 -
  789.  
  790.  
  791. weren't going to give it to me.  The  one  book  devoted  to
  792. UNIX security ([Kochran and Wood 86]) was good, but the pro-
  793. grams that they presented were not expansive enough for what
  794. I  had  in  mind,  plus the fact that they had written their
  795. programs mostly based on System V.  And  while  most  system
  796. administrators  I  talked  to  had  written at least a shell
  797. script or two that performed a  minor  security  task  (SUID
  798. programs seemed the most popular), no one seemed to exchange
  799. ideas or any their problems with  other  sites  --  possibly
  800. afraid  that the admission of a weakness in their site might
  801. be an invitation to disaster.  There is an  excellent  secu-
  802. rity  discussion  group on the network ([Various Authors 84-
  803. ]), from which I received some excellent ideas for this pro-
  804. ject, but it is very restrictive to whom it allows to parti-
  805. cipate.  I hope that with the release of this security  sys-
  806. tem it will not only help stamp out problems with UNIX secu-
  807. rity, but would encourage people  to  exchange  ideas,  pro-
  808. grams,  problems  and solutions to the computer community at
  809. large.
  810.  
  811. Dan Farmer September 29, 1989
  812.  
  813.      Acknowledgements: I would like to thank Eugene Spafford
  814. for  his  invaluable  help in the researching, planning, and
  815. development of this project.  Without the writings and  pro-
  816. grams created by Robert Morris, Matt Bishop, and other capa-
  817. ble UNIX programmers, this project could never  have  gotten
  818. off  the  ground.  Thanks also go to Brian Kernighan, Dennis
  819. Ritchie, Donald Knuth, and Ken Thompson, for  such  inspira-
  820. tional  computer  work.   And of course without Peg, none of
  821. this would have come into being.  Thanks  again  to  all  of
  822. you.
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.                      February 19, 1991
  849.  
  850.  
  851.  
  852.  
  853.  
  854.                            - 14 -
  855.  
  856.  
  857.                         BIBLIOGRAPHY
  858.  
  859.  
  860. _, UNIX Programmers Manual, 4.2 Berkeley Software  Distribu-
  861. tion,  Computer  Science  Division, Department of Electrical
  862. Engineering and Computer Science University  of  California,
  863. Berkeley, CA, August 1983.
  864.  
  865. _, DYNIX(R) V3.0.12 System Manuals,  Sequent  Computer  Sys-
  866. tems, Inc., 1984.
  867.  
  868. Aho, Alfred V., Brian W. Kernighan, and Peter J. Weinberger,
  869. The AWK Programming Language, Addison-Wesley Publishing Com-
  870. pany, 1988.
  871.  
  872. Authors, Various, UNIX Security Mailing  List/Security  Dig-
  873. est, December 1984 -.
  874.  
  875. Baldwin,  Robert  W.,  Crypt  Breakers  Workbench,   Usenet,
  876. October 1986.
  877.  
  878. Baldwin, Robert W., Rule Based Analysis  of  Computer  Secu-
  879. rity, Massachusetts Institute of Technology, June 1987.
  880.  
  881. Bauer, David S. and Michael E. Koblentz, NIDX - A  Real-Time
  882. Intrusion Detection Expert System, Proceedings of the Summer
  883. 1988 USENIX Conference, Summer, 1988.
  884.  
  885. Bishop, Matt, Security Problems with the UNIX Operating Sys-
  886. tem,  Department  of  Computer  Sciences, Purdue University,
  887. January 31, 1983.
  888.  
  889. Bishop, Matt, How to Write a Setuid Program, April 18, 1985.
  890.  
  891. Denning, Dorothy, Cryptography and Data  Security,  Addison-
  892. Wesley Publishing Company, Inc, 1983.
  893.  
  894. Duff, Tom, Viral Attacks On UNIX System  Security,  Proceed-
  895. ings of the Winter 1988 USENIX Conference, Winter, 1988.
  896.  
  897. Fiedler, David and Bruce Hunter, UNIX System Administration,
  898. Hayden Book Company, 1986.
  899.  
  900. Grampp, F. T. and R. H. Morris, "UNIX Operating System Secu-
  901. rity,"  AT&T  Bell  Laboratories  Technical Journal, October
  902. 1984.
  903.  
  904. Kaplilow, Sharon A. and Mikhail Cherepov, "Quest -- A  Secu-
  905. rity  Auditing Tool," AT&T Bell Laboratories Technical Jour-
  906. nal, AT&T  Bell  Laboratories  Technical  Journal,  May/June
  907. 1988.
  908.  
  909. Morris, Robert and Ken Thompson, "Password Security : A Case
  910. History," Communications of the ACM, November 1979.
  911.  
  912.  
  913.  
  914.                      February 19, 1991
  915.  
  916.  
  917.  
  918.  
  919.  
  920.                            - 15 -
  921.  
  922.  
  923. Reed, Brian, "Reflections on Some Recent Widespread Computer
  924. Break-ins,"  Communications  of the ACM, vol. Vol 30, No. 2,
  925. February 1987.
  926.  
  927. Reed, J.A. and P.J. Weinberger, File Security and  the  UNIX
  928. System  Crypt Command, Vol 63, No. 8, AT&T Bell Laboratories
  929. Technical Journal, October 1984.
  930.  
  931. Smith, Kirk, Tales of  the  Damned,  UNIX  Review,  February
  932. 1988.
  933.  
  934. Spafford, Eugene H., The Internet Worm Program: An Analysis,
  935. Purdue Technical Report CSD-TR-823, Nov 28, 1988.
  936.  
  937. Spafford, Eugene H., 1989.  Private Communications
  938.  
  939. Bruce Spence, spy: A  UNIX  File  System  Security  Monitor,
  940. Workshop  Proceedings  of  the  Large  Installation  Systems
  941. Administration III, September, 1988.
  942.  
  943. Stoll, Clifford, Stalking the Wily Hacker, Volume 31, Number
  944. 5, Communications of the ACM, May 1988.
  945.  
  946. Thompson, Ken, Reflections on  Trusting  Trust,  Volume  27,
  947. Number 8, Communications of the ACM, August 1984.
  948.  
  949. Wood, Patrick and Stephen  Kochran,  UNIX  System  Security,
  950. Hayden Books, 1986.
  951.  
  952. Wood, Patrick, A Loss of Innocence,  UNIX  Review,  February
  953. 1988.
  954.