home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / docs / kuang.man < prev    next >
Text File  |  1992-03-10  |  37KB  |  848 lines

  1. .ps 12
  2. .vs 12
  3. .PH ````
  4. .nr W 80
  5. .in 0
  6. .ce 3
  7. \fBKuang: Rule-Based Security Checking\fP
  8. Robert W. Baldwin
  9. MIT, Lab for Computer Science Programming Systems Research Group
  10.  
  11. .PP
  12. The security of data in a particular computer depends both on the
  13. integrity of the computer's protection mechanism and on the consistent
  14. uses of those mechanisms by the users of that computer.  Software
  15. verification and specification technology addresses the integrity
  16. problem, but very little has been done to insure that the protection
  17. mechanisms are being used consistently.  This paper describes a
  18. rule-based system that finds inconsistencies in the set of protection
  19. decisions made by the users of an information system.
  20.  
  21. .PP
  22. \fBIntroduction\fP
  23. .PP
  24. The trend in commercial computer systems has been to increase the the
  25. number of mechanisms that allow users to execute commands and to
  26. increase the number of mechanisms that allow users to share
  27. information.  All of these mechanisms must be considered to be part of
  28. the protection system.  For example, if users can specify a set of
  29. commands that will be executed automatically every night, then the
  30. database that contains these commands, and the program that processes
  31. the database must be considered part of the protection system.  Even
  32. if the program has been certified to work correctly, the access list
  33. for the command database and the set of privileges available to the
  34. processing program must be considered to be part of the protection
  35. configuration \**
  36. .FS
  37. The protection configuration is a subset of the
  38. access matrix.  The access matrix specifies how each user can access
  39. each object.  I use the term
  40. .ul
  41. protection configuration
  42. to refer to the portion of the access matrix concerning the objects 
  43. used by any piece of the protection system.
  44. .FE
  45. of that computer.  The problem
  46. considered in this paper is ensuring that the protection configuration
  47. is consistent with the user's security goals.
  48. .PP
  49. The goal of flexible information processing and sharing makes
  50. computers more useful, but that goal also makes protection systems
  51. larger and more complex.  The large number of interactions between the
  52. pieces of the protection system makes it hard for the users to make
  53. protection decisions correctly.  This is particularly true when parts
  54. of an information system are managed by novices (e.g., personal work
  55. stations).  Users need automated tools for analyzing the interactions
  56. between the pieces of a large protection system.
  57. .PP
  58. This paper describes a class of systems, called Kuang-type \**
  59. .FS
  60. This
  61. project was inspired by William Gibson's book
  62. .ul
  63. Neuromancer
  64. , which won the 1984 Nebula award for best science fiction novel.
  65. Gibson's book describes innovative ways to visualize the structure of
  66. information systems.  In particular, it describes a program called a
  67. Kuang Grade Mark 11 Ice Breaker (
  68. .ul
  69. ice
  70. refers to the mechanisms used
  71. to protect access to information).  The program described in this memo
  72. is a greatly simplified version of that ice breaker program.
  73. .FE
  74. systems, for analyzing large protection configurations.  
  75. This class of systems is illustrated by a Simple Unix Kuang program
  76. (SU-Kuang) that answers a question about a Unix protection
  77. configuration.  The question is "what if an attacker had access to a
  78. given set of privileges (groups), could that attacker become
  79. super-user?".  SU-Kuang allows a system manager to perform a simple
  80. what-if analysis of a protection configuration, and in this mode it
  81. helps the manager make protection decisions.  A typical use of SU-Kuang
  82. is to run it periodically to see if access to the group, World, (i.e.,
  83. minimum privileges) is sufficient to become super-user.  In this mode
  84. Kuang functions as an automatic security checker.  SU-Kuang is just one
  85. possible tool for helping users cope with the complexity of a large
  86. protection system.  Some other desirable tools are mentioned at the
  87. end of this paper.
  88. .PP
  89. The heart of the SU-Kuang program is a set of rules that describe the
  90. Unix (BSD4.2) protection system from the point of view of an
  91. attacker.  For example, one rule says that if an attacker can write
  92. the file /etc/passwd (the authentication database), then that attacker
  93. can become super-user.  To decide whether to use this rule, an
  94. attacker would examine the protection configuration of the target
  95. machine to see what privileges are required to write the file
  96. /etc/passwd.  Using similar rules, SU-Kuang can answers the what-if
  97. question by performing a backward chaining search of the protection
  98. configuration (see figure
  99. .ul
  100. goal-tree
  101. ).  Given a goal, like become
  102. super-user, SU-Kuang examines all the rules to produce a list of
  103. subgoals that would be sufficient to meet its goal.  Recursively, each
  104. of the subgoals can be processed to produce a list of sub-subgoals.
  105. The process continues until there are no new goals.  At each step, if
  106. a goal can be achieved using the initial privileges of the attacker,
  107. SU-Kuang prints out a message that describes the sequence of steps
  108. that leads from the initial goals to the target goal.
  109. .sp
  110. .sp
  111. .nf
  112.              Become Super-User
  113.              /                     \\
  114.             /                       \\
  115.    Replace /etc/passwd      Write /.rhosts
  116.         /        \\                      .
  117.        /          \\                    . .
  118.  Become Staff   Write /etc
  119.      .                                   .
  120.     . .                                 . .
  121.    .   .                               .   .
  122.  
  123.  
  124. .fi
  125. (Example of a goal-tree used by SU-Kuang.  The nodes of the tree
  126. are goals desired by an attacker.
  127. The children of each node are the subgoals that are sufficient to
  128. achieve the parent goal.  The goal-tree used by SU-Kuang is a pure
  129. OR-tree.  Any one of the subgoals is sufficient to grant the parent goal.)
  130.  
  131. .PP
  132. Notice that SU-Kuang does not find holes in the Unix operating system.
  133. It finds mistakes in the protection configuration.  For example,
  134. SU-Kuang found a security hole on an MIT machine that resulted from
  135. two incorrect decisions about who should have write access to start-up
  136. command files.  SU-Kuang points out holes by describing the sequence
  137. of steps used to exploit the hole.  The sequence SU-Kuang printed was:
  138. "member MIT, write ~tom/.cshrc, member A_STAFF, write ~dick/.login,
  139. member STAFF, write /etc, replace /etc/passwd, become ROOT".  This
  140. means that the attacker had access to the group MIT, which all users
  141. are in.  The MIT group had write access to one of the start-up command
  142. files executed automatically when the user Tom (not his real
  143. name) logged in.  Anyone in the MIT group could add commands to Tom's
  144. start-up command file, and have these commands executed with Tom's
  145. privileges next time Tom logged into the machine.  Tom is a member of
  146. the Athena Staff group, which is not particularly privileged.  However,
  147. the A_STAFF group does have write access to one of Dick's start-up
  148. command files, and Dick is a member of the Staff group, which is one
  149. of the most privileged groups.  In fact, members of the staff group
  150. can write the directory that contains the password database.  Write
  151. access to the directory allows staff members to delete and recreate
  152. the password database.  By creating a password database that has a
  153. known password for the super-user account, members of the staff group
  154. can acquire super-user privileges.
  155. .PP
  156. My experience running SU-Kuang is that these mistakes are created
  157. periodically because the users do not understand the interactions
  158. between the numerous pieces of the Unix protection system.  However,
  159. it is not complicated to write a program that can explore all the
  160. possible interactions.  SU-Kuang itself is a simple program, and
  161. generating the rules that describe the pieces of the protection system
  162. is also easy (see section
  163. .ul
  164. rules
  165. ).  The simplifying idea is to
  166. describe the protection system in terms of how an attacker can
  167. manipulate it.  Using this framework, performing the analysis is easy.
  168. .PP
  169. I consider any system that uses attacker-oriented rules to be a
  170. Kuang-type system.  The remainder of this paper describes the Unix
  171. Kuang system I built to determine whether a given set of privileges is
  172. sufficient to become super-user.  The nature of the rules and the
  173. process used to deduce them is illustrated in section
  174. .ul
  175. rules
  176. , which lists the set of rules used to model Unix.  The model used by
  177. SU-Kuang was incomplete in several ways, so section
  178. .ul
  179. extensions
  180. describes some of the features of Unix that were not
  181. modeled.  The incomplete model turned out to be very effective at
  182. finding security holes, so section
  183. .ul
  184. experience
  185. presents the
  186. lessons learned from running SU-Kuang on the computers at MIT.  The last
  187. section discusses other kinds of Kuang systems and their benefits.
  188. .PP
  189. \fBRules to model Unix\fP
  190. .PP
  191. The first step in generating attacker-oriented rules is to determine
  192. the types of goals that are relevant to an attacker of the target
  193. system.  These goal types can be deduced from the basic protection
  194. model of the operating system, so before presenting the rules, the
  195. Unix protection model is summarized.  The second step is to make a
  196. list of the pieces of the protection system and to examine each one in
  197. terms of the goals an attacker could achieve using each piece.
  198. The pieces of the Unix protection system that were included in the
  199. prototype's model are listed below along with the rules used to
  200. describe each piece.
  201. .PP
  202. \fBSummary of the Unix protection model\fP
  203. .PP
  204. The Unix protection model concerns processes and files.  Associated
  205. with each process is one user identifier UID, and one or more group
  206. identifiers (GIDs).  The UID and GIDs are generally inherited when one
  207. process forks another.  One exception is that the super-user (UID =
  208. 0) can change the UID and GIDs of his current process.  The other
  209. exception is that a user can associate a UID and GID with a program
  210. stored in the file system.  When anyone runs such a program, the
  211. process executing that program will run with the stored user and/or
  212. group IDs.
  213. .PP
  214. Associated with each file is one UID, one GID, and nine permission
  215. bits.  The nine permission bits are divided into three groups to
  216. specify the read, write, and execute rights for the file's owner
  217. (specified by the UID), for the members of the file's group (specified
  218. by the GID), and for all others (the World group).  Directories are a
  219. special case of files.  For a directory, read permission allows a
  220. process to list a directory, write permission allows a process to
  221. create or delete files in that directory, and execute permission
  222. allows a process to resolve names in that directory even if the
  223. directory is unreadable.
  224. .PP
  225. When a process accesses a file or directory it is given either owner,
  226. group, or world access permissions, but only one of those three.
  227. Owner access is granted if the process and file UIDs match; Group
  228. access is granted if the process and file UIDs are different but the
  229. file's GID is in the list of GIDs for the process; otherwise, World
  230. access is granted.  The super-user has full access to all files and
  231. directories.  Only the owner or the super-user can change the access
  232. permissions of a file.
  233. .PP
  234. \fBThree types of attacker goals\fP
  235. .PP
  236. The Unix protection model deals with users, groups, and files, so
  237. those are the three types of goals that will concern an attacker.  The
  238. canonical user goal is "execute one of the attacker's programs with a
  239. particular UID".  For example, the top level goal is "execute a
  240. program chosen by the attacker under UID zero (i.e., as
  241. super-user)".  It is important that the attacker be able to specify
  242. the program to be executed with super-user privileges.  The login
  243. program runs as super-user, and anyone can run it.  The attacker wants
  244. to specify the computation performed with super-user privileges.  One
  245. scheme for getting access to super-user privileges is to write the
  246. command file that is executed automatically when the super-user logs
  247. in.
  248. .PP
  249. Group ID goals are similar.  The canonical form of a GID goal is
  250. "execute an arbitrary program with a particular group ID".  One
  251. possible way to achieve this goal is to add the attacker's UID to the
  252. list of users allowed to access the desired group.  This authorization
  253. database is stored in the file /etc/group.
  254. .PP
  255. The canonical file goal is "obtain read/write/replace access to a particular
  256. file".  Achieving a file goal usually involves getting access to a
  257. particular group or user ID.  However, if the attacker wants to replace
  258. a file, one way to do that is to delete the old file and create a new
  259. one.  That can be done if the attacker has write or replace access to
  260. the directory that contains the target file.
  261. .PP
  262. In summary, SU-Kuang considers three types of goals for an attacker of
  263. Unix: user, group, and file.  Each type of goal can lead to subgoals
  264. of the same or different type.
  265. .PP
  266. \fBSome pieces of the Unix protection system\fP
  267. .PP
  268. This section presents the rules that describe many of the pieces of the
  269. Unix protection system.  Section
  270. .ul
  271. extensions
  272. describes the
  273. significant pieces that were left out of the prototype's model.  The
  274. pieces of the Unix protection system include all programs, like 
  275. .ul
  276. login,
  277. that have the set user/group ID property.  It also  includes programs
  278. like 
  279. .ul
  280. cron
  281. (cron executes commands in the future) that
  282. are forked off by processes that run with special user or group IDs.
  283. Finally, programs like 
  284. .ul
  285. sh
  286. (a command interpreter) must be included
  287. in the protection system because when they are started they execute
  288. commands from a file using the privileges of the user invoking them.
  289. .PP
  290. Each rule describes how a piece of the protection system can be
  291. used by an attacker to achieve a desired goal in terms of the ability
  292. to achieve a subgoal.  The method used to achieve a goal given the
  293. subgoal may require that some condition be true.  For that reason the
  294. rules include a condition that can be tested to decide if the subgoal
  295. should be pursued.  The conditions are general predicates on the state
  296. of the protection configuration.  For example, the rule that says that
  297. an attacker can become the super-user by writing the password file,
  298. has the condition that the password file is writable by someone other
  299. than the super-user.
  300. .PP
  301. In the rules listed below, the notation \*Q/d/f\*U means a
  302. pathname for the file \*Qf\*U in the directory with pathname \*Q/d\*U.
  303. The goal, \*Qbecome U\*U, means to execute an arbitrary command under the
  304. user ID \*QU\*U.  The goal, \*Qmember G\*U, means the same thing for
  305. group \*QG\*U.  The goal, \*Qwrite /d/f\*U, means being able to write the
  306. file \*Q/d/f\*U.  Finally, \*Qreplace /d/f\*U, means being able to write
  307. \*Q/d/f\*U or being able to delete \*Q/d/f\*U and recreate it.
  308. .PP
  309. \fBThe file system\fP
  310. .PP
  311. Most programs in the protection system use the file hierarchy to
  312. locate their databases.  If the file hierarchy can be modified, then
  313. the protection system can be tricked into using the wrong database
  314. files.  The file hierarchy itself must be treated as one of the
  315. main databases in the protection configuration.
  316. .PP
  317. The notation \*QOwner(/d/f)\*U refers to the UID associated with the
  318. file \*Q/d/f\*U.  Similarly \*QGroup(/d/f)\*U refers to the file's GID.
  319. The expression \*QGroupWrite(/d/f)\*U is true if the file \*Q/d/f\*U can
  320. be written by the members of \*QGroup(/d/f)\*U.  The expression
  321. \*QWorldWrite(/d/f)\*U is true if the file can be written by members of
  322. the World group (i.e., all users).
  323. .sp
  324. Rules{
  325. .sp
  326. .ul
  327. <Goal/Condition/Subgoal/Note>
  328. .PP
  329. Replace /d/f Write /d/f
  330. .PP
  331. Replace /d/f Replace /d\**
  332. .FS
  333. The condition stops the
  334. recursion at the root directory of the file system.
  335. .FE
  336. .PP
  337. Write /d/f Become Owner(/d/f)\**
  338. .FS
  339. The owner of a file can
  340. always change the access permissions to allow owner write access.
  341. .FE
  342. .PP
  343. Write /d/f GroupWrite(/d/f) Member Group(/d/f)
  344. .PP
  345. Write /d/f WorldWrite(/d/f) Member World\**
  346. .FS
  347. This subgoal is
  348. is achievable by all users provided they can get to the file.  The
  349. notable exceptions are users logged in via anonymous ftp or uucp
  350. connections.  These users have restricted access to the file
  351. hierarchy.
  352. .FE
  353. .sp
  354. }
  355. .PP
  356. \fBlogin\fP
  357. .PP
  358. The login program uses two database to set the UID and GIDs of the
  359. user's command interpreter.  The contents of
  360. these databases and the protection of the databases themselves
  361. must be considered part of the protection configuration.
  362. .PP
  363. The user name \*Qroot\*U refers to the super-user.  The label, \*QU\*U, stands
  364. for an arbitrary UID including \*Qroot\*U.  The label, \*QG\*U, stands for
  365. an arbitrary GID.  The expression \*QUIDS(G)\*U expands to all the
  366. UIDs authorized to use the group \*QG\*U according to the files
  367. /etc/group or /etc/passwd.
  368.  
  369. .sp
  370. Rules{
  371. .sp
  372. .ul
  373. <Goal/Condition/Subgoal/Note>
  374.  
  375. Become U Replace /etc/passwd\**
  376. .FS
  377. This rule matches the goal \*QBecome root\*U.
  378. .FE
  379.  
  380. Member G Replace /etc/group
  381.  
  382. Member G Become UIDS(G)\**
  383. .FS
  384. The subgoal means to try to become any member of the group \*QG\*U.
  385. .FE
  386. .sp
  387. }
  388. .PP
  389. \fBrsh, rlogin, rcp\fP
  390. .PP
  391. Berkeley Unix includes several remote execution commands that greatly
  392. improve the usability of multiple Unix hosts connected by a network.
  393. The underlying authentication protocol does not resist an attacker
  394. that can transmit arbitrary messages on the network, but even if that
  395. problem was fixed, the databases used by these programs would have to
  396. be considered as part of the protection system.
  397. .PP
  398. The file /etc/hosts.equiv lists the names of the hosts that are
  399. trusted by the target machine's administrators.  If a user has an
  400. account on the target machine, and on one of the trusted hosts, then
  401. that user can log into the target machine from the trusted machine
  402. without supplying a password.  Users can list additional hosts (or
  403. other users) that they trust in a file (.rhosts) in their home
  404. directory.
  405. .PP
  406. The expression \*QNotEmpty(/d/f)\*U is true if the file /d/f exists and
  407. it is not empty.  The label, \*Q~U\*U, refers to the home directory of user
  408. \*QU\*U.
  409. .sp
  410. Rules{
  411. .sp
  412. .ul
  413. <Goal/Condition/Subgoal/Note>
  414. .PP
  415. Become U (~U/.rhosts) /etc/hosts\**
  416. .FS
  417. If there is
  418. a host listed in the user's remote access database and the host name
  419. table is replaceable, then an attacker can make his host appear to be
  420. the host listed in the user's database.  This assumes that the
  421. attacker has super-user privileges on some host that can talk to the
  422. target host, because the attacker will need to create an account with
  423. the target's user name.  This attack will become obsolete when hosts
  424. start using a distributed name server rather than a fix hostname
  425. database.  However, the name server will open other avenues of attack.
  426. .FE
  427. .PP
  428. Become U Write ~U/.rhosts\**
  429. .FS
  430. The remote execution routines insist that the target user be the owner
  431. of the database file, so replace access is not sufficient to use this
  432. attack.
  433. .FE
  434. .PP
  435. Become U root Replace /etc/hosts.equiv\**
  436. .FS
  437. Remote execution with super-user privileges is only accepted from
  438. the hosts listed in ~root/.rhosts, so replacing the hosts.equiv file
  439. cannot be used to directly gain access to super-user privileges.
  440. .FE
  441. .sp
  442. }
  443. .PP
  444. \fBshells\fP
  445. .PP
  446. Several command interpreters, called shells, have been written for
  447. Unix.  Different users can use different shells, but all shell have
  448. some mechanism for executing a list of commands when a user logs in.
  449. The files that specify these initialization commands are a part of the
  450. protection configuration that each user can change.
  451. .PP
  452. The expression \*QExists(/d/f)\*U is true if the file /d/f exists.
  453. .sp
  454. Rules{
  455. .sp
  456. .ul
  457. <Goal/Condition/Subgoal/Note>
  458. .PP
  459. Become U Exists(~U/.login) Replace ~U/.login\**
  460. .FS
  461. This file contains the commands read when a user logs in.
  462. The conditional should really test to see if the user is actually using
  463. the /bin/csh command interpreter.  If csh is being used, then
  464. this rule will work even if the file .login doesn't exist, so
  465. the conditional is overly strict.
  466. .FE
  467. .PP
  468. Become U Exists(~U/.cshrc) Replace ~U/.cshrc\**
  469. .FS
  470. This file is read each time a /bin/csh is executed such as at login
  471. and when a command file is executed.  The conditional is also overly
  472. strict.
  473. .FE
  474. .PP
  475. Become U Exists(~U/.profile) Write ~U/.profile\**
  476. .FS
  477. Same trick for the /bin/sh command interpreter.
  478. .FE
  479. .sp
  480. }
  481. .PP
  482. \fBcron\fP
  483. .PP
  484. Cron is a program that is forked off when a Unix system is booted.
  485. This means that it runs with super-user privileges.  Cron reads a
  486. database (/usr/lib/crontab) that describes the commands that should be
  487. executed periodically.  By default these commands are executed with
  488. \*Qroot\*U privileges.
  489. .sp
  490. Rules{
  491. .sp
  492. .ul
  493. <Goal/Condition/Subgoal/Note>
  494.  
  495. Become root none Replace /usr/lib/crontab
  496. .sp
  497. }
  498. .PP
  499. \fBsendmail\fP
  500. .PP
  501. The Unix mail system has many features that allow flexible forms of
  502. information sharing.  The most interesting feature (to system builders
  503. and to attackers) is that receiving mail can trigger the invocation of
  504. a program which is passed the mail message as its input.  The file
  505. /usr/lib/aliases specifies the human readable form of a binary
  506. database that describes mailing lists, mail forwarding, and programs
  507. to invoke when mail is received by certain mailboxes.  Being able to
  508. modify this database allows an attacker to get access to other
  509. people's user and group IDs because the mail sending program runs with
  510. the privileges of the user who invokes it.  If the destination of the
  511. message is on the same host as the source, then the receiving program
  512. (also sendmail) will run with the invoker's privileges.  If the source
  513. of the message is on another computer, then sendmail will run under
  514. the UID \*Qdaemon\*U.
  515. .sp
  516. Rules{
  517. .sp
  518. .ul
  519. <Goal/Condition/Subgoal/Note>
  520. .PP
  521. Become daemon none Replace /usr/lib/aliases\**
  522. .FS
  523. This assumes
  524. that the command to build the binary database can be executed by
  525. everyone, or that it is executed automatically when the mailer detects
  526. that the binary database is out of date.  There should also be rules
  527. to see if the binary database can be written directly.
  528. .FE
  529. .PP
  530. Become root none Replace /usr/lib/aliases\**
  531. .FS
  532. Assumes that
  533. \*Qroot\*U sends mail to some user on this machine.  Such users can be
  534. found by scanning the mail logs, which are usually World readable.  If
  535. such a user exists, the aliases database can be set up to tell sendmail to
  536. deliver mail to the recipient and invoke the attacker's program.  Next
  537. time root sends mail to that user, the attacker's program will be
  538. invoked with root privileges.  The program would test to see if it was
  539. running with \*Qroot\*U privileges, and if so plant a trap door such as
  540. making /.rhosts publicly writable.
  541. .FE
  542. .sp
  543. }
  544. .PP
  545. \fBboot\fP
  546. .PP
  547. When a Unix reboots, it executes the commands in the file /etc/rc.
  548. This file usually executes the commands in the file /etc/rc.local.
  549. .sp
  550. Rules{
  551. .sp
  552. .ul
  553. <Goal/Condition/Subgoal/Note>
  554.  
  555. Become root Exists(/etc/rc) Replace /etc/rc
  556.  
  557. Become root Exists(/etc/rc.local) Replace /etc/rc.local
  558. }
  559. .PP
  560. \fBExtensions to the Unix model\fP
  561. (extensions)
  562. .PP
  563. This section lists some of the important pieces of the Unix protection
  564. system that were left out of the SU-Kuang's model.  Most of these
  565. pieces could be added easily.
  566. .PP
  567. The major deficiency of the model is that it does not include all of the
  568. programs that run with super-user privileges.  Each of these
  569. programs must be modeled if there is some way that an attacker could
  570. use the programs' databases to get access to root privileges.
  571. .PP
  572. Locating all the programs that run with super-user privileges is not
  573. easy.  Many ordinary programs are executed inside of command files
  574. that are run with root privileges.  This points out another
  575. shortcoming of SU-Kuang.  It does not look inside of command files.
  576. For example, on system restart, Unix executes the commands in the file
  577. /etc/rc with super-user privileges.  That file executes additional
  578. commands in the file /rc.local, so those commands also runs as root.
  579. The prototype has an explicit rule that covers this case, whereas it
  580. should deduce this and other cases by parsing the commands in /etc/rc.
  581. .PP
  582. The prototype does not understand search paths.  On Unix, as with most
  583. systems, users do not specify the full pathname of the programs they
  584. want to execute.  Instead, users specify a sequence of directories
  585. that should be searched to find the program.  Often users tell their
  586. command interpreter to first look in a private directory of commands,
  587. and quite often that directory is writable by any member of the user's
  588. primary group.  If an attacker can write a user's private command
  589. directory, then the attacker can plant a trojan horse on that user.
  590. For example, the user may want to execute /usr/local/gnuemacs, but the
  591. user may end up executing the attacker's program in
  592. /usr/smith/@_bin/gnuemacs.  To model this attack, SU-Kuang would need to
  593. be able to read each user's startup command file to determine each
  594. user's search path.
  595. .PP
  596. The file goals considered by the model only include write and replace
  597. access to a file.  Read access is not considered.  To include read
  598. access, each piece of the protection system must be re-examined to see
  599. if it could provide read access to an arbitrary file.  For example,
  600. the Unix finger program, which displays information about users, runs
  601. with super-user privileges so it can read an information file (.plan)
  602. in the specified user's home directory.  Unfortunately, some
  603. implementations of the finger program allow the .plan file to be a
  604. symbolic link to another file, and thus the finger program allows read
  605. access to any file on the system.
  606. .PP
  607. The rules that model the file system do not include the fact that the
  608. disks can be accessed via the raw device files.  Reading and writing
  609. the device files can be used to read and write arbitrary blocks on the
  610. disks.  These files should only be accessible to the super-user, but
  611. often anyone can read them.  If so, an attacker can read any file on
  612. the disk.
  613. .PP
  614. A different kind of deficiency in the model is that it does not allow
  615. the attacker to guess at passwords.  On a system that allows users to
  616. pick their own passwords, an attacker can usually guess a few of the
  617. passwords.  Assuming that an attacker can read the password file,
  618. \**
  619. .FS
  620. Protecting the password file from users logged in on a guest
  621. account or using anonymous file transfer is a good idea.  However,
  622. protecting it from ordinary users is hard.  Many programs need read
  623. access to the non-password information kept in that file, and making
  624. all those programs run with special privileges may create more
  625. problems than it solves.
  626. .FE
  627. the attacker can test passwords at the rate of about ten per second.\**
  628. .FS
  629. There are lots of tricks that speed up the execution of
  630. the Unix salted DES function on a 32 bit machine.
  631. .FE
  632. A 2000 word dictionary of common passwords can be processed at the
  633. rate of a few minutes per account.
  634. .PP
  635. As in any kind of modeling, the better the model, the better the
  636. results.  Fortunately, in the case of Unix, making the model more
  637. detailed does not require using a more complicated framework. The
  638. rule-based framework of SU-Kuang is flexible enough to model all the
  639. features described in this section.
  640. .PP
  641. \fBPrototype Implementation\fP
  642. (implementation)
  643. .PP
  644. The SU-Kuang program described in this paper is easy to
  645. implement.  The primary inputs to the program are a list of groups
  646. (privileges) accessible to the attacker (including the special group
  647. \*QWorld\*U), and the target goal (usually \*Qbecome root\*U).  The
  648. program examines the protection configuration of the machine it is
  649. running on, so this can be considered a secondary input.  The
  650. primary output is a list of the ways that an attacker can achieve the
  651. target goal from the initial privileges.  Internally, the program
  652. builds a goal-tree based on a set of rules that are compiled into the
  653. program.  When a node of the goal-tree can be directly achieved using
  654. the initial privileges, the program prints out the sequence of steps
  655. that describe the path from the given node of the goal-tree to the
  656. root of the goal-tree.
  657. .PP
  658. In classic Unix style, the prototype was initially implemented by a
  659. set of shell scripts (command files).  Later, to improve performance,
  660. some of the shell scripts were re-written in C.  The top level
  661. shell script keeps track of the goal-tree, and invokes other shell
  662. scripts to generate successive levels of the goal-tree.  For each of the
  663. three kinds of goals (user, group, and file), there is a shell script
  664. that reads a list of goals of that kind and produces a list of
  665. subgoals.
  666. .PP
  667. Associated with each node of the goal-tree is a human readable comment
  668. that describes the path from each node to the root of the goal-tree.
  669. This comment is appended to a list of 'successes' if the
  670. associated goal can be directly achieved using the initial privileges
  671. of the attacker.  Since each comment specifies the sequence of steps
  672. an attacker could use to achieve the target goal given the current
  673. goal, it is easy to derive the comments for subgoals from the comments
  674. of parent goals.  The subgoal comments is the parent goal's comment
  675. plus an indication of which rule was used to derive the subgoal.
  676. .PP
  677. The basic data abstraction used by SU-Kuang is a goal-table.  There
  678. are three goal-tables, one for each type of goal.  The operations on a
  679. goal table are: 
  680. .ul
  681. new, 
  682. .ul
  683. addto, and 
  684. .ul
  685. next.  The 
  686. .ul
  687. new
  688. operation creates an empty goal table.  It takes a set of initial
  689. goals that are directly achievable by the attacker.  The 
  690. .ul
  691. addto
  692. operation adds a goal and a comment to the table.  If the goal is
  693. already in the table, the table is not changed.  If the goal is in the
  694. set of directly achievable goals, then 
  695. .ul
  696. addto also appends the
  697. comment to the file that contains a list of successes.  The operation,
  698. .ul
  699. next, examines a goal-table and returns any goal-comment pair that
  700. it has not already returned.  The 
  701. .ul
  702. addto
  703. operation is effectively
  704. the inner loop of a rule interpreter.
  705. .PP
  706. The goal-table abstraction is implemented by four files.  One file
  707. keeps track of all of the goals in the table and it is used to avoid
  708. duplicate goals.  Another file holds the list of goals initially
  709. available to the attacker.  Two files are used to support the next
  710. operation.  One file records all the goal-comment pairs that have been
  711. returned by the next operations, the other file lists the goal-comment
  712. pairs that have been added to the table but not yet selected by the
  713. next operation.
  714. .PP
  715. Using the goal-table abstraction it is easy to express rules as lines
  716. of a shell script.  Figure
  717. .ul
  718. shell
  719. rule shows a rule and its shell
  720. script implementation.  The conditional part of the rules are
  721. expressed by shell script conditionals (e.g., \*Q-z\*U means that a file
  722. exists and has a length of zero, \*Q!\*U and \*Q&&\*U mean logical
  723. negation and conjunction).
  724. .sp
  725. Rules{
  726. .sp
  727. .ul
  728. <Goal/Condition/Subgoal>
  729.  
  730. Become root NotEmpty(/.rhosts) Replace /etc/hosts
  731. .sp
  732. }
  733.  
  734. .nf
  735. # $User and $OldComment are set by the goal-table next operation.
  736. # $FileGoals refers to the goal-table object for file type goals.
  737. if (($User == "root") && (! -z /.rhosts))  then
  738.     set NewComment="Fake HostAddress, $OldComment"
  739.     set SubGoal="Replace /etc/hosts"
  740.     addto $FileGoals $SubGoal $NewComment
  741. endif
  742. .fi
  743. Sample rule and corresponding shell script line.
  744.  
  745. .PP
  746. The implementation of SU-Kuang is straight forward.  The only reason
  747. for describing it in this paper is to demonstrate how easy it is to
  748. process the attacker-oriented rules that describe a protection system.
  749. .PP
  750. \fBExperience\fP
  751. (experience)
  752. .PP
  753. The SU-Kuang system has been run on a large number of
  754. sites managed by personnel with a wide range of skills and interests
  755. in security.  It has almost always found a hole.  A Kuang that
  756. incorporates the extensions described in section
  757. .ul
  758. extensions
  759. would find more holes.
  760. .PP
  761. I believe that holes are created because users do not understand how
  762. the various pieces of the protection system interact.  The main
  763. evidence for this is that fact that most holes are found in the
  764. protection databases that are maintained by ordinary users (e.g.,
  765. .login and .rhosts).  Also, users who have recently been given special
  766. privileges tend to create holes that allow anyone to achieve
  767. super-user privileges.  When I tell users about the problems SU-Kuang
  768. finds, they often do not understand what was wrong with the decision
  769. they made.
  770. .PP
  771. Users create security holes periodically.  When I ran SU-Kuang
  772. periodically on one computer that had a large complicated protection
  773. configuration (e.g., the authorization databases included 300 users
  774. and 25 groups), SU-Kuang found new holes every week or two.  Often
  775. these new holes were created when someone modified a security
  776. database.  One common procedure for modifying a database is to first
  777. rename the original, then copy of the original into a file with the
  778. proper name, and finally edit the copy.  The motivation for the first
  779. rename step is to preserve the timestamp that indicates when the
  780. database was last written.  Unfortunately, the file copy step does not
  781. copy the protection information from the original database.  The
  782. protection for the copy is determined by the defaults for the
  783. currently running process.  It is not determined by the original.  The
  784. file UID is set to the UID of the process that performs the copy,
  785. and the GID is set to the GID of the directory that contains
  786. the file.  The permission bits are set to a default value specified in
  787. the copier's login command file.
  788. .PP
  789. The holes found by SU-Kuang point out that it is hard to set up multiple
  790. separate security groups under BSD4.2 Unix.  For example, a group
  791. that allows its members to install programs in the /etc directory,
  792. also allows its members to replace the authentication database in
  793. /etc/passwd.  The fact that users run with their full privileges (i.e.,
  794. they can access multiple groups in the same process), makes Berkeley
  795. Unix easier to use than other versions of Unix that force users to
  796. access one group at a time.  However, that same feature makes it
  797. easier for an attacker to plant a trojan horse on a user that is a
  798. member of a lower privilege group (e.g., the implementors of some
  799. project) and a member of a high privilege group (e.g., staff).
  800. .PP
  801. The impression I have gotten from running SU-Kuang is that most of the
  802. features that make Unix easy to use also make Unix hard to secure.
  803. However, SU-Kuang does make it easier to build a secure protection
  804. configuration for Unix.    
  805.  
  806. .PP
  807. \fBDiscussion\fP
  808. (conclusions)
  809. .PP
  810. To increase the usefulness of computers, systems designers have
  811. provided an increasing number of mechanisms that allow users to
  812. execute commands and share information.  Since these new mechanisms
  813. must be considered part of the protection system, this trend has made
  814. protection systems larger and progressively harder to understand.  As
  815. a protection system becomes more complex, it becomes unlikely that
  816. all the protection decisions are made correctly, and these mistakes
  817. can ruin the overall security of the information and resources
  818. controlled by computers.  The commercial environment presents a
  819. special problem because usability is the primary goal of commercial
  820. information systems, but security cannot be neglected.  There needs to
  821. be some way to manage the complexity of the protection systems that arise
  822. on information systems that stress usability.
  823. .PP
  824. This paper presents one approach for achieving both usability and
  825. security.  The idea is to use rule-based systems to analyze the
  826. interactions between all the decisions that make up a computer's
  827. protection configuration.  If analyzing a protection configuration is
  828. easy, then the manager of a system can ensure that the system meets
  829. the security objectives of its users.  A program that performs a
  830. simple analysis of a Unix protection configuration was presented to
  831. illustrate that this sort of rule-based system is easy to build if
  832. the protection system is described from the attacker's viewpoint.
  833. This simple Unix analysis system, called SU-Kuang, answered the
  834. question "given access to a particular set of privileges,
  835. can an attacker achieve super-user privileges?".  Using SU-Kuang,
  836. a security manager could ensure that a system did not allow ordinary
  837. user to achieve super-user privileges.
  838. .PP
  839. SU-Kuang is just one of many helpful Kuang-type systems.  For example,
  840. many security objectives are expressed in terms of limiting the set of
  841. people who have access to particular privileges.  A Kuang-type system
  842. that computed the set of privileges accessible to each user would help
  843. a security manager determine whether the security objectives are being
  844. met.  Even better, if the bulk of the security objectives can be
  845. expressed in computer understandable form, then the bulk of the work
  846. of checking computer security could be automated.
  847.  
  848.