Last revised: September 23, 1997
Updated Copyright Statement
A complete revision history is at the end of this file.
The CERT Coordination Center has received reports that there is a vulnerability in the NCSA HTTP Daemon V.1.3 for UNIX. Because of this vulnerability, the daemon can be tricked into executing shell commands.
If you have any questions regarding this vulnerability, please contact NCSA (Elizabeth Frank, efrank@ncsa.uiuc.edu ).
We will update this advisory as we receive additional information. Please check advisory files regularly for updates that relate to your site.
I. Description
A vulnerability in the NCSA HTTP Daemon allows it to be tricked into executing shell commands.
II. Impact
Remote users may gain unauthorized access to the account (uid) under which the httpd process is running.
III. Solution
Review the text provided by NSCA (#1 below) and install the patch provided under #2 below.1. Read the following text, which was provided by the HTTPD Team at SDG at NCSA. This text replaces Step 1 in the original version of the advisory. The NCSA text can also be found at
http://hoohoo.ncsa.uiuc.edu/docs/patch_desc.html
Beginning of Text Provided by NCSA
NCSA httpd Patch for Buffer Overflow A vulnerability was recently discovered in the NCSA httpd. A program which will break into an HP system running the precompiled httpd has been published, along with step by step instructions. The program overflows a buffer into program space which then gets executed. If you are running a precompiled NCSA httpd, please ftp a new copy of the binary. If you have compiled your own source code, we recommend applying the following Patch to fix the vulnerability in the NCSA HTTP Daemon V.1.3 for UNIX. It modifies the strsubfirst subroutine in util.c. We believe that earlier versions of the server are vulnerable to a similar attack, and strsubfirst should be modified for all releases of the server. [The original version of] Cert Advisory CA-95.04 describes the problem and includes two suggested steps. We do not recommend taking step 1, which increases MAX_STRING_LEN to 8192. There are 154 occurrences of variables using MAX_STRING_LEN and changing them from 256 to 8192 bytes is going to expand the memory needed to run httpd tremendously! On top of that, httpd forks a new process (a complete copy of the parent) for each connection, which if your site gets hit a lot will use unnecessarily large amounts of memory. We have already had reports from admins who have made the change saying they are experiencing performance degradation due to swapping. Step 2, applying the patch to util.c, should be sufficient to fix the problem. There is significantly less forking in Release 1.4 of the NCSA HTTP Daemon which will be released soon. Detecting a Break-in If the access log contains control characters, there is a chance that someone has tried to break into your system. If your server has died recently, they failed at least one attempt. And, if your server has not crashed and there are control characters in the access log you should assume your system has been compromised. In this case, servers which currently use the User Directive to run the server as "nobody", have limited the potential damage of an intruder to those commands which "nobody" may execute. Control Characters in the Access Log You've discovered control characters in your access log. How do you tell if was an intruder? If the beginning of the line containing the control characters begins sensibly (eg. machine name, and date (the GET periodically gets clobbered)) and ends with a series of control characters, it is a break-in attempt. If the beginning of the line starts with control characters (often nulls), this is a symptom of a collision problem that occurs when two children try to write to the access log simultaneously. This problem has only been seen with moderately to heavily loaded servers. (We are working to fix this in Release 1.4.) Other ways to Make Your Server More Secure A tutorial about running a secure server is available. We also recommend that the User Directive be used to run the server as "nobody". Patched Source and Binaries The patched source and precompiled binaries are available. We will also be correcting the source for previous releases, but we will NOT be generating binaries for previous releases. Elizabeth Frank efrank@ncsa.uiuc.eduEnd of Text Provided by NCSA
2. Install the following patch, which performs the functionality of strsubfirst (i.e., copy src followed by dest[start] into dest) without the use of a temporary buffer.
cut here |
*** util.c.bak Sat May 7 21:47:15 1994 --- util.c Thu Feb 16 04:17:07 1995 *************** *** 158,168 **** void strsubfirst(int start,char *dest, char *src) { ! char tmp[MAX_STRING_LEN]; ! strcpy(tmp,&dest[start]); ! strcpy(dest,src); ! strcpy(&dest[strlen(src)],tmp); } /* --- 158,174 ---- void strsubfirst(int start,char *dest, char *src) { ! int src_len, dest_len, i; ! if ((src_len=strlen(src))<start){ /** src "fits" in dest **/ ! for (i=0;dest[i]=src[i];i++); ! for (i=src_len;dest[i]=dest[i-src_len+start];i++); ! } ! else { /** src doesn't fit in dest **/ ! for (dest_len=strlen(dest),i=dest_len+src_len-start;i>=src_len;i--) ! dest[i] = dest[i-src_len+start]; ! for (i=0;i<src_len;i++) dest[i]=src[i]; ! } } /*
cut here |
After you apply this patch, recompile httpd, kill the current running process, and restart the new httpd.
The CERT Coordination Center thanks Steve Weeber, Carlos Varela, and Beth Frank for their support in responding to this problem.
Copyright 1995, 1996 Carnegie Mellon University.
Revision History
Sep. 23, 1997 Updated copyright statement Aug. 07, 1996 Information previously in the README was inserted into the advisory. Mar. 15, 1995 Sec. III - Replaced original Step 1 with text from NCSA. Updated NCSA contact information.