home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / library / hack / sendmail1.txt < prev    next >
Text File  |  1998-03-25  |  3KB  |  98 lines

  1.                        L0pht Security Advisory
  2.  
  3.                      Application: Sendmail 8.7.5
  4.                            Platforms: All
  5.                    Severity: any local user can gain
  6.                              root priveledges.
  7.                        Author: mudge@l0pht.com
  8.  
  9. Scenario:
  10.  
  11. Due to a problem with the code in sendmail a buffer overflow condition
  12. exists that allows a user to overwrite the information in a saved
  13. stack frame. When the function returns, the saved frame is popped off of
  14. the stack and user code can be executed.
  15.  
  16. An exploit script will be made public upon the actual release of
  17. Sendmail 8.8 which fixes this particular exploitable code segment.
  18.  
  19. Example:
  20.  
  21.   > id
  22.   uid=621(mudge) gid=200(users)
  23.   > ./sploit.sh 3883
  24.   chfn: rebuilding the database...
  25.   chfn: done
  26.   using arg of [0x-------- (hex) + 3883(dec)]
  27.   # id
  28.   uid=621(mudge) euid=0(root) gid=200(users)
  29.   # ./up
  30.   # id
  31.   uid=0(root) gid=200(users)
  32.  
  33. If a user is able to alter his/her gecos field then that user can
  34. exploit a coding flaw in sendmail to elevate their effective UID to 0.
  35.  
  36. Various operating systems ship with chfn(1) which enables users to
  37. change their gecos field. Some of the operating systems that ship with
  38. this program are NetBSD, FreeBSD, BSDI, OpenBSD, and Linux. It has
  39. not been extensively researched as to what others come out of the
  40. box with this functionality. Even if your operating system does not
  41. ship with this functionality, it has been witnessed that many service
  42. providers offering shell accounts add these, or equivalent utils,
  43. in order to minimize their administrative tasks and to facilitate
  44. user functionality. No matter, the flaw is a coding problem in sendmail and
  45. not the fact that these other programs exist.
  46.  
  47. The actual problem in the code is quite apparent.
  48.  
  49.   Inside recipient.c we find the following:
  50.  
  51.   char nbuf[MAXNAME + 1];
  52.   ...
  53.   buildfname(pw->pw_gecos, pw->pw_name, nbuf);
  54.  
  55. The problem is that nbuf[MAXNAME + 1] is a fixed length buffer and as
  56. we will soon see, buildfname() does not honor this.
  57.  
  58. from util.c:
  59.  
  60. void
  61. buildfname(gecos, login, buf)
  62.         register char *gecos;
  63.         char *login;
  64.         char *buf;
  65. {
  66.         register char *p;
  67.         register char *bp = buf;
  68.         int l;
  69.         ...
  70.         /* now fill in buf */
  71.         for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++)
  72.         {
  73.                 if (*p == '&')
  74.                 {
  75.                         (void) strcpy(bp, login);
  76.                         *bp = toupper(*bp);
  77.                         while (*bp != '\0')
  78.                                 bp++;
  79.                 }
  80.                 else
  81.                         *bp++ = *p;
  82.         }
  83.         *bp = '\0';
  84. }
  85.  
  86. Here we see that buildfname() happily copies whatever size we can hand
  87. it into nbuf[MAXNAME +1]. The function is even nice enough to append
  88. a null to the string in case we wanted to put our machine opcodes and
  89. operands inside the gecos field. Though this is one way of doing it,
  90. we opted for another method that enabled us more freedom with the
  91. various methods of altering ones gecos field.
  92.  
  93. Solution:
  94.  
  95. This particular problem has been fixed in Sendmail 8.8 beta.
  96.  
  97. A temporary fix is to remove the ability for users on a local system
  98. to change their gecos (commonly referred to as 'real-name') field.