Re: Dosemu/S-Lang Overflow + sploit

From: Erik Mouw (J.A.K.Mouwat_private)
Date: Tue Jan 12 1999 - 10:21:34 PST

  • Next message: Roy T. Fielding: "Apache 1.3.4 Released"

    On Mon, 04 Jan 1999 06:26:52 +0000, digitat_private (digitat_private) wrote:
    > DiGiT and crazy-b present:
    >
    > Dosemu's S-Lang linux/others? local buffer overflow...
    >
    > Risk: local users can obtain root privs. phear script kiddies!
    >
    > The story:
    >
    > <DiGiT>
    >
    > During christmas [IG-88] told me a possible bug in dosemu and libtermcap,
    > first thing I checked was $TERM, and .... overflow (TM) .. after further
    > checking me and crazy-b concluded that this bug was not in libtermcap, but
    > in the S-Lang library. S-Lang is is an interpreted language see
    > http://space.mit.edu/%7Edavis/slang.html for more info about it.
    >
    > <crazy-b>
    > Because of the rumors we suspected it could already be known, so we
    > started investigating this. We found that redhat had already posted a
    > patch for this overflow, and another similar bug, in June '98. And here
    > comes the big BUT! DiGiT had already successfully exploited the dosemu on
    > a standard redhat 5.2 installation which came out in November!! Dosemu
    > comes with its own slang lib, and this had not been patched! Kind of
    > sloppy, since the 5.2 distrib was released months after the discovery of
    > this bug. Possibly because of bad communication with the dosemu
    > programmers?
    >
    > <DiGiT>
    > These are the two overflow conditions in S-Lang; The first one we found
    > could be exploited by setting the TERM variable to write past the end of
    > err_buf:
    >
    >         sldisply.c line 1616:
    >
    >                 SLtt_get_terminfo (void)
    >         -- cut
    >                 char err_buf[512];
    >                 sprintf (err_buf, "Unknown terminal: %s\n\...cut", term);
    >
    > Very simple that! And the second overflow is equally obvious... We cause
    > this overflow by setting TERMINFO to overwrite the file var:
    > This latter one depends on what version of Dosemu, this only appears to be
    > overflowable in some releases of dosemu which have TERMCAP defined.
    >
    >         SLtt_tigetent get's called in sldisply.c line 1647:
    >
    >                 #ifndef USE_TERMCAP
    >                    if (NULL == (Tbuf = tgetent (term)))
    >
    >         sltermin.c line 229:
    >         char file[256];
    >
    >                 char *SLtt_tigetent (char *term)
    >         --cut
    >                 tidir = Terminfo_Dirs[i];
    >                         if (tidir != NULL)
    >                          {
    >                            sprintf (file, "%s/%c/%s", tidir, *term, term);
    >
    >
    > In both cases the exploitable condition will not exist if you have TERMCAP
    > set. So script kiddies, unset TERMCAP before you try to exploit this!
    >
    > <crazy-b>
    > Looks to me like this mess is due to lack of good communication between
    > the programmers. It seems this slipped by the dosemu team anyways!
    > Possibly the S-Lang programmers was not aware of this either.
    >
    > <DiGiT>
    >>From testing we have found that redhat 4.2, and 5.X are vulnerable to
    > these exploits. So is suse 5.X. It is not unlikely that other linux
    > distribs contain the vulnerable dosemu. S-Lang has been ported to many
    > OS', but i haven't had the chance to see if any of them use it, or dosemu
    > for that matter. dosemu sources are distributed with the slackware CD's.
    > Wether or not these are vulnerable i have not checked. Also it is worth
    > mentioning that by default Suse and Debian give "ALL USERS" full access to
    > dosemu, bad bad bad i think...
    >
    >
    > As an example we give you our linux/x86 exploit (script kiddies: W0W FREE
    > LEECH!) for the Dosemu + S-Lang overflow:
    >
    > NOTE: By default rh 5.2, does not allow reg user's to run dosemu so this
    > exploit will probably not work for you, BUT the overflow exists.
    
    [snip exploit code]
    
    I passed your exploit to the more active members of the Dosemu Team (I'm
    too busy to contribute, pity).
    
    Last saturday, the Dosemu Team released Dosemu 0.99.6 which fixes the
    Slang hole. This is a development release, but the changes will also come
    in the next stable release, Dosemu 0.98.5. From the ChangeLog:
    
      99/01/06 ver. 0.99.5.3 unofficial pre-release
              From Hans
              - upgraded to slang-1.2.2 because of buffer overrun exploits
                in 1.0.3. Verified, that _both_ exploits are fixed.
              - fixed (now) possible buffer overrun in verror (utilities.c), because
                slang-1.2.2 fixed its exploit by passing the involved printout
                via (*SLang_Exit_Error_Hook)() to _our_ hooking routine.
                (well, so we now have it ;-)
    
    Dosemu 0.99.6 is available at:
      ftp://ftp.dosemu.org:/dosemu/Development/dosemu-0.99.6.tgz
    
    
    People using the 0.98 stable release should not run Dosemu suid root.
    Remove the s-bit from the Dosemu binary and wait for the next stable
    0.98.5 release.
    
    There is some security related documentation for Dosemu available at
    http://www.dosemu.org/docs/README/0.98/README-3.html , although it is a
    bit outdated.
    
    Note that any Dosemu version running suid root with DPMI enabled is
    inherently unsafe. A DPMI program in Dosemu is able to use Linux system
    calls, including system calls that require root privileges. The Dosemu
    Team is not able to fix this security hole; system administrators who are
    serious about security, should not install Dosemu suid-root. Dosemu can
    run non-suid on the Slangterminal, under X, in the background and even on
    serial lines (bbs'es for example).
    
    
    
    Erik
    (speaking for myself, not for my employer)
    
    --
    J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
    of Electrical Engineering, Faculty of Information Technology and Systems,
    Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
    Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouwat_private
    WWW: http://www-ict.its.tudelft.nl/~erik/
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:28:41 PDT