home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / exploits / mop / multiple.asc < prev   
Encoding:
Text File  |  1997-02-23  |  3.5 KB  |  106 lines

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