Discovered: August 4, 2001
Updated: February 13, 2007 11:37:00 AM
Also Known As: CodeRed.v3, CodeRed.C, CodeRed III, W32.Bady.C, CodeRed.F
Type: Trojan Horse, Worm
Systems Affected: Microsoft IIS
The worm propagates by installing itself into a random Web server using a known buffer overflow exploit, contained in the file Idq.dll. Only systems that have not been patched with the latest Microsoft IIS service packs can be affected.
Microsoft has published information on this vulnerability, and a Microsoft patch is available at
http://www.microsoft.com/technet/security/bulletin/MS01-033.asp. A cumulative patch for IIS, which includes the four patches released to date, is available at
http://www.microsoft.com/technet/security/bulletin/MS01-044.asp. System administrators are encouraged to apply the Microsoft patch to prevent the infection of this worm and other unauthorized access.
When a Web server is infected, the worm first calls its initialization routine, which identifies the base address of Kernel32.dll in the process address space of the IIS Server service. Next, it looks for the address of GetProcAddress and then starts to call GetProcAddress to access a set of API addresses:
LoadLibraryA
CreateThread
..
..
GetSystemTime
Then, the worm loads WS2_32.dll to access functions such as socket, closesocket, and WSAGetLastError. From User32.dll, it gets ExitWindowsEx, which the worm uses to reboot the system.
The main thread checks for two different markers.
- The first marker, "29A," controls the installation of the Trojan.VirtualRoot.
- The other marker is a semaphore named "CodeRedII." If the semaphore exists, the worm goes into an infinite sleep.
Next, the main thread checks the default language. If the default language is Chinese (either Taiwan or PRC), it creates 600 new threads; otherwise, it creates 300. These threads generate random IP addresses, which are used to search for new Web servers to infect. While these threads are working, the main thread copies Cmd.exe from the Windows NT \System folder to the following folders (if they exist).
C:\Inetpub\Scripts\Root.exe
D:\Inetpub\Scripts\Root.exe
C:\Progra~1\Common~1\System\MSADC\Root.exe
D:\Progra~1\Common~1\System\MSADC\Root.exe
If the Trojan that the worm drops has modified the registry key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\
Services\W3SVC\Parameters\Virtual Roots
and, by adding a few new keys and setting the user group to 217, a hacker can control the Web server by sending an HTTP GET request to run scripts/root.exe on the infected Web server.
The main thread sleeps for 48 hours on Chinese systems and for 24 hours on other systems. The 300 or 600 threads will still work and attempt to infect other systems. When the main thread wakes up from its sleep, it causes the computer to restart. Further, all the threads check whether the month is October or whether the year is 2002. If so, the computer is restarted.
The worm copies the command shell (Cmd.exe) to the default execution-enabled directory of the IIS Web server, allowing remote control. It also drops a file (which has its attributes set to Hidden, System, and Read Only) onto the root drive as either or both C:\Explorer.exe or D:\Explorer.exe. Norton AntiVirus identifies these Trojan files as Trojan.VirtualRoot. The worm carries this file inside itself in a packed format and unpacks it when it is dropped.
The infection lasts 24 or 48 hours, and then the computer is restarted. However, the same computer can be re-infected until it is patched with the latest update from Microsoft.
If the month is October or if the year is 2002, the computer will also be restarted. When the computer is restarted, Trojan.VirtualRoot is executed when the system attempts to execute Explorer.exe (due to the way that Windows NT resolves or searches program paths when executing a program). The Trojan (C:\Explorer.exe) sleeps for a few minutes and resets these keys to assure that the registry keys are modified.
NOTE: After a restart, the memory-resident worm will be inactive, meaning that, on an infected system that has been restarted, the worm will not attempt to spread itself to other machines unless it happens to get re-infected.
The Trojan also alters the registry key:
HKEY_LOCAL_MACHINE\Software\Microsoft\
Windows NT\CurrentVersion\Winlogon
so that the value:
SFCDisable
is set to:
0xFFFFFF9D
This disables the System File Checker (SFC).
NOTES:
- If you are running Microsoft FrontPage or a similar program used to design Web pages, IIS may be installed on your computer.
- For additional information, including the string that is added to the IIS log files, refer to the information on the CERT Coordination Center page:http://www.cert.org/incident_notes/IN-2001-08.html
Symantec ManHunt
Symantec Manhunt 2.2 detects the CodeRed Worm with its Anomaly Engine as "HTTP Malformed URL," and if the custom rule update is applied with the latest set of snort rules, it will be detected as "HTTP_IIS_ISAPI_Extension" under Hybrid Mode.
Recommendations
Symantec Security Response encourages all users and administrators to adhere to the following basic security "best practices":
- Use a firewall to block all incoming connections from the Internet to services that should not be publicly available. By default, you should deny all incoming connections and only allow services you explicitly want to offer to the outside world.
- Enforce a password policy. Complex passwords make it difficult to crack password files on compromised computers. This helps to prevent or limit damage when a computer is compromised.
- Ensure that programs and users of the computer use the lowest level of privileges necessary to complete a task. When prompted for a root or UAC password, ensure that the program asking for administration-level access is a legitimate application.
- Disable AutoPlay to prevent the automatic launching of executable files on network and removable drives, and disconnect the drives when not required. If write access is not required, enable read-only mode if the option is available.
- Turn off file sharing if not needed. If file sharing is required, use ACLs and password protection to limit access. Disable anonymous access to shared folders. Grant access only to user accounts with strong passwords to folders that must be shared.
- Turn off and remove unnecessary services. By default, many operating systems install auxiliary services that are not critical. These services are avenues of attack. If they are removed, threats have less avenues of attack.
- If a threat exploits one or more network services, disable, or block access to, those services until a patch is applied.
- Always keep your patch levels up-to-date, especially on computers that host public services and are accessible through the firewall, such as HTTP, FTP, mail, and DNS services.
- Configure your email server to block or remove email that contains file attachments that are commonly used to spread threats, such as .vbs, .bat, .exe, .pif and .scr files.
- Isolate compromised computers quickly to prevent threats from spreading further. Perform a forensic analysis and restore the computers using trusted media.
- Train employees not to open attachments unless they are expecting them. Also, do not execute software that is downloaded from the Internet unless it has been scanned for viruses. Simply visiting a compromised Web site can cause infection if certain browser vulnerabilities are not patched.
- If Bluetooth is not required for mobile devices, it should be turned off. If you require its use, ensure that the device's visibility is set to "Hidden" so that it cannot be scanned by other Bluetooth devices. If device pairing must be used, ensure that all devices are set to "Unauthorized", requiring authorization for each connection request. Do not accept applications that are unsigned or sent from unknown sources.
- For further information on the terms used in this document, please refer to the Security Response glossary.
Writeup By: Peter Szor, Eric Chien