Malspec

Famous hacks, and how they were fixed.

Worms & malwareIncident report

How WannaCry was slowed by a domain name and stopped by a patch

The 2017 ransomware worm spread through an unpatched Windows flaw; a kill-switch domain slowed it and the MS17-010 patch closed the hole.

Illustration: ransomware spreads along network links, locking computers on the left, until a kill switch stops it; patched computers on the right stay safe behind green shields.

On 12 May 2017 a piece of ransomware called WannaCry spread across the world in a single day, locking files on hospital computers, factory systems and office PCs and demanding bitcoin to unlock them. It got in through a Windows flaw that Microsoft had already patched two months earlier. Its spread was slowed that afternoon by a researcher who registered a web domain for about $11, and it was finished off by the same thing that would have prevented it: the patch.

When: May 2017 Hit: Roughly 200,000 computers in about 150 countries, by estimates at the time Way in: A Windows file-sharing flaw (SMBv1), through a leaked exploit called EternalBlue Found by: Victims worldwide on the morning of 12 May, then security researchers Fixed by: Microsoft's MS17-010 patch, and a kill-switch domain registered by researcher Marcus Hutchins Time to fix: The patch came two months before the attack; the kill switch took hours

What happened

WannaCry was ransomware: it encrypted a computer's files and showed a message asking for $300 in bitcoin, rising to $600 after three days. That part was not new. What made WannaCry different was that it was also a worm. Once it was on one computer, it scanned for other Windows machines on the same network and on the internet, and copied itself to any that had a particular hole open. Nobody had to click anything.

The outbreak began in the morning, European time, on Friday 12 May 2017 and reached companies, governments and hospitals in dozens of countries within hours. In the UK, the National Audit Office later found that at least 81 of the 236 trusts that run NHS hospitals in England were disrupted, along with hundreds of GP practices and other NHS organisations, and estimated that around 19,000 appointments were cancelled. Ambulances were diverted from some affected hospitals.

Elsewhere, carmakers paused production lines, a Spanish telecoms company sent staff home, and railway and logistics companies reported infected systems.

How it worked

Windows computers share files and printers using a protocol called SMB. Its oldest version, SMBv1, had a flaw that let a specially crafted message run code on the receiving machine. Microsoft fixed it in March 2017 in a security update called MS17-010.

A month later, a group calling itself the Shadow Brokers published a collection of hacking tools online. Among them was an exploit, nicknamed EternalBlue, that used exactly this SMB flaw. WannaCry's authors built that exploit into their ransomware so it could move from machine to machine on its own.

Any Windows computer that had SMB reachable and had not installed MS17-010 was exposed. Many organisations had not yet applied the March update. Others still ran Windows XP and similar versions that Microsoft no longer supported, so no patch had been offered to them at all. The NAO found that every NHS organisation infected had unpatched or unsupported Windows systems.

Inside the code was an odd check. Before doing anything, WannaCry tried to contact a long, meaningless web address that nobody had registered. If the address did not answer, the worm carried on. If it did answer, the worm stopped.

How it was discovered

Nobody found WannaCry before it struck. It announced itself: on the morning of 12 May, staff in hospitals, offices and factories turned to their screens and found a red ransom note instead of their work. Within hours, national cyber security centres and antivirus companies were collecting copies from victims.

How to stop it was discovered by reading those copies. Marcus Hutchins, a British researcher who blogged as MalwareTech, ran a sample in a lab and watched its network traffic. Before encrypting anything, it tried to reach a long, meaningless web address that nobody owned. Malware often contacts addresses like that to report back, so he registered it for about $11 to see where infections were coming from.

Only afterwards did he and other researchers realise what they had done. The worm was checking whether that address answered. Once it did, new copies stopped themselves instead of spreading. A step meant to track the outbreak had switched it off.

The hole it used had been found earlier. Microsoft fixed it in March 2017 without publicly naming who reported it, and the exploit became public when the Shadow Brokers posted it in April.

The timeline

2017-03-14 · Microsoft releases MS17-010

A routine monthly security update fixes the SMBv1 flaw on Windows versions that Microsoft still supports.

2017-04-14 · The EternalBlue exploit is published

The Shadow Brokers post a batch of hacking tools, including a working exploit for the flaw MS17-010 had fixed. Anyone can now attack unpatched machines.

2017-05-12 · WannaCry spreads, and a researcher finds the kill switch

Infections start in the morning in Europe and spread worldwide. That afternoon, Marcus Hutchins, a young British researcher who wrote about malware online as MalwareTech, spots the unregistered address in a sample and registers it to track infections. New infections start stopping themselves, because the worm now finds the address answering.

2017-05-13 · Microsoft patches Windows XP and other unsupported systems

In an unusual step, Microsoft releases emergency updates for Windows XP, Windows 8 and Windows Server 2003, versions it had stopped supporting, so that every machine has a fix.

How it was fixed

The fix came in two layers. The kill switch slowed new infections within hours, but it was fragile: it depended on that domain staying online, and copies of the worm with the check changed or removed could ignore it. Hutchins and others worked with internet companies to keep the domain reachable under heavy traffic.

The lasting fix was the patch. Installing MS17-010, or the emergency updates for older systems, closed the hole the worm used. Turning off SMBv1 and blocking SMB traffic from the internet at the network edge closed it too. Organisations that already had the March update were largely untouched.

Computers that had already been encrypted were a harder problem. Some researchers found ways to recover keys on certain Windows versions under narrow conditions, but most victims restored from backups or rebuilt their machines.

In December 2017 the US and UK governments publicly attributed WannaCry to North Korea. In September 2018 the US Department of Justice charged a North Korean programmer, Park Jin Hyok, over WannaCry and other attacks.

What changed after

In the NHS, the NAO and a later review by NHS England's chief information officer found that the trusts had no clear plan for a national cyber incident and had not acted on earlier warnings to patch. The NHS invested in a security operations centre, agreed a deal with Microsoft to keep Windows up to date across the service, and made patching critical updates a requirement.

Across the industry, WannaCry sped up the retirement of SMBv1, which Microsoft now leaves off by default in new Windows installations. It also strengthened the case for patching quickly: the gap between a fix being published and attackers using the flaw had shrunk to weeks.

The Shadow Brokers leak added urgency to the debate over governments keeping software flaws secret rather than reporting them to vendors.

Lessons that still apply

  • Patch on a schedule you can keep. Most WannaCry victims were hit by a flaw with a fix available for two months. Critical updates should go out in days, not quarters.
  • Retire what can't be patched. Unsupported systems will eventually meet a flaw that never gets fixed. Isolate them from the network if they cannot be replaced.
  • Turn off what you don't use. Old protocols like SMBv1 were rarely needed, but they were on by default and they were the way in.
  • Keep offline backups. Organisations with tested backups that ransomware could not reach recovered far faster.

Sources

The fix → A domain bought for about $11 slowed it in an afternoon, and a patch two months old would have stopped it.

Share this