home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / library / articles / holelist.txt < prev    next >
Text File  |  1998-03-25  |  16KB  |  386 lines

  1.  
  2. ( Please contribute by sending E-Mail to <scott@santafe.edu> ... )
  3.  
  4. [quoting from the comp.security.unix FAQ]
  5. Security holes manifest themselves in (broadly) four ways:
  6.  
  7. 1) Physical Security Holes.
  8.  
  9. - Where the potential problem is caused by giving unauthorised persons
  10. physical access to the machine, where this might allow them to perform
  11. things that they shouldn't be able to do.
  12.  
  13. A good example of this would be a public workstation room where it would
  14. be trivial for a user to reboot a machine into single-user mode and muck
  15. around with the workstation filestore, if precautions are not taken.
  16.  
  17. Another example of this is the need to restrict access to confidential
  18. backup tapes, which may (otherwise) be read by any user with access to
  19. the tapes and a tape drive, whether they are meant to have permission or
  20. not.
  21.  
  22. 2) Software Security Holes
  23.  
  24. - Where the problem is caused by badly written items of "privledged"
  25. software (daemons, cronjobs) which can be compromised into doing things
  26. which they shouldn't oughta.
  27.  
  28. The most famous example of this is the "sendmail debug" hole (see
  29. bibliography) which would enable a cracker to bootstrap a "root" shell.
  30. This could be used to delete your filestore, create a new account, copy
  31. your password file, anything.
  32.  
  33. (Contrary to popular opinion, crack attacks via sendmail were not just
  34. restricted to the infamous "Internet Worm" - any cracker could do this
  35. by using "telnet" to port 25 on the target machine.  The story behind a
  36. similar hole (this time in the EMACS "move-mail" software) is described
  37. in [Stoll].)
  38.  
  39. New holes like this appear all the time, and your best hopes are to:
  40.  
  41.   a: try to structure your system so that as little software as possible
  42.   runs with root/daemon/bin privileges, and that which does is known to
  43.   be robust.
  44.  
  45.   b: subscribe to a mailing list which can get details of problems
  46.   and/or fixes out to you as quickly as possible, and then ACT when you
  47.   receive information.
  48.  
  49. >From: Wes Morgan <morgan@edu.uky.ms>
  50. >
  51. > c: When installing/upgrading a given system, try to install/enable only
  52. > those software packages for which you have an immediate or foreseeable
  53. > need.  Many packages include daemons or utilities which can reveal
  54. > information to outsiders.  For instance, AT&T System V Unix' accounting
  55. > package includes acctcom(1), which will (by default) allow any user to
  56. > review the daily accounting data for any other user.  Many TCP/IP packa-
  57. > ges automatically install/run programs such as rwhod, fingerd, and
  58. > <occasionally> tftpd, all of which can present security problems.
  59. >
  60. > Careful system administration is the solution.  Most of these programs
  61. > are initialized/started at boot time; you may wish to modify your boot
  62. > scripts (usually in the /etc, /etc/rc, /etc/rcX.d directories) to pre-
  63. > vent their execution.  You may wish to remove some utilities completely.
  64. > For some utilities, a simple chmod(1) can prevent access from unauthorized
  65. > users.
  66. >
  67. > In summary, DON'T TRUST INSTALLATION SCRIPTS/PROGRAMS!  Such facilities
  68. > tend to install/run everything in the package without asking you.  Most
  69. > installation documentation includes lists of "the programs included in
  70. > this package"; be sure to review it.
  71.  
  72. 3) Incompatible Usage Security Holes
  73.  
  74. - Where, through lack of experience, or no fault of his/her own, the
  75. System Manager assembles a combination of hardware and software which
  76. when used as a system is seriously flawed from a security point of view.
  77. It is the incompatibility of trying to do two unconnected but useful
  78. things which creates the security hole.
  79.  
  80. Problems like this are a pain to find once a system is set up and
  81. running, so it is better to build your system with them in mind.  It's
  82. never too late to have a rethink, though.
  83.  
  84. Some examples are detailed below; let's not go into them here, it would
  85. only spoil the surprise.
  86.  
  87. 4) Choosing a suitable security philosophy and maintaining it.
  88.  
  89. >From: Gene Spafford <spaf@cs.purdue.edu>
  90. >The fourth kind of security problem is one of perception and
  91. >understanding.  Perfect software, protected hardware, and compatible
  92. >components don't work unless you have selected an appropriate security
  93. >policy and turned on the parts of your system that enforce it.  Having
  94. >the best password mechanism in the world is worthless if your users
  95. >think that their login name backwards is a good password! Security is
  96. >relative to a policy (or set of policies) and the operation of a system
  97. >in conformance with that policy.
  98.  
  99. ---
  100.  
  101. From: Hacking
  102. Subject: Hacking Ideas
  103. Date: 11/10/93
  104.  
  105. ( Please contribute by sending E-Mail to <scott@santafe.edu> ... )
  106.  
  107. [ Many ideas taken from: HaxNet - APG V1.3 : Guide to finding new holes]
  108.  
  109. NOTE: I think this should be divided into general categories:
  110. 1) General principles
  111. 2) Looking for holes in src (most items here)
  112. 3) Looking in binary distributions
  113. 4) Looking in site specific configurations
  114.  
  115.   The following general classifications suggest themselves:
  116. 1) SUID/SGID
  117. 2) Return codes/error conditions
  118. 3) unexpected input
  119. 4) race conditions
  120. 5) authentication
  121. 6) implicit trust
  122. 7) parameters
  123. 8) permissions
  124. 9) interrupts
  125. 10) I/O
  126. 11) symbolic links
  127. 12) Daemons, particularly those taking user input.
  128. 13) Kernel race conditions
  129. 14) what else? - please add categories
  130.  
  131. (Suggested splitting of above into main and sub-catagories)
  132. I:   Suid binaries and scripts
  133.      unexpected user interactions
  134.      flawed liberary calls
  135.      implicit assumptions of external conditions (sym links, loc. paths)
  136.      race conditions
  137. II:  daemons running with priviliged uid's
  138.      race conditions
  139.      poor file protectons
  140.      implicit file protections
  141.      trust
  142.      authentication
  143. III: Kernel problems
  144.      Kernel race conditions
  145.      device driver code
  146.  
  147. The following four step method was created by System Development
  148. Corporation, who report a 65% success rate on the flaw hypotheses
  149. generated.  Doing a comprehensive search for operating system flaws
  150. requires four steps:
  151.  
  152. Step 1) Knowledge of system control structure.
  153. ===============================================
  154.   To find security holes, and identifying design weaknesses it is
  155. necessary to understand the system control structure, and layers.
  156.   One should be able to list the:
  157. A) security objects: items to be protected. ie: a users file.
  158. B) control objects: items that protect security objects. ie: a i-node
  159. C) mutual objects  : objects in both classes. ie: the password file
  160.   With such a list, it is possible to graphically represent a control
  161. hierarchy and identify potential points of attack. Making flow charts
  162. to give a visual breakdown of relationships definitely helps.
  163.   Reading the various users, operators, and administrators manuals should
  164. provide this information.
  165. (following para's should probably be moved to a "legal" section)
  166.   Reading and greping source code should also prove valuable. For those
  167. without a source licence, I would suggest we use LINUX, NET2, and BSD386
  168. distributions in order to stay legal. At some future time we may be able
  169. to form a working contract between someone or a company with legal access
  170. to other distributions and members actively participating in this project.
  171.   It appears that extracts of proprietary code may be used for academic
  172. study, so long as they are not reused in a commercial product - more
  173. checking is necessary though.
  174.  
  175. Step 2) Generate an inventory of suspected flaws. (i.e. flaw hypotheses)
  176. ========================================================================
  177. In particular we want:
  178.   Code history:
  179.     What UNIX src does a particular flavor derive from? This is important
  180. for cross references (very often only one vendor patches certain code,
  181. which may get reused, in it's unpatched reincarnation by others)
  182.   A solid cross reference:
  183.     Who checked which bug in what OS and what version prevents us from
  184. duplicating work.
  185.  
  186.   A good start would be listing all the suid binaries on the various OS
  187. flavors/versions. Then try to work out why each program is suid. i.e.:
  188.     rcp is suid root because it must use a privilaged port to do user
  189.     name authentication.
  190.   Often code that was never designed to be suid, is made suid, durring
  191. porting to solve file access problems.
  192.   We need to develope a data base that will be able to look at pairs and
  193. triplets of data, specificly: program name, suid, sgid, object accessed
  194. (why prog is suid/sgid), OS flavor/version, and flav/vers geniology.
  195.   Any sugestions on how to implement such a DB?
  196.  
  197. Step 3) Confirm hypotheses. (test and exploit flaws)
  198. ====================================================
  199.  
  200. Step 4) Make generalizations of the underlying system weaknesses, for
  201.         which the flaw represents a specific instance.
  202. =====================================================================
  203.  
  204. Tool Box:
  205. =========
  206. AGREP: I suggest everyone obtain, and install agrep from:
  207.     ftp cs.arizona.edu /agrep/agrep.tar.Z
  208.   Agrep supports "windowing" so it can look for routines, and subroutines.
  209. It also supports logical operators and is thus ideally suited to automating
  210. the search for many of the following flaws. i.e. <psudocode>
  211.       agrep WINDOW {suid() NOT taintperl()} /usr/local/*.pl
  212. or    agrep WINDOW {[suid() OR sgid()] AND [system() OR popen() OR execlp()
  213.             OR execvp()]} /usr/local/src/*.c
  214.  
  215. PERMUTATION PROGRAM: Another tool worth producing is a program to generate
  216. all possible permutations of command line flags/arguments in order to uncover
  217. undocumented features, and try to produce errors.
  218.  
  219. TCOV:
  220.  
  221. CRASH: Posted to USENET (what FTP archive?) (descrip?)
  222.  
  223. PAPERS: There are several papers that discuss methods of finding flaws, and
  224.   present test suites.
  225.   1) An Emphirical Study of the reliability of UNIX Utilities, by Barton P.
  226.     Miller, Lars Fredriksen, and Bryan So, Comm ACM, v33 n12, pp32-44,
  227.     Dec '90. Describes a test suite for testing random input strings.
  228.     Results indicated that 25% of the programs hung, crashed, or misbehaved.
  229.     In one case the OS crashed. An understanding of buffer and register
  230.     layout on the environment in question, and the expected input is likely
  231.     to produce the desired results.
  232.   2) The Mothra tools set, in Proceedings of the 22nd Hawaii International
  233.     Conference on Systems and Software, pages 275-284, Kona, HI, January '89
  234.   3) Extending Mutation Testing to Find Environmental Bugs, by Eugene H.
  235.     Spafford, Software Practice and Experience, 20(2):181-189, Feb '90
  236.   4) A paper by IBM was mentioned that was submitted to USENIX a few years
  237.     ago. (Anyone have a citation?).
  238.  
  239. Specific Flaws to Check For:
  240. ============================
  241. 1) Look for routines that don't do boundary checking, or verify input.
  242.    ie: the gets() family of routines, where it is possible to overwrite
  243.    buffer boundaries. ( sprintf()?, gets(), etc. )
  244.    also: strcpy() which is why most src has:
  245.      #define SCYPYN((a)(b)) strcpy(a, b, sizeof(a))
  246.  
  247. 2) SUID/SGID routines written in one of the shells, instead of C or
  248.    PERL.
  249.  
  250. 3) SUID/SGID routines written in PERL that don't use the "taintperl"
  251.    program.)
  252.  
  253. 4) SUID/SGID routines that use the system(), popen(), execlp(), or
  254.    execvp() calls to run something else.
  255.  
  256. 5) Any program that uses relative path names inside the program.
  257.  
  258. 6) The use of relative path names to specify dynamically linked libraries.
  259.    (look in Makefile).
  260.  
  261. 7) Routines that don't check error return codes from system calls. (ie:
  262.    fork(2), suid(2), etc), setuid() rather, as in the famous rcp bug
  263.  
  264. 8) Holes can often be found in code that:
  265.   A) is ported to a new environment.
  266.   B) receives unexpected input.
  267.   C) interacts with other local software.
  268.   D) accesses system files like passwd, L.sys, etc.
  269.   E) reads input from a publicly writable file/directory.
  270.   F) diagnostic programs which are typically not user-proofed.
  271.  
  272. 9) Test code for unexpected input. Coverage, data flow, and mutation
  273.    testing tools are available.
  274.  
  275. 10) Look in man pages, and users guides for warnings against doing X, and
  276.    try variations of X. Ditto for "bugs" section.
  277.  
  278. 11) Look for seldom used, or unusual functions or commands - read backwards.
  279.    In particular looking for undocumented flags/arguments may prove useful.
  280.    Check flags that were in prior releases, or in other OS versions. Check
  281.    for options that other programs might use. For instance telnet uses -h
  282.    option to login ...
  283.      right, as most login.c's I've seen have:
  284.           if((getuid()) && hflag){
  285.                  syslog()
  286.                  exit()
  287.                  }
  288.  
  289. 12) Look for race conditions.
  290.  
  291. 13) Failure of software to authenticate that it is really communicating
  292.    with the desired software or hardware module it wants to be accessing.
  293.  
  294. 14) Lack or error detection to reset protection mechanisms following an
  295.    error.
  296.  
  297. 15) Poor implementation resulting in, for example, condition codes being
  298.    improperly tested.
  299.  
  300. 16) Implicit trust: Routine B assumes routine A's parameters are correct
  301.    because routine A is a system process.
  302.  
  303. 17) System stores it's data or references user parameters in the users
  304.    address space.
  305.  
  306. 18) Inter process communication: return conditions (passwd OK, illegal
  307.    parameter, segment error, etc) can provide a significant wedge, esp.
  308.    when combined with (17).
  309.  
  310. 19) User parameters may not be adequately checked.
  311.  
  312. 20) Addresses that overlap or refer to system areas.
  313.  
  314. 21) Condition code checks may be omitted.
  315.  
  316. 22) Failure to anticipate unusual or extraordinary parameters.
  317.  
  318. 23) Look for system levels where the modules involved were written by
  319.    different programmers, or groups of programmers - holes are likely
  320.    to be found.
  321.  
  322. 24) Registers that point to the location of a parameters value instead
  323.    of passing the value itself.
  324.  
  325. 25) Any program running with system privileges. (too many progs are given
  326.    uid 0, to facilitate access to certain tables, etc.)
  327.  
  328. 26) Group or world readable temporary files, buffers, etc.
  329.  
  330. 27) Lack of threshold values, and lack of logging/notification once these
  331.    have been triggered.
  332.  
  333. 28) Changing parameters of critical system areas prior to their execution
  334.    by a concurrent process. (race conditions)
  335.  
  336. 29) Inadequate boundary checking at compile time, for example, a user
  337.    may be able to execute machine code disguised as data in a data area.
  338.    (if text and data areas are shared)
  339.  
  340. 30) Improperly handling user generated asynchronous interrupts. Users
  341.    interrupting a process, performing an operation, and either returning
  342.    to continue the process or begin another will frequently leave the
  343.    system in an unprotected state. Partially written files are left open,
  344.    improper writing of protection infraction messages, improper setting
  345.    of protection bits, etc often occur.
  346.  
  347. 31) Code that uses fopen(3) without setting the umask. ( eg: at(1), etc. )
  348.   In general, code that does not reset the real and effective uid before
  349.   forking.
  350.  
  351. 32) Trace is your friend (or truss in SVR4) for helping figure out what
  352.   system calls a program is using.
  353.  
  354. 33) Scan /usr/local fs's closely. Many admins will install software from
  355.   the net. Often you'll find tcpdump, top, nfswatch, ... suid'd root for
  356.   their ease of use.
  357.  
  358. 34) Check suid programs to see if they are the ones originally put on the
  359.   system. Admins will sometimes put in a passwd replacement which is less
  360.   secure than the distributed version.
  361.  
  362. 35) Look for programs that were there to install software or loadable
  363.   kernel modules.
  364.  
  365. 36) Dynamically linked programs in general. Remember LD_PRELOAD, I think
  366.   that was the variable.
  367.  
  368. 37) I/O channel programming is a prime target. Look for logical errors,
  369.   inconsistencies, and omissions.
  370.  
  371. 38) See if it's possible for a I/O channel program to modify itself, loop
  372.   back, and then execute the newly modified code. (instruction pre-load
  373.   may screw this up)
  374.  
  375. 39) If I/O channels act as independent processors they may have unlimited
  376.   access to memory, thus system code may be modified in memory prior to
  377.   execution.
  378.  
  379. 40) Look for bugs requiring flaws in multiple pieces of software, i.e. say
  380.   program a can be used to change config file /etc/a now program b assumes
  381.   the information in a to be correct and this leads to unexpected results
  382.   (just look at how many programs trust /etc/utmp)
  383.  
  384. 41) Any program, especially those suid/sgid, that allow shell escapes.
  385.  
  386.