The Code Red computer worm was a memory-resident worm that spread in July 2001 by exploiting a buffer overflow in Microsoft IIS web servers. Its second version infected more than 250,000 systems in nine hours and over 350,000 in a day, defaced websites, and caused an estimated $2.6 billion in damage.
Key takeaways
- Code Red spread through a known, already-patched IIS vulnerability — patching was the fix.
- Its second version infected more than 250,000 systems in nine hours, showing how fast worms scale.
- The worm taught the industry to patch fast, segment networks and watch for scanning traffic.
On July 12, 2001, a new worm began spreading across the internet. A week later it had infected hundreds of thousands of servers, slowed the internet itself, and forced the White House to change how its website was routed. It was called Code Red, and it changed how the industry thought about patching.
What was the Code Red worm?
Code Red was a memory-resident computer worm that exploited a buffer overflow in Microsoft Internet Information Services (IIS) web servers. It infected servers running IIS 4.0 and 5.0 on Windows NT 4.0 and Windows 2000, and it spread by scanning the internet for other vulnerable servers.
Unlike a virus, a worm copies itself to other machines without needing a host file or a user to open anything. Code Red went further: it never wrote itself to disk at all. It lived only in memory, which made it harder to find and meant a reboot cleared the infection — until the server was scanned again.
The name came from the drink, not the damage. Researchers Ryan Permeh and Marc Maiffret at eEye Digital Security, who analyzed the worm through the night of July 13, named it after the Code Red Mountain Dew they were drinking, according to CAIDA's analysis of Code-Red.
How did Code Red work?
Code Red sent its code as an HTTP request to a vulnerable server. The request exploited a buffer overflow in the IIS indexing service filter, known as the .ida vulnerability, which let the worm run code with system-level privileges on the server.
The vulnerability had been disclosed by eEye on June 18, 2001, and Microsoft had released a patch. But a month later, hundreds of thousands of servers were still unpatched, and Code Red turned that delay into a global incident. The lesson was blunt: a known vulnerability with a patch is still dangerous until the patch is installed.
Once inside, the worm checked for a file called C:\Notworm. If it existed, the worm thread went into an infinite sleep — a crude safety valve that administrators later used as a defense. Otherwise it created new threads to scan random IP addresses for more vulnerable servers.
What happened, day by day?
Code Red arrived in three waves. The first version spread slowly because of a bug in its random-number generator; the second fixed that bug and exploded; the third, Code Red II, exploited the same flaw but carried a backdoor.
| Date | Event | What happened |
|---|---|---|
| June 18, 2001 | Vulnerability disclosed | eEye discloses the IIS .ida buffer overflow; Microsoft releases a patch. |
| July 12, 2001 | Code Red v1 appears | First worm begins infecting unpatched IIS servers, spreading slowly. |
| July 13, 2001 | Analysis overnight | eEye researchers disassemble the worm and name it Code Red. |
| July 19, 2001 | Code Red v2 appears | Random-seed variant spreads fast: 250,000+ systems in nine hours. |
| July 20, 2001 | Attack phase begins | Infected servers flood the White House website; the White House changes its routing. |
| August 4, 2001 | Code Red II appears | New worm, same flaw, adds a backdoor that survives reboots. |
The first version used a static seed for its random-number generator, so every infected machine probed the same list of addresses, and growth was linear. The July 19 version used a random seed, so each machine probed different addresses, and growth turned exponential.
How fast did Code Red spread?
Extremely fast. The second version infected more than 250,000 systems in just nine hours, according to the SANS GIAC paper on the worm. Within 24 hours it had infected over 350,000 machines, and later estimates put the total above 500,000 servers.
That speed is what made Code Red historic. Earlier worms took days or weeks to reach that scale. Code Red showed that a worm exploiting a common, unpatched service could infect a large share of the vulnerable population in a single working day — faster than most organizations could react.
The flood of scanning traffic itself became a denial-of-service attack. The uncontrolled growth in scanning slowed the internet, caused widespread outages, and knocked out servers at companies including the Associated Press and FedEx, as contemporary reporting described.
What did Code Red do to infected servers?
Code Red had two payloads, and they ran on a calendar. Before the 20th of each month it spread; from the 20th to the end of the month it attacked. That schedule was written into the worm's code.
- Website defacement: on English-language systems, it replaced web pages with the text "Hacked by Chinese".
- Denial of service: from the 20th of the month, infected machines flooded the White House website (www.whitehouse.gov) with traffic.
- Scanning flood: the sheer volume of probes slowed networks and caused outages far beyond the infected servers themselves.
The White House responded to the flooding threat by changing the address of its website, which blunted the attack. Code Red II, which arrived on August 4, was different: it installed a backdoor that gave attackers root access and survived reboots, making it more dangerous for the servers it infected.
How much damage did Code Red cause?
Damage from Code Red and its variants was estimated at about $2.6 billion, according to Computer Economics figures cited in contemporary reporting. That total covered outages, lost sales, cleanup and the cost of emergency patching.
The damage was not evenly spread. Qwest, a telecommunications company with about 360,000 DSL customers in the western and midwestern US, faced demands to refund customers after service interruptions caused by the worm, and the Washington state Attorney General asked Qwest to compensate customers who said the outage cost them thousands of dollars in lost sales.
Those figures are estimates, and they count only reported costs. The indirect damage — trust lost, projects delayed, staff diverted to emergency patching — was never fully counted. Learn how to spot a compromised machine in our guide to how to know if your phone is hacked, which covers the same warning signs on personal devices.
How was Code Red different from earlier worms?
Code Red was the first significant Windows worm, and the first to be completely memory resident. Earlier famous worms, such as the Morris worm of 1988, infected about 6,000 machines; Code Red infected a hundred times that many in a day.
| Worm | Year | Systems infected | Key difference |
|---|---|---|---|
| Morris worm | 1988 | About 6,000 | First major internet worm; spread via Unix services |
| Code Red | 2001 | 350,000+ in 24 hours | First major Windows worm; memory resident |
| SQL Slammer | 2003 | About 75,000 in 10 minutes | Even faster; single-packet worm |
| Conficker | 2008 | Millions | Used many propagation methods at once |
The Morris worm and SQL Slammer figures come from the same Stanford and Berkeley course materials that describe Code Red's spread; treat them as approximate, because counting worm infections in real time was — and still is — imprecise. What is certain is the trend: each generation spread faster than the last.
What did Code Red teach us?
Code Red taught the industry five lessons that still apply. The first is the most important: patch quickly. The vulnerability was known and patched a month before the worm arrived, yet hundreds of thousands of servers were still vulnerable.
The other lessons follow from the first. Reduce exposure by not putting a service on the internet unless it needs to be there. Watch for scanning traffic, because a sudden surge in probes is often the first sign of a worm. Segment networks so one infected server cannot reach them all. And plan for the attack phase, not just the infection: Code Red's calendar-driven denial-of-service attack was visible in its code before it fired.
How was Code Red stopped?
Code Red was not stopped by a single fix. It faded because administrators patched IIS, rebooted infected servers to clear the memory-resident worm, and blocked the scanning traffic — and because the worm's own code included stop dates.
The first version was programmed to go into an infinite sleep mode on July 28. Code Red II was programmed to die on October 1, 2001. Those dates limited the original worms, but the underlying lesson was about process, not luck: the servers that were patched before July 12 were never infected at all.
Modern defenses follow the same logic. Keep your operating system and applications updated, keep native antivirus and anti-malware protections active as CISA recommends, and check your public services with our free security headers checker to see what the internet can reach.
Could a Code Red happen today?
Yes, in a different form. The specific IIS flaw is long gone, but the pattern repeats: an unpatched, internet-facing service, a public exploit, and a worm that spreads faster than organizations can patch. Recent incidents have followed exactly that script with different software.
What has changed is the speed. SQL Slammer in 2003 infected about 75,000 systems in ten minutes. Modern ransomware worms can move across a network in minutes. The defense has not changed much either: patch fast, reduce exposure, monitor for scanning, and segment your network. If you manage a small business, our small business cybersecurity checklist covers those controls alongside backups and updates.
The bottom line
Code Red was not the most damaging worm in history, but it was the wake-up call. It proved that a known vulnerability, left unpatched for a month, could become a global incident in a single day.
The fix was never complicated: install the patch, reboot the server, and close the services you do not need. Check what your own site exposes today with the free SSL checker — and patch it before someone else finds it first.
Frequently asked questions
What was the Code Red worm?
Code Red was a computer worm that spread in July 2001 by exploiting a buffer overflow in Microsoft Internet Information Services web servers. It lived only in memory, defaced some websites, and launched denial-of-service attacks.
When did the Code Red worm happen?
The first version appeared on July 12, 2001. A faster second version appeared on July 19, 2001, and a related worm, Code Red II, appeared on August 4, 2001.
How many computers did Code Red infect?
The second version infected more than 250,000 systems in nine hours, according to the SANS GIAC paper. Within 24 hours it had infected over 350,000 machines, and estimates of the total infected run above 500,000 servers.
How much damage did Code Red cause?
Damage from Code Red and its variants was estimated at about $2.6 billion, according to Computer Economics figures cited in contemporary reporting. The damage came from outages, defaced websites and the cost of cleanup.
What did Code Red do to infected computers?
It defaced some websites with the phrase Hacked by Chinese, scanned the internet for other vulnerable servers, and, from the 20th of each month, launched a denial-of-service attack against the White House website.
Is Code Red still a threat today?
No. The vulnerability it exploited was in old versions of Microsoft IIS, and modern systems are not vulnerable to it. But the same pattern — an unpatched, internet-facing service exploited at scale — still causes major incidents today.
Why was it called Code Red?
Researchers Ryan Permeh and Marc Maiffret at eEye Digital Security named it after the Code Red Mountain Dew they were drinking while they analyzed it through the night. The name has nothing to do with the worm's payload.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against CAIDA's analysis of Code Red, the SANS GIAC paper on the worm, and contemporary reporting of its spread and damage.
How we write and fact-check →