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

  1.  
  2.                           Irix: another root exploit
  3.                                        
  4.    Yuri Volobuev (volobuev@t1.chem.umn.edu)
  5.    Thu, 21 Nov 1996 13:41:16 -0600
  6.    
  7. Howdy,
  8.  
  9. Brand new root exploit for Irix.  This one's a _little_ less lame than the
  10. previous one, this time it's more like trading 10 years old's dad's truck
  11. for a really cool bicycle.
  12.  
  13. Abstract
  14.  
  15. /usr/bin/X11/cdplayer, part of a standard Irix 5.3/6.2 installation, is
  16. suid and insecure.  It can be used by any local user for creating
  17. root-owned, world-writable arbitrarily named directory anywhere on the
  18. system.  Some other weaknesses of standard Irix configuration allow to
  19. convert it to root priviledges.
  20.  
  21. How to fix:
  22.  
  23. chmod -s /usr/bin/X11/cdplayer
  24.  
  25. (it will break it, but it's no big deal, there's a program called cdman,
  26. usually invoked by double-clicking CD ROM icon on the desktop, that does the
  27. same thing, only better, and it's not suid).
  28.  
  29. To make your Irix generally more safe:
  30.  
  31. systune -i
  32. restricted_chown 1
  33.  
  34. then answer y and press Enter.  5.3 requires reboot for the change to take
  35. effect, I'm not sure about 6.2.
  36.  
  37. In /etc/passwd replace line
  38.  
  39. sysadm:*:0:0:System V Administration:/usr/admin:/bin/sh
  40.  
  41. with something like
  42.  
  43. sysadm:*:0:0:System V Administration:/:/bin/nono
  44.  
  45. or, if you know what you are doing, just remove it.  Removing it _might_
  46. break something.
  47.  
  48. If you are busy person, move on to your next message now.  If you think you
  49. have some time and patience, read on.
  50.  
  51.  
  52. Exploiting suid program vulnerability: practical example.
  53. =========================================================
  54.  
  55. The world of Unix vulnerabilities is big, and suid programs present a good
  56. part of it.  Irix is no exception.  How can this be exploited?
  57.  
  58. Let's review the situation on example.  Look in /usr/bin/X11.  There are
  59. several suid programs, but most of them are standard to all Unices, so their
  60. holes are well known and thus are not interesting for research purposes.
  61. One binary caught our eye -- cdplayer.  It's Irix special, must be
  62. interesting.  Close look reveals that indeed it is.
  63.  
  64. Suid program that does file I/O always has something to offer.  First step,
  65. reading man page, shows that it stores CD catalogs and programs in ~/.cddb
  66. directory.  Well, let's see it working.  Put audio CD in the drive, run
  67. cdplayer.  Looks nice.  Let's make a short CD description and look at what
  68. we have on the disk.  Indeed, ~/.cddb is there, but it's empty.  Hm. ls -ld
  69. ~/.cddb.  Owned by root?  Interesting.  But harmless.  What is the use of
  70. root-owned ~/.cddb?  But what did that man page say about CDDB_WRITE_PATH?
  71. Yep, RTFMing always helps, now we have .cddb in /etc.  Let's see if catalog
  72. files themselves are root-owned. Nope. And it refuses to overwrite anything.
  73. Too bad, it's suid-aware and gives up root priorities.  So it's still
  74. useless.  But it begins to look promising so we take standard step #2,
  75.  
  76. strings /usr/bin/X11/cdplayer
  77.  
  78. As usually, out friend strings tells us many interesting facts.  For
  79. example, there are few strings that look like command line options,
  80. particularly -dbcdir.  Yep, these are valid options, though not documented
  81. in man page.  What -dbcdir does?  Suddenly, our abilities increase from
  82. creating .cddb anywhere to creating a root-owned arbitrarily named directory
  83. anywhere.  Not bad.  But how empty directory could be usefull?  No way.  And
  84. it's writable only by root... hm.  Suddenlly, friend Jay drops by and asks
  85. what's up.  Explain him our advances so far.  Jay isn't so much of a hacker,
  86. but he's curious anyway.  What permissions that directory has, he asks?
  87. Really, let's take a look.  drwxr-xr-x -- why so?  Wait a moment, what is
  88. our umask?  Bull's eye.  umask 000; cdplayer -dbcdir /etc/test.  drwxrwxrwx.
  89. Cool. Well, yeah, but what now?  We can write whatever we want to an
  90. arbitrary directory in arbitrary place -- if it doesn't exist already.
  91. Sounds pretty useless.  Well, it's time to take a little break, relax, chat,
  92. enjoy some spare time.  Rested, we continue.  We were we?  Uhu.  Some
  93. thinking reveals that indeed all that we have earned so far is pretty
  94. useless -- on an ideal OS.  But we deal with Irix, which is pretty far from
  95. this nice state and more close to opposite, user-friendly OS.
  96.  
  97. Some scientists say that humans only use fraction of their brain, the rest
  98. is there but isn't being used.  What is true about humans is usually true
  99. about things that humans create, in particular /etc/passwd files.  Lets take
  100. a peek.  Right near the top, we see an interesting line
  101.  
  102. sysadm:*:0:0:System V Administration:/usr/admin:/bin/sh
  103.  
  104. wow.  uid 0.  But it's starred out.  And home directory doesn't exist.
  105. DOESN'T EXIST?  He he.  One call to our friend cdplayer, and it does.  Now
  106. what?  .forward?  Doesn't work, sysadm is in /etc/aliases.  More chatting
  107. with Jay, and suddenly it strikes me -- why I'm so stupid?  Why I first
  108. think about .forward, not about obvious things?
  109.  
  110. echo "+ +" >/usr/admin/.rhosts
  111.  
  112. As fingers type, lips are telling Jay that it's not going to work.
  113. Yep, it doesn't, .rhosts have to be owned by the home directory owner, i.e.
  114. sysadm.  But we're almost there.  Last effort -- recall it's Irix, and it's
  115. user-friendly.  Remember, some time ago somebody on bugtraq (or was it
  116. linux-security?) asked what is bad in giving away your own file.  Well,
  117. here's a live demo
  118.  
  119. chown root.sys /usr/admin/.rhosts
  120. rsh localhost -l sysadm
  121.  
  122. and we enjoy that wonderful, sweet, warm feeling every hacker gets when he
  123. sees # as his command prompt.  When the machine is friend's, where he
  124. doesn't have root access, which is the case.  Not anymore.
  125.  
  126. So what's the moral of that long lousy story?  Few seemingly minor problems:
  127. cdplayer gives up root priorities a little too late, unused account with uid
  128. 0 in passwd, chown not restricted in default kernel config -- small pieces
  129. make a big picture.  The moral is that cdplayer shouldn't be suid -- why
  130. cdman isn't and still it works? sysadm account shouldn't be there and
  131. shouldn't have real shell for sure, chown should be restricted by default.
  132. But the way it is, a standard Irix 5.3/6.2 installation is vulnerable.
  133.  
  134. Sorry to be so talkative, I'm procrustinating.  My only alternative is
  135. written exam.
  136.  
  137. cheers,
  138.  
  139. yuri
  140.