Ghttpd is a fast and efficient HTTP server that has CGI support. Ghttpd has a small memory foot print and is capable of handling thousands of simultaneous connections. It is ideal for large and small websites. A security vulnerability in the product allows remote attackers to cause the product to execute arbitrary code.
Credit:
The information has been provided by pyramid-rp.
This flaw was detected in the latest ghttpd version (1.4-3) but it's likely that the problem exists in previous versions as well, although this was not tested.
A proof of concept exploit was coded for ghttpd servers running on "i386 RedHat 7.3 Linux", "i386 RedHat 7.2 Linux" and "i386 Slackware 8.1" operating systems.
[root@testlab httpd]# uname -a
Linux testlab 2.4.18-3 #1 Thu Apr 18 07:31:07 EDT 2002 i586 unknown
[root@testlab ghttpd]# cat /etc/issue
Red Hat Linux release 7.3 (Valhalla)
[flea@testlab httpd]$ telnet localhost 36864
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
id;
uid=99(nobody) gid=99(nobody) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) : command not found
Temporary Patch:
Another similar bug affects the Log() function, so here's a temporary fix for both.
va_start(ap, format); // format it all into temp
+
+ /* temp[200] overflow patch */
+ temp = malloc(strlen(format)+1024);
- - vsprintf(temp, format, ap);
+ vsnprintf(temp, strlen(format)+1024, format, ap);
va_end(ap);
// format it all so we have date/time/loginfo
+ /* temp2[200] overflow patch */
+ temp2 = malloc((strlen(temp) + strlen(datetime_final) + 5));
sprintf(temp2, "%s - %s\n", datetime_final, temp);
sprintf(logfilename, "%s/ghttpd.log", SERVERROOT);
@@ -234,4 +240,4 @@
fputs(temp2, logfile); // Save to the file
fclose(logfile); // Close file
- -}
\ No newline at end of file
+}
EOF
Exploit:
/* PRPghttpd.c
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-
PYR/\MID, Research Project
Author: flea
Date: October 7, 2002
Members: Apm, flea, thread
Proof of Concept Remote Exploit for GazTek HTTP Daemon v1.4-3
Works on:
i386 Redhat 7.2
i386 Redhat 7.3
i386 Slackware 8.1