This vulnerability could allow an attacker, from a remote location, to gain full system level access to any server that is running a default installation of Windows NT 4.0, Windows 2000, or Windows XP and using the Microsoft Internet Information Services (IIS) Web server software.
The vulnerability lies within the code that allows a Web server to interact with Microsoft Indexing Service functionality, which is installed by default on all versions of IIS. The problem lies in the fact that the .ida (Indexing Service) ISAPI filter does not perform proper "bounds checking" on user inputted buffers and therefore is susceptible to a buffer overflow attack.
Attackers that leverage this vulnerability can perform any desired system level action, including but not limited to, installing and running programs, manipulating web server content, adding, changing or deleting files and even possibly using the compromised system to launch additional attacks directed against other systems.
This vulnerability was discovered by Riley Hassell of eEye Digital Security (http://www.eeye.com).
IP is the basis by which data is sent from one computer to another across the Internet.
IP is a connectionless protocol that does not assume reliability from the lower layers of the TCP/IP protocol stack. IP does not provide reliability, flow control or error recovery, these functions must be supplied by protocols at a higher layer. This means that packets sent by IP may become lost, or even arrive out of ordered.
For more information on IP refer to:While IP is concerned with the actual delivery of the data TCP is concerned keeping track of the individual units of data that comprise a complete message.
TCP is a connection-oriented protocol complete with error recovery, flow control and reliability. This ensures that a persistent connection will be established between the client and server until all data has been successfully sent and received.
For more information on TCP refer to:HTTP (HyperText Transfer Protocol) is one of the most widely used protocols currently in use throughout the World Wide Web and is based on request-response activity. In the case of the Internet a client application, usually a browser, establishes a connection to a server and sends a request in the form of a request method. The server responds with a status line including the message's protocol version and a success or error code, followed by a message containing server information, entity information and possibly body content.
The HTTP request-response transaction is simply divided into four steps:In most circumstances, including that of the Internet, HTTP travels over TCP connections. The default is TCP port 80 but any port (as long as it is not already in use) can be used. It is possible for HTTP to be transported over other underling protocols, but it does require a reliable connection to be established.
For more information on HTTP refer to:The Indexing service in Internet Information Services (IIS) provides search capabilities across both Intranet and Internet web sites. It can extract content from files and construct an indexed catalog to facilitate efficient and rapid searching. Users are able to enter search criteria into a prepared web page and have the results displayed back to them.
While there is no variant in the vulnerability itself there have been a few unique exploits that take advantage of this security hole.
Code Red II used the same buffer overflow to compromise systems but had a much different payload. This variant was more deadly, it required more than a reboot to clean the system, and instead of defacing web sites and launching denial of service attacks it installed a remote backdoor program. There was also greater care taken with the random subnet generation routine which increase the spread of infection.
The Code Blue worm behaves slightly different. It uploads the worm file from another infected machine, whereas Code Red would download and impose itself on the machine. The worm is spread through a single .dll and is execute via a .exe program. Code Blue also patches the IIS buffer overflow vulnerability to prevent re-infection.
Code Green is like a vigilantly variant of Code Red. This worm will actively seek out systems infected with Code Red, clean the infection, and patch the system to prevent re-infection. This is a very interesting idea, although it would probably cause more havoc then good.
Microsoft's IIS web server installs several Internet Services Application Programming Interface (ISAPI) extensions by default. These extensions consist of dynamically linked libraries (dll) which enable developers to extend the functionality beyond what is natively provided by IIS. It is one of the ISAPI extensions, idq.dll, which is responsible for this vulnerability. The idq.dll extension has two functions:
The exploit occurs because the idq.dll contains an unchecked buffer in a section of code that handles the input of the URLs. This means that the idq.dll does not perform proper input validation and blindly write all data sent by the user to the buffer that was created by the program. If the data sent by the user is greater than that expected by the program (that which can be stored in the buffer) then the data can overflow into adjacent buffers and overwrite or corrupt the data held within them. This additional data usually contains code designed by the attacker to trigger specific actions, in effect sending new instructions to the target computer. Using this technique it is possible for an attacker to establish a HTTP session with a server and send an abnormally large request (with additionally designed code) that would result in a buffer overflow, executing the code of the attackers choice.
It is important to note that the buffer overflow occurs before any indexing functionality is actually requested. This means that even though idq.dll is a component of Indexing Service, the service would not need to be running in order for an attacker to exploit this vulnerability. As long as the script mapping for .idq or .ida files were present, and the attacker could establish a web session, it would be possible for the attacker to exploit this vulnerability.
Since the idq.dll runs in the local system context, exploiting this vulnerability would give the attacker complete control of the server, allowing the attacker to execute any code/commands at the operating system level.
This vulnerability has been associated with one of, if not the most devastating Internet worms ever released into the wild. The now infamous 'Code Red' worm made headlines when it began to wreak havoc throughout the Internet in such a short period of time starting on July 12, 2001. There have been a few variants of this worm since the release of the original. Although each use the same vulnerability described previously to exploit systems some differences have been discovered in the code. Each variant is briefly discussed below.
CRv1 was first discovered in the wild on July 12, 2001. After successful infection the worm would check the date of the system. If the date were between the 1st and the 20th the worm would generate a random list of IP addresses and try to infect other systems on that list. If the date were between the 20th and the 28th the worm would launch a Denial of Service attack against www.whitehouse.gov. This worm however had one small imperfection, it used a static seed when generating the random list of IP addresses. This inhibited the worm from spreading very quickly because each infected machine would only probe machines that were either already infected or that were not vulnerable.
CRv2 was first discovered on July 20, 2001. It has almost identical code to that of CRv1 with one slight difference, the static seed was replaced with a random seed. So now the list of randomly generated IP addresses were truly random and the propagation of the worm was much quicker. It was reported that over 359,000 systems were infected within the first 14 hours.
CRv2 was also found to effect additional devices with web interfaces, such as routers, switches, and printers. Although these devices were not infected with the worm they were caused to crash or reboot.
CRv1 and CRv2 are both memory resident and can be removed by simply rebooted the infected system. There is however a good chance the system would be re-infected if the appropriate patches were not applied.
Code Red II was first discovered on August 4, 2001. This worm was written with entirely new code and has no association with the original worm. When Code Red II infects a system it first determines if that system had previously been infected. If not the worm sets up a trojan backdoor into the system, then after 1 day reboots the system. Code Red II is not memory resident like the CRv1 and CRv2, so a reboot will not remove the worm. After the reboot the worm begins to spread. It generates a list of random IP addresses to target, using a slightly different technique then either CRv1 or Crv2.
The Payload of the worm is also different. It does not deface web pages or launch attacks it does something which is much more serious. It installs a mechanism for remote administrator level access to the system. This would allow any code to be executed on the target machine.
***Note that the remainder of the paper will deal with Code Red Version 1.To perform this exploit manually an attacker could make a TCP/IP connection to the server on port 80 via a Telnet or NetCat session, or even by using an Internet Browser. The attacker could then enter the HTTP GET request using the same overflow string seen in the Code Red worm itself. The following example show how this could be accomplished using a Telent session.
C:\ telnet www.targetsystem.com 80
GET/default.ida?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN%u9090%u6858%ucb
d3%u7801%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801%u9090%u
9090%u8190%u00c3%u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a HTTP/1.0
This string could also be used as a URL inside the browser, just remove the GET and the HTTP/1.0. Those are taken care of by the browser
An extremely detailed step-by-step analysis of the original Code Red worm has previously been conducted by Ryan Permeh and Marc Maiffret of eEye Digital Security. Instead of recreating their great work much of the following information will be taken from their analysis. Full details of the eEye analysis can be found at http://www.eeye.com/.
Since the worm seems to contain three distinct actions (system infection, web page hack, and denial of service attack against www.whitehouse.gov) this analysis will be broken into three sections, each offering a detailed explanation of the worm's activities.
| From kernel32.dll | From infocomm.dll | from WS2_32.dll |
|
GetSystemTime CreateThread CreateFileA Sleep GetSystemDefaultLangID VirtualProtect |
TcpSockSend |
socket connect send recv closesocket |
The worm stores the base address of w3svc.dll which it will later use to potentially deface the infected website.

The diagram above illustrates, from a very high level, how a typical company would have their web server connected to the Internet (in this case an IIS web server). People from all over the world would then be able to connect to this web server using a standard Internet browser. To allow for these connections the company would have to open TCP port 80 (HTTP default port) on their corporate firewall. Simple yet secure right. Not quite, there is one huge problem. The Code Red exploit also travels over TCP port 80. The corporate firewall in this case offers absolutely no protection from the Code Red worm.

It is very common to see an organization focus less of their security efforts on their internal networks, this can prove to be a huge oversight. In the case illustrated above a default Windows 2000 server (residing on a mobile laptop) was attached to the internal network. This laptop could have been infected with Code Red through a home connection and later connected to the corporate WAN. At this point the worm can begin to wreak its havoc infecting all vulnerable machines in sight, internal and external.
A full packet capture of the Code Red worm can be found in Appendix A. This capture illustrates the complete session of TCP/IP packets that a single infected system would send when trying to replicate and infect other systems.
Signature based IDS look for patterns within the packets to identify possible malicious activity. The following signature can be used, and is used by many IDS systems, to identify Code Red activity. This signature is specific to CRv1 and CRv2, the signature for Code Red II is slightly different.
/default.ida?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNN%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801
%u9090%u6858%ucbd3%u7801%u9090%u9090%u8190%u00c3%u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a HTTP/1.0
The following entry could be found in an IIS Web Server log if the system was probed by the Code Red worm (CRv1 and/or CRv2). It is important to note that this entry would be the same whether the system was infected or not. Therefore it is impossible to tell strictly of the basis of IIS logs if Code Red has infected the system. However, if entries like this are found and it is known that the system has not been patched for this vulnerability there is a very good chance that the system has been infected.
"GET default.ida?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNN%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801%u909
0%u6858%ucbd3%u7801%u9090%u9090%u8190%u00c3%u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a
HTTP/1.0" 404 10100 "-" "-"
There are other possible means by which to detect the presence of Code Red on a network.
The system administrator may notice that the server is not performing as usual. Code Red may be using enough CPU cycles to impact the server's normal routine prompting the system administrator to investigate further.
A few techniques the administrator could employ are:It may also be possible to use the auditing features of the corporate proxy server, the Internet firewall, or the boarder router to determine if any abnormal activity is taking place. These logs contain a wealth of information but are seldom reviewed.
Now that the potential destructive capabilities of this worm have become evident, it is important to recognize some of the ways in which to protect against them. Many of the common security components or devices are not adequate to deal with this threat. Take a firewall for example. Since the worm travels over TCP port 80 traditional firewalls are not able to filter the traffic from reaching the web servers, lest the administrator wants to stop all valid web traffic as well.
IDS sensors are able to detect the signature of the worm but the actions they can take are limited. In the most extreme cases some IDS network sensors have the capability to reset connections. This will still not prevent the infection of a vulnerable system due to the fact that exploit only needs to send one HTTP session for the worm to spread, this eliminates the possibility of the IDS resetting the connection before the server receives the malicious payload.
One of the only ways to truly prevent this worm from infecting a system is to make sure all applicable security patches are applied, a practice all to uncommon in the industry.
These patches can be found at the following locations.Another good means by which to proactively protect your systems is through OS and application hardening. Operating System (OS) hardening simply pertains to disabling services that are not needed for the system to perform its basic functions. As an example take a default installation of Windows 2000 Server. Some services, such as SNMP will be enabled and started automatically during boot up. Most times these services are not needed and should be disabled. Otherwise your system can be unnecessarily exposed. The same actions can be taken with applications. In this case the IIS web server has many additional features installed and enabled by default, one of which is the Indexing service. With minimal configuration changes one can make their web server, or other application much more secure. Detailed hardening guidelines for both IIS and Windows 2000 (among other things) can be purchased from SANS.
It is also good security practice to routinely conduct vulnerability assessments against ones own systems. Vulnerability assessments are a proactive process in which the system administrator or local security officer will simulate real attacks against a system to determine where that system's exposures are. This offers a means to keep current with patches and helps ensure that the overall risks are minimized. There are many good tools freely available to conduct such assessments, some of which exclusively look for Code Red vulnerabilities.
|
|
I have 14 years experience in IT security, and SANS is by far the best technical security conferences I have attended.
-Tom Davis, Indiana University
Absolutely wonderful, both in presentation and content
-Don Seymour, TerpSys
The quality of a SANS course is "exceptional" and the instructors are true experts with real experience.
-Todd Coston, Kern Community College District
Wow! It's an incident handler's Christmas morning, tools, tools, tools. Very Applicable!
-Todd Davis, Symantec
I learned techniques and processes that I can use as soon as I walk back into work.
-Michael Marrion