home *** CD-ROM | disk | FTP | other *** search
/ Hacker Chronicles 1 / HACKER1.ISO / hack / unixhak2.txt < prev    next >
Text File  |  1992-08-30  |  12KB  |  383 lines

  1.  
  2.  
  3.               On the Security of UNIX
  4.  
  5.               =-=-=-=-=-=-=-=-=-=-=-=
  6.  
  7. Recently there has been much interest in the security aspects of operating
  8.  
  9. systems and software.At issue is the ability to prevent undesired disclosure of
  10.  
  11. information, destruction of information,and harm to the functioning of the
  12.  
  13. system.This paper discusses the degree of security which can be provided under
  14.  
  15. the system and offers a number of hints on how to improve security.The first
  16.  
  17. fact to face is that UNIX was not developed with security,in any realistic
  18.  
  19. sense,in mind;this fact alone guarantees a vast number of holes.(Actually the
  20.  
  21. same statement can be made with respect to most systems.)
  22.  
  23.  
  24.  
  25. The area of security in which is theoretically weakest is in protecting against
  26.  
  27. crashing or at least crippling the operation of the system.The problem here is
  28.  
  29. not mainly in uncritical acceptance of bad parameters to system calls (there
  30.  
  31. may be bugs in this area, but none are known)but rather in lack of checks for
  32.  
  33. excessive consumption of resources.
  34.  
  35.  
  36.  
  37. Most notably, there is no limit on the amount of disk storage used, either in
  38.  
  39. total space allocated or in the number of files or directories.Here is a
  40.  
  41. particularly ghastly shell sequence guaranteed to stop the system:
  42.  
  43.  
  44.  
  45.  
  46.  
  47. while : ; do
  48.  
  49.     mkdir x
  50.  
  51.     cd x
  52.  
  53. done
  54.  
  55.  
  56.  
  57. Either a panic will occur because all the i-nodes on the device are used up,
  58.  
  59. or all the disk blocks will be consumed, thus preventing anyone from writing
  60.  
  61. files on the device.In this version of the system,users are prevented from
  62.  
  63. creating more than a set number of processes simultaneously,so unless users
  64.  
  65. are in collusion it is unlikely that any one can stop the system altogether.
  66.  
  67.  
  68.  
  69. However, creation of 20 or so CPU or disk-bound jobs leaves few resources
  70.  
  71. available for others.Also, if many large jobs are run simultaneously,swap space
  72.  
  73. may run out, causing a panic.  It should be evident that excessive consumption
  74.  
  75. of diskspace, files, swap space and processes can easily occur accidentally in
  76.  
  77. malfunctioning programs as well as at command level.In fact UNIX is essentially
  78.  
  79. defenseless against this kind of abuse,nor is there any easy fix.The best that
  80.  
  81. can be said is that it is generally fairly easy to detect what has happened
  82.  
  83. when disaster strikes ,to identify the user responsible, and take appropriate
  84.  
  85. action.In practice,we have found that difficulties in this area are rather
  86.  
  87. rare,but we have not been faced with malicious users,and enjoy a fairly
  88.  
  89. generous supply of resources which have served to cushion us against accidental
  90.  
  91. overconsumption.
  92.  
  93.  
  94.  
  95. The picture is considerably brighter in the area of protection of information
  96.  
  97. from unauthorized perusal and destruction.Here the degree of security seems
  98.  
  99. (almost) adequate theoretically, and the problems lie more in the necessity for
  100.  
  101. care in the actual use of the system.Each UNIX file has associated with it
  102.  
  103. eleven bits of protection information together with a user identification
  104.  
  105. number and a user-group identification number (UID and GID).
  106.  
  107.  
  108.  
  109. Nine of the protection bits are used to specify independently permission to
  110.  
  111. read, to write, and to execute the file to the user himself, to members of the
  112.  
  113. user's group, and to all other users.Each process generated by or for a user
  114.  
  115. has associated with it an effective UID and a real UID, and an effective and
  116.  
  117. real GID.When an attempt is made to access the file for reading, writing, or
  118.  
  119. executing UID for the process is changed to the UID associated with the file;
  120.  
  121. the change persists until the process terminates or until the UID changed again
  122.  
  123. by another execution of a set-UID file.Similarly the effective group ID of a
  124.  
  125. process is changed to the GID associated with a file when that file is executed
  126.  
  127. and has the set-GID bit set.The real UID and GID of a process do not change
  128.  
  129. when any file is executed,but only as the result of a privileged system
  130.  
  131. call.The basic notion of the set-UID and set-GID bits is that one may write a
  132.  
  133. program which is executableby others and which maintains files accessible to
  134.  
  135. others only by that program.
  136.  
  137.  
  138.  
  139. The classical example is the game-playing program which maintains records of
  140.  
  141. the scores of its players.The program itself has to read and write the score
  142.  
  143. file,but no one but the game's sponsor can be allowed unrestricted access to
  144.  
  145. the file lest they manipulate the game to their own advantage.
  146.  
  147.  
  148.  
  149. The solution is to turn on the set-UID bit of the game program.  When, and only
  150.  
  151. when,it is invoked by players of the game,it may update the score file but
  152.  
  153. ordinary programs executed by others cannot access the score.  There are a
  154.  
  155. number of special cases involved in determining access permissions.  Since
  156.  
  157. executing a directory as a program is a meaningless operation,the
  158.  
  159. execute-permission bit, for directories, is taken instead to mean permission to
  160.  
  161. search the directory for a given file during the scanning of a path name; thus
  162.  
  163. if a directory has execute permission but no read permission for a given user,
  164.  
  165. he may access files with known names in the directory,but may not read (list)
  166.  
  167. the entire contents of the directory.
  168.  
  169.  
  170.  
  171. Write permission on a directory is interpreted to mean that the user may create
  172.  
  173. and delete files in that directory;it is impossible for any user to write
  174.  
  175. directly into any directory..Another, and from the point of view of security,
  176.  
  177. much more serious special case is that there is a ``super user'' who is able to
  178.  
  179. read any file and write any non-directory.The super-user is also able to change
  180.  
  181. the protection mode and the owner UID and GID of any file and to invoke
  182.  
  183. privileged system calls.It must be recognized that the mere notion of a
  184.  
  185. super-user is a theoretical, and usually practical, blemish on any protection
  186.  
  187. scheme.
  188.  
  189.  
  190.  
  191. The first necessity for a secure system is of course arranging that all files
  192.  
  193. and directories have the proper protection modes.Traditionally, UNIX software
  194.  
  195. has been exceedingly permissive in this regard;essentially all commands create
  196.  
  197. files readable and writable by everyone.In the current version,this policy may
  198.  
  199. be easily adjusted to suit the needs ofthe installation or the individual user.
  200.  
  201.  
  202.  
  203. Associated with each process and its descendants is a mask, which is in effect
  204.  
  205. anded with the mode of every file and directory created by that process.  In
  206.  
  207. this way, users can arrange that, by default,all their files are no more
  208.  
  209. accessible than they wish.The standard mask, set by login,allows all permiss-
  210.  
  211. ions to the user himself and to his group,but disallows writing by others.
  212.  
  213.  
  214.  
  215. To maintain both data privacy and data integrity,it is necessary, and largely
  216.  
  217. sufficient,to make one's files inaccessible to others.  The lack of sufficiency
  218.  
  219. could follow from the existence of set-UID programs created by the user and the
  220.  
  221. possibility of total breach of system security in one of the ways discussed
  222.  
  223. below(or one of the ways not discussed below).
  224.  
  225.  
  226.  
  227. For greater protection,an encryption scheme is available.Since the editor is
  228.  
  229. able to create encrypted documents, and the crypt command can be used to pipe
  230.  
  231. such documents into the other text-processing programs,the length of time
  232.  
  233. during which clear text versions need be available is strictly limited.The
  234.  
  235. encryption scheme used is not one of the strongest known, but it is judged
  236.  
  237. adequate, in the sense that cryptanalysisis likely to require considerably more
  238.  
  239. effort than more direct methods of reading the encrypted files.For example, a
  240.  
  241. user who stores data that he regards as truly secret should be aware that he is
  242.  
  243. implicitly trusting the system administrator not to install a version of the
  244.  
  245. crypt command that stores every typed password in a file.  Needless to say, the
  246.  
  247. system administrators must be at least as careful as their most demanding user
  248.  
  249. to place the correct protection mode on the files under their control.
  250.  
  251.  
  252.  
  253. In particular,it is necessary that special files be protected from writing, and
  254.  
  255. probably reading, by ordinary users when they store sensitive files belonging
  256.  
  257. to otherusers.It is easy to write programs that examine and change files by
  258.  
  259. accessing the device on which the files live.
  260.  
  261.  
  262.  
  263. On the issue of password security,UNIX is probably better than most systems.
  264.  
  265. Passwords are stored in an encrypted form which, in the absence of serious
  266.  
  267. attention from specialists in the field,appears reasonably secure, provided its
  268.  
  269. limitations are understood.In the current version, it is based on a slightl y
  270.  
  271. defective version of the Federal DES;it is purposely defective so that
  272.  
  273. easily-available hardware is useless for attempts at exhaustive
  274.  
  275. key-search.Since both the encryption algorithm and the encrypted passwords are
  276.  
  277. available,exhaustive enumeration of potential passwords is still feasible up to
  278.  
  279. a point.We have observed that users choose passwords that are easy to
  280.  
  281. guess:they are short, or from a limited alphabet, or in a dictionary.
  282.  
  283. Passwords should be at least six characters long and randomly chosen from an
  284.  
  285. alphabet which includes digits and special characters.
  286.  
  287.  
  288.  
  289. Of course there also exist feasible non-cryptanalytic ways of finding out
  290.  
  291. passwords.For example:    write a program which types out ``login:''on the
  292.  
  293. typewriter and copies whatever is typed to a file of your own.    Then invoke the
  294.  
  295. command and go away until the victim arrives..The set-UID (set-GID)notion must
  296.  
  297. be used carefully if any security is to be maintained.    The first thing to keep
  298.  
  299. in mind is that a writable set-UID file can have another program copied onto
  300.  
  301. it.
  302.  
  303.  
  304.  
  305. For example, if the super-user command is writable,anyone can copy the shell
  306.  
  307. onto it and get a password-free version of Shell Unix.A more subtle problem can
  308.  
  309. come from set-UID programs which are not sufficiently careful of what is fed
  310.  
  311. into them.To take an obsolete example,the previous version of the mail command
  312.  
  313. was set-UID and owned by the super-user.This version sent mail to the r
  314.  
  315. ecipient's own directory.The notion was that one should be able to send mail to
  316.  
  317. anyone even if they want to protecttheir directories from writing.  The trouble
  318.  
  319. was that mailwas rather dumb:anyone could mail someone else's priva te file to
  320.  
  321. himself.Much more seriousis the following scenario:  make a file with a line
  322.  
  323. like one in the password filewhich allows one to log in as the super-user.Then
  324.  
  325. make a link named ``.mail'' to the password file in some writable directory on
  326.  
  327. the same device as the password file (say /tmp).  Finally mail the bogus login
  328.  
  329. line to /tmp/.mail;You can then login as the superuser,clean up the
  330.  
  331. incriminating evidence,and have your will.
  332.  
  333.  
  334.  
  335. The fact that users can mount their own disks and tapes as file systems can be
  336.  
  337. another way of gaining super-user status.Once a disk pack is mounted, the
  338.  
  339. system believes what is on it.Thus one can take a blank disk pack,put on it
  340.  
  341. anything desired,and mount it.There are obvious and unfortunate consequences.
  342.  
  343. For example:a mounted disk with garbage on it will crash the system;one of the
  344.  
  345. files on the mounted disk can easily be a password-free version of Shell Unix;
  346.  
  347. other files can be unprotected entries for special files.  The only easy fix
  348.  
  349. for this problem is to forbid the use of mount to unpriv- ileged users.A
  350.  
  351. partial solution, not so restrictive,would be to have the mount command examine
  352.  
  353. the special file for bad data,set-UID programs owned by others ,and accessible
  354.  
  355. special files,and balk at unprivileged invokers.
  356.  
  357.  
  358.  
  359. Removed from Berkely Unix System by the Terminal Technician with glee....
  360.  
  361. --------------------------------------------------------------------------
  362.  
  363.    This file passed through the DEAD ZONE.  It is a phun place, and you
  364.  
  365. really should call it @ (303) 468-8069.  300/1200/2400, 24 hours, 7 days.
  366.  
  367.  
  368.  
  369. A RING-BACK system:
  370.  
  371.           Call Once, let ring 1-2 times, HANG UP.
  372.  
  373.           Call back 20-45 seconds later and the system will answer.
  374.  
  375.  
  376.  
  377.     There is no way to connect on the first call, so don't let it ring a
  378.  
  379.     bunch of times or you'll get an answering machine.
  380.  
  381. Downloaded From P-80 Systems 304-744-2253
  382.  
  383.