First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 81894
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Security <security@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: rob holland (RETIRED) <tigger@gentoo.org>
Add CC:
CC:
URL:
Summary:
Status Whiteboard:
Keywords:
Flags: Requestee:
 
 
  ()

Filename Description Type Creator Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 81894 depends on: Show dependency tree
Bug 81894 blocks:

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2005-02-13 11:53 0000
The gproftpd source code is badly written. Lots of sprintf, strcat (versus
snprintf and strncat), allowing stack and heap overflows.

The package should be masked. I have notified the author of problems.

I haven't patched it as it'd be a big patch and I don't use the software.

I haven't attempted to exploit any of the overflows but it should be possible.

Marked critical as it should be trivial to exploit.

Reproducible: Always
Steps to Reproduce:

------- Comment #1 From solar 2005-02-13 11:58:43 0000 -------
Could you provide an example of where user/network input is taken and can be 
abused. I often see programs which do not use snprintf()/strncat() but do so 
in a semi safe way (kernel)

------- Comment #2 From Andreas Kling 2005-02-13 14:42:43 0000 -------
Here's a nice (and not too revealing) example from callbacks.c:

sprintf(user_pass, "usermod -p '%s' %s", encrypted_pass, username);

Try changing a user's password in gproftpd while grep'ing for usermod processes.

You will catch something like this:

 8715 pts/8    D+     0:00 usermod -p $1$is54ShF3$4RUrFy9d8D8I0VCBlo5c91 test_user

This package should be blocked.

------- Comment #3 From rob holland (RETIRED) 2005-02-13 15:10:45 0000 -------
Try typing lots of stuff in the DNS server text entry box and hitting add
server, overflow in xfer_update.

------- Comment #4 From solar 2005-02-13 16:28:14 0000 -------
oh this is nice the package is maintained by bug-wranglers@gentoo.org
2 votes for masking now.

------- Comment #5 From Andrea Barisani (RETIRED) 2005-02-13 16:29:08 0000 -------
/me votes for masking it

------- Comment #6 From rob holland (RETIRED) 2005-02-13 16:40:45 0000 -------
I lied, the overflow isn't related to the text field at all.

bzero(&(myaddr.sin_zero), sizeof(myaddr));

in xfer_update, callbacks.c.

It overflows itself, doesn't need user help :P

------- Comment #7 From rob holland (RETIRED) 2005-02-14 01:15:50 0000 -------
Having looked post-coffee this morning I think I over-reacted here. The code is
indeed crap, but I can't see anything exploitable, even if it does have stupid
self-inflicted overflow in it.

There is an information leak as noted by Andreas.

Maybe if someone with more knowledge than me could review the code?

------- Comment #8 From rob holland (RETIRED) 2005-02-14 02:26:22 0000 -------
The code popens "ftpwho" in callbacks.c if something (anything) is listening on
the port which is metioned in proftpd.conf. An evil ftpwho in my path:

--- "exploit" ---
rob@leet ~ $ cat bin/ftpwho 
#!/usr/bin/perl

print 'v' x 68000;
--- end ---

This causes a segfault. I assume this is exploitable, can someone who knows
better than me check please?

------- Comment #9 From rob holland (RETIRED) 2005-02-14 03:52:33 0000 -------
its possible to overflow tempname in callbacks.c:user_exists by having a passwd
line longer than 4096. Quite how you'd manage to get that I don't know... chfn
limits you to a total of 80 chars for the gecos field.

------- Comment #10 From Andreas Kling 2005-02-14 05:19:51 0000 -------
If the proftpd daemon is running without a MaxInstance limit (not default),
spawn about ~500 simultaneous connections (no authentication required) and
gproftpd will overflow in a strcat() call.

------- Comment #11 From rob holland (RETIRED) 2005-02-15 02:40:47 0000 -------
A new version has been released which fixes the ftpwho overflow. I'll let
Magnus know about the passwd/ps listing bugs.

------- Comment #12 From Tavis Ormandy (RETIRED) 2005-02-15 08:45:39 0000 -------
There's an remotely exploitable format string vulnerability in the gprostats
log parser, users can trigger it by putting or fetching a specally crafted
filename:

the vulnerable statements:

314: snprintf(datestamp, x+1, old_buffer);

obvious fix, add "%s" as arg3. 

demo:

$ lftp taviso@localhost
Password: 
lftp taviso@localhost:~> put /dev/null -o foo%.500nbar
lftp taviso@localhost:~> exit                

which generates the xferlog line:

Tue Feb 15 16:43:07 2005 0 localhost 0 /home/taviso/foo%.500nbar b _ i r taviso
ftp 1 * c

running gprostats:

$ gdb /usr/sbin/gprostats 
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".
(gdb) r -c /etc/proftpd/proftpd.conf -x /var/log/xferlog 
Starting program: /usr/sbin/gprostats -c /etc/proftpd/proftpd.conf -x
/var/log/xferlog
Using conf: /etc/proftpd/proftpd.conf
Using xferlog: /var/log/xferlog

Program received signal SIGSEGV, Segmentation fault.
0x4008d26a in vfprintf () from /lib/libc.so.6

Changing component to vulnerability.

------- Comment #13 From rob holland (RETIRED) 2005-02-16 01:18:39 0000 -------
New version 8.1.9 released by Magnus which fixes the remote overflow via the
log file.

There are still a few local format-string overflows when reading from the
config file:

rob@leet /tmp/gproftpd-8.1.9 $ cat /tmp/conf 
ServerName foo%.1000nblehbleh

rob@leet /tmp/gproftpd-8.1.9 $ gdb ./src/gprostats
GNU gdb 6.2.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) r -c /tmp/conf
Starting program: /tmp/gproftpd-8.1.9/src/gprostats -c /tmp/conf
Using conf: /tmp/conf

Program received signal SIGSEGV, Segmentation fault.
0xb7ed1622 in _IO_vfprintf (s=0xbffe89a0, format=0x80521cb
"foo%.1000nblehbleh", ap=0xbffe8ad0 "") at vfprintf.c:1534
1534    vfprintf.c: No such file or directory.
        in vfprintf.c
(gdb) backtrace
#0  0xb7ed1622 in _IO_vfprintf (s=0xbffe89a0, format=0x80521cb
"foo%.1000nblehbleh", ap=0xbffe8ad0 "") at vfprintf.c:1534
#1  0xb7eef02d in _IO_vsnprintf (string=0xbfff1440 "foo", maxlen=83,
format=0x0, args=0xbffe8acc "") at vsnprintf.c:120
#2  0xb7ed6b62 in __snprintf (s=0x0, maxlen=0, format=0x0) at snprintf.c:35
#3  0x080494ae in main (argc=3, argv=0xbffff4e4) at gprostats.c:196
(gdb)

------- Comment #14 From Tavis Ormandy (RETIRED) 2005-02-16 05:41:58 0000 -------
net-ftp/gproftpd-8.1.9 has been added to portage.

------- Comment #15 From Thierry Carrez (RETIRED) 2005-02-16 05:45:25 0000 -------
sparc: please test and mark stable.

------- Comment #16 From Gustavo Zacarias (RETIRED) 2005-02-16 11:07:15 0000 -------
sparc stable.

------- Comment #17 From Sune Kloppenborg Jeppesen 2005-02-18 08:13:51 0000 -------
Thx Rob and Tavis.

GLSA 200502-26

First Last Prev Next    No search results available      Search page      Enter new bug