EternalBlue (WannaCry)
EternalBlue was a flaw in Windows' old SMBv1 file sharing that let anyone who could reach port 445 run code with full rights. In May 2017 the WannaCry ransomware used it to spread between computers on its own.
- Affected
- Windows Vista to Windows 10 1607 and Server 2008 to 2016 without MS17-010
- Fixed in
- MS17-010 (March 2017)
- Published
- 2017-03-17
- Known exploited since
- 2022-02-10
What EternalBlue is
SMBv1 mishandled specially crafted network packets. An attacker who could reach port 445 could run code as the system, with no user action, which is what lets a worm move from computer to computer.
Spot it in the logs
Where did it start?
Inbound SMBv1 connections to port 445 from machines that have no reason to make them, and an infected machine scanning the local network on ports 137, 138, 139 and 445. WannaCry ran a service named mssecsvc2.0 and dropped tasksche.exe.
How the attack works
- 1An infected PC scans the network on port 445
- 2Another PC's SMBv1 mishandles a crafted packet
- 3The worm runs there with full system rights
- 4It encrypts files and scans for the next machine
Why EternalBlue and WannaCry were so severe
NVD scores CVE-2017-0144 at 8.8 (high) on CVSS 3.1 and 9.3 on the older CVSS 2 scale. Microsoft rated its fix, MS17-010, Critical for every supported version of Windows. The sources differ on one detail: NVD's 3.1 score assumes the attacker needs a low-privilege account, while Microsoft's bulletin says that in most situations an attacker with no account at all could send the crafted packet.
The flaw sat in SMBv1, the oldest version of Server Message Block, the protocol Windows uses to share files and printers. MS17-010 lists every Windows release from Vista and Server 2008 to Windows 10 version 1607 and Server 2016, and Microsoft later shipped fixes for Windows XP, Windows 8 and Server 2003, which were already out of support. Microsoft only stopped installing SMBv1 by default with the Windows 10 Fall Creators Update (version 1709) and Windows Server 2019, and Windows 10 Home and Pro still keep it. An attacker who succeeded got code running in the kernel, the core of the operating system: Microsoft found that WannaCry's kernel-level code appeared to be copied from DOUBLEPULSAR, a publicly known backdoor.
What made it dangerous was the combination. No user had to click anything, so a worm could jump from machine to machine on its own. WannaCry scanned its local network and random internet addresses, so one infected laptop could reach every unpatched machine it could talk to on port 445. The machines hardest to patch were the old ones: the UK National Audit Office found that the infected NHS organisations ran unpatched or unsupported Windows.
Check your systems
- Is SMBv1 on?
Get-SmbServerConfiguration | Select-Object EnableSMB1Protocol - Is the SMBv1 feature installed?
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
How to detect EternalBlue and WannaCry
Look for two things: machines that still accept SMBv1, and the network and file traces WannaCry leaves behind.
- Find who still uses SMBv1Check whether SMBv1 is on with `Get-SmbServerConfiguration | Select EnableSMB1Protocol` or `Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol`. Before you remove it, turn on SMBv1 auditing with `Set-SmbServerConfiguration -AuditSmb1Access $true`. Each SMBv1 connection then writes event ID 3000 to the Microsoft-Windows-SMBServer/Audit log, which tells you which old devices still depend on it.
- Scan for missing MS17-010Vulnerability scanners check whether the update is installed. The Nmap script smb-vuln-ms17-010 checks a host without exploiting it: it sends one SMB transaction that does not exploit anything and reads the error code, where STATUS_INSUFF_SERVER_RESOURCES means the host is likely unpatched. Scan only networks you are allowed to test.
- Watch port 445 for worm scanningAn infected machine connects to many addresses on TCP port 445, on its own subnet and at random internet addresses. CISA lists UDP 137 and 138 and TCP 139 and 445 as the ports involved. Talos published Snort rules 41978, 42329 to 42332 and 42340 for the threat, and Malwarebytes saw the kill switch DNS lookup followed by SMB Trans2 traffic in packet captures.
- Log lookups of the kill switch domainThe original sample looks up iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea[.]com before it does anything else. A machine that queries this name has run WannaCry. Do not block the domain: CISA and Microsoft both say a successful connection makes the malware stop, and Microsoft notes it does not use a proxy, so networks behind one may need an internal DNS record.
- Check hosts for WannaCry files and settingsLook for a service named mssecsvc2.0 shown as "Microsoft Security Center (2.0) Service" with the arguments `-m security`, the file C:\Windows\tasksche.exe, the registry key HKLM\SOFTWARE\WanaCrypt0r, a TaskData\Tor folder holding tor.exe and taskhsvc.exe, @WanaDecryptor@.exe and files ending in .WNCRY. CISA also lists the mutex Global\MsWinZonesCacheCounterMutexA and the YARA rules Wanna_Cry_Ransomware_Generic and MS17_010_WanaCry_worm. Microsoft Defender names it Ransom:Win32/WannaCrypt.
- Alert on backup deletion commandsMicrosoft's analysis shows WannaCry running `vssadmin delete shadows /all /quiet`, `wmic shadowcopy delete`, `bcdedit` commands that turn off recovery, and `wbadmin delete catalog -quiet`. These commands rarely run in normal work, so an alert on them in process creation logs or your endpoint tool is a cheap way to catch the moment before files are lost.
Check a log line
Search the logs yourself
How did the ransomware start, and how did it reach the next machine?
Fix it, in this order
- 1Cut off the infected PCIsolate it first, so it cannot reach anything else.
- 2Close the door everywhere elseApply MS17-010, or disable SMBv1 where the update must wait. Keep file sharing working.
- 3Clean before you reconnectStop the ransomware, disable its service, quarantine its file, then reconnect.
Vulnerabilities related to EternalBlue
Timeline
- 2017-03-14Microsoft releases MS17-010
- 2017-05-12WannaCry spreads to unpatched Windows systems worldwide
- 2017-05-13Microsoft ships emergency patches even for unsupported Windows
EternalBlue and WannaCry attacks in the wild
Counts of the WannaCry outbreak vary. Europol's director spoke of more than 200,000 victims in at least 150 countries on 14 May 2017, and the UK government later said about 300,000 computers in 150 countries. In England, the National Audit Office found that at least 81 of 236 NHS trusts were affected, 37 of them infected and locked out of devices, along with 603 primary care organisations including 595 GP practices. NHS England counted 6,912 cancelled appointments and estimated over 19,000 in total, and five A&E departments diverted patients. No NHS organisation paid the ransom. A UK Foreign Office statement in December 2017 gave a lower figure of 48 trusts.
On each machine, a dropper (mssecsvc.exe) installed a service called mssecsvc2.0, scanned for new targets and dropped tasksche.exe, which encrypted files and renamed them with the .WNCRY extension. It deleted Windows shadow copies so files could not be restored, talked over Tor, and asked for about 0.1781 bitcoin, roughly 300 US dollars. How the first machines were infected is disputed: CISA listed phishing as a possible first step, while Malwarebytes found no WannaCry emails in its data and concluded the attackers scanned the internet for exposed SMB ports.
In December 2017 the UK's National Cyber Security Centre judged it highly likely that the North Korean Lazarus Group was behind WannaCry, and in June 2018 CISA attributed it to the North Korean government. On 6 September 2018 the US charged Park Jin Hyok, of the North Korean front company Chosun Expo, over WannaCry, the 2014 Sony Pictures hack and the theft of 81 million dollars from a Bangladesh bank. EternalBlue did not stop with WannaCry: on 27 June 2017 the NotPetya malware, delivered through the Ukrainian accounting software M.E.Doc, used EternalBlue and EternalRomance to spread. CISA said it behaved more like destructive malware than ransomware, and the US attributed it to the Russian military in February 2018.
Who found EternalBlue
Microsoft fixed the flaw on 14 March 2017 in MS17-010, together with five related SMBv1 bugs (CVE-2017-0143 to CVE-2017-0148). The bulletin marked none of them as publicly disclosed or exploited and named no reporter. In mid-April 2017 a group calling itself the Shadow Brokers published a set of hacking tools. On 15 April Microsoft wrote that four of them, EternalBlue, EternalChampion, EternalRomance and EternalSynergy, were already fixed by MS17-010. The name EternalBlue comes from that leak. After the outbreak, Microsoft wrote on 14 May that the exploits used by WannaCry were drawn from those stolen from the US National Security Agency (NSA).
WannaCry appeared on 12 May 2017. Cisco Talos saw a jump in scanning on its honeypots shortly before 5 a.m. Eastern time. Within hours, Marcus Hutchins, a 22-year-old researcher known as MalwareTech who worked for Kryptos Logic, noticed that the malware checked an unregistered web address and registered it. Talos confirmed the domain was registered on 12 May and pointed to a sinkhole, which stopped new infections from running. On 13 May Microsoft made the fix for Windows XP, Windows 8 and Server 2003 available to everyone.
Lessons from WannaCry
The patch was out two months before the outbreak, and Microsoft wrote afterwards that many computers remained unpatched worldwide. The National Audit Office called the NHS attack relatively unsophisticated and said basic IT security practice could have prevented it. The lessons were plain: patch quickly, replace systems that no longer get updates, block SMB at the network edge, keep offline backups, and segment networks so one machine cannot reach all the others. Microsoft also stopped installing SMBv1 by default from Windows 10 version 1709 and Windows Server 2019, so old protocols are now something to switch on deliberately, not something left on by accident.
WannaCry also raised the question of where the exploit came from. Microsoft said governments should treat the attack as a wake-up call and report vulnerabilities to vendors instead of stockpiling them. And the outbreak slowed partly by luck, because a researcher registered a domain name. Variants without a working kill switch kept circulating for years: Sophos counted 4.3 million WannaCry detections in August 2019 alone and said they showed machines that still had not installed the 2017 patch.
The case
WannaCry: The Back Office
- Count what it can still infect
- Where did it start?
- Stop it moving
- Clean the reception PC and bring it back
Questions
Is disabling SMBv1 enough to stop EternalBlue?
Yes, for this flaw: Microsoft lists disabling SMBv1 as a workaround. Apply MS17-010 as well when you can.
Should I block port 445?
At the network edge, yes. Inside the network, file sharing needs it, so close SMBv1 on the machines instead.
Is WannaCry still a threat?
It still circulates. Sophos recorded 4.3 million WannaCry detections in August 2019 and 12,480 variants in total; the common variants had lost the kill switch but also had a broken encryption part, so they spread without locking files. Any machine where it still turns up is missing MS17-010.
Has EternalBlue been patched?
Yes. Microsoft fixed it in MS17-010 on 14 March 2017 and released fixes for Windows XP, Windows 8 and Server 2003 in May 2017. Windows Server 2019 and later, and Windows 10 version 1709 and later (except Home and Pro), do not install SMBv1 by default.
How do I check if I am vulnerable to EternalBlue?
Check that the MS17-010 update, or any later cumulative update, is installed, and check whether SMBv1 is on with `Get-SmbServerConfiguration | Select EnableSMB1Protocol`. A vulnerability scanner or the Nmap script smb-vuln-ms17-010 can check many machines over the network without exploiting them.
What is the difference between EternalBlue and WannaCry?
EternalBlue is the exploit for CVE-2017-0144, the SMBv1 flaw, and it came from the toolkit the Shadow Brokers leaked. WannaCry is the ransomware that used EternalBlue to spread in May 2017. Other malware, such as NotPetya in June 2017, used the same exploit.
Who was behind WannaCry?
The UK government said in December 2017 that the North Korean Lazarus Group was highly likely responsible, and CISA attributed it to the North Korean government in 2018. In September 2018 the US charged a North Korean programmer, Park Jin Hyok, in connection with WannaCry and other attacks.
Did paying the WannaCry ransom get files back?
The note asked for about 300 US dollars in bitcoin. CISA warned that paying does not guarantee you get your files back, and no NHS organisation paid. Offline backups were the reliable way to recover.