home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / security / smrsh / README next >
Encoding:
Text File  |  1993-11-04  |  5.0 KB  |  146 lines

  1.  
  2.  
  3.  
  4. README  smrsh - sendmail restricted shell.
  5.  
  6.  
  7. This README file is provided as a courtesy of the CERT Coordination Center,
  8. Software Engineering Institute, Carnegie Mellon University.  This file is 
  9. intended as a supplement to the CERT advisory CA-93:16.sendmail.vulnerability,
  10. and to the software, smrsh.c, written by Eric Allman.
  11.  
  12.  
  13.  
  14. The smrsh(8) program is intended as a replacement for /bin/sh in the
  15. program mailer definition of sendmail(8).  This README file describes
  16. the steps needed to compile and install smrsh.
  17.  
  18. smrsh is a restricted shell utility that provides the ability to
  19. specify, through a configuration, an explicit list of executable
  20. programs.  When used in conjunction with sendmail, smrsh effectively
  21. limits sendmail's scope of program execution to only those programs
  22. specified in smrsh's configuration.
  23.  
  24. smrsh has been written with portability in mind, and uses traditional 
  25. Unix library utilities.  As such, smrsh should compile on most
  26. Unix C compilers.
  27.  
  28.  
  29.  
  30. To compile smrsh.c, use the following command:
  31.  
  32. host.domain% cc -o smrsh smrsh.c
  33.  
  34. For machines that provide dynamic linking, it is advisable to compile
  35. smrsh without dynamic linking.  As an example with the Sun Microsystems
  36. compiler, you should compile with the -Bstatic option.
  37.  
  38. host.domain% cc -Bstatic -o smrsh smrsh.c
  39.  
  40.  
  41. Choose a directory that smrsh will reside in.  We will use the traditional 
  42. /usr/etc directory for the remainder of this document.
  43.  
  44. As root, install smrsh in /usr/etc directory, with mode 511.
  45.  
  46. host.domain# mv smrsh /usr/etc
  47. host.domain# chmod 511 /usr/etc/smrsh
  48.  
  49.  
  50.  
  51. Next, determine the list of commands that smrsh should allow sendmail
  52. to run.  This list of allowable commands can be determined by:
  53.  
  54.    1.  examining your /etc/aliases file, to indicate what commands 
  55.        are being used by the system. 
  56.  
  57.    2.  surveying your host's .forward files, to determine what 
  58.        commands users have specified.  
  59.  
  60. See the man page for aliases(5) if you are unfamiliar with the format of 
  61. these specifications. Additionally, you should include in the list, 
  62. popular commands such as /usr/ucb/vacation.
  63.  
  64. You should NOT include interpreter programs such as sh(1), csh(1),
  65. perl(1), uudecode(1) or the stream editor sed(1) in your list of 
  66. acceptable commands.
  67.  
  68.  
  69. You will next need to create the directory /usr/adm/sm.bin and populate 
  70. it with the programs that your site feels are allowable for sendmail
  71. to execute.   This directory is explicitly specified in the source
  72. code for smrsh, so changing this directory must be accompanied with
  73. a change in smrsh.c.
  74.  
  75.  
  76. You will have to be root to make these modifications.
  77.  
  78. After creating the /usr/adm/sm.bin directory, either copy the programs
  79. to the directory, or establish links to the allowable programs from
  80. /usr/adm/sm.bin.  Change the file permissions, so that these programs
  81. can not be modified.  If you use links, you should ensure that the target 
  82. programs are not modifiable.
  83.  
  84. To allow the popular vacation(1) program by creating a link in the 
  85. /usr/adm/sm.bin directory, you should:
  86.  
  87. host.domain# cd /usr/adm/sm.bin
  88. host.domain# ln -s /usr/ucb/vacation vacation
  89.  
  90.  
  91.  
  92.  
  93. After populating the /usr/adm/sm.bin directory, you can now configure
  94. sendmail to use the restricted shell.  Save the current sendmail.cf
  95. file prior to modifying it, as a prudent precaution.
  96.  
  97. Typically, the program mailer is defined by a single line in the 
  98. sendmail configuration file, sendmail.cf.  This file is traditionally
  99. found in the /etc, /usr/lib or /etc/mail directories, depending on 
  100. the UNIX vendor.
  101.  
  102. If you are unsure of the location of the actual sendmail configuration
  103. file, a search of the strings(1) output of the sendmail binary, will
  104. help to locate it.
  105.  
  106. In order to configure sendmail to use smrsh, you must modify the Mprog 
  107. definition in the sendmail.cf file, by replacing the /bin/sh specification 
  108. with /usr/etc/smrsh.
  109.  
  110. As an example:
  111.  
  112. In most Sun Microsystems' sendmail.cf files, the line is:
  113. Mprog,    P=/bin/sh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
  114.  
  115. which should be changed to:
  116. Mprog,    P=/usr/etc/smrsh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
  117.           ^^^^^^^^^^^^^^
  118.  
  119. A more generic line may be:
  120. Mprog,        P=/bin/sh, F=lsDFM, A=sh -c $u
  121.  
  122. and should be changed to;
  123. Mprog,        P=/usr/etc/smrsh, F=lsDFM, A=sh -c $u
  124.  
  125.  
  126. After modifying the Mprog definition in the sendmail.cf file, if a frozen 
  127. configuration file is being used, it is essential to create a new one.
  128. You can determine if you need a frozen configuration by discovering
  129. if a sendmail.fc file currently exists in either the /etc/, /usr/lib,
  130. or /etc/mail directories.  The specific location can be determined using
  131. a search of the strings(1) output of the sendmail binary.
  132.  
  133. In order to create a new frozen configuration, if it is required:
  134. host.domain# /usr/lib/sendmail -bz
  135.  
  136. Now re-start the sendmail process.  An example of how to do this on 
  137. a typical system follows:
  138.  
  139. host.domain# /usr/bin/ps aux | /usr/bin/grep sendmail
  140. root 130  0.0  0.0  168    0 ?  IW   Oct  2  0:10 /usr/lib/sendmail -bd -q
  141. host.domain# /bin/kill -9 130
  142. host.domain# /usr/lib/sendmail -bd -q30m
  143.  
  144.  
  145.  
  146.