Skip to content

UEFI bootkit

FinSpy UEFI Bootkit: Traces and Offline Checks

The FinSpy UEFI bootkit replaces the Windows Boot Manager and keeps encrypted loaders in the ESP's en-us folder. Traces, the MBR variant, checks and recovery.

Kind
UEFI bootkit · Boot layer
Platforms
Windows
First seen
2021-09
Status
In the wild
Also known as
FinFisher, Wingbird
Checked by
EFI system partitionMeasured Boot logsDisk boot sectors

Overview

FinSpy, also known as FinFisher or Wingbird, is commercial surveillance spyware. MITRE describes it as reportedly sold only to government agencies. Kaspersky has tracked it since 2011, and on 28 September 2021 it published the first public details of a UEFI bootkit used to load FinSpy on Windows. The same report covers the two other Windows infection paths Kaspersky saw: trojanized installers, and an MBR bootkit for machines without UEFI, which it says has been known since at least 2014.

This page covers the bootkit, not the whole spyware platform. Because FinSpy is a product, the report does not attribute individual infections to a customer, and neither does this page. Kaspersky does not date the first UEFI infection; firstSeen above is the date of the public report.

The UEFI bootkit does not touch the firmware in SPI flash. It replaces a file on the EFI system partition (ESP). ESET, describing ESPecter a week later, placed FinSpy's bootkit in the same category of ESP implants.

How it loads and hides

Kaspersky reports that on every machine infected through UEFI, the Windows Boot Manager, bootmgfw.efi, had been replaced with a malicious loader. At boot:

  1. The firmware runs the malicious bootmgfw.efi. It finds the original Windows Boot Manager, which is kept in \EFI\Microsoft\Boot\en-us\ under a name made of hexadecimal characters, loads it, patches it in memory and starts it.
  2. The patch reaches the OS loader's hand-over to the kernel and hooks the kernel function PsCreateSystemThread. On its first call, a new kernel thread decrypts and starts the next stage.
  3. That stage reads the Trojan loader from the ESP, decrypts it, waits for a user to log on and injects it into winlogon.exe.
  4. The Trojan loader extracts the FinSpy Trojan from its resources, decrypts and unpacks it, and loads it reflectively.

The same en-us folder holds the Winlogon injector and the Trojan loader. Both are RC4-encrypted with the ESP's partition GUID as the key, which differs from machine to machine. Their contents, and so their hashes, are unique to each infected disk.

Kaspersky's report does not discuss Secure Boot. In a reply to a reader under the report, Kaspersky stated that Secure Boot prevents this bootkit from starting, but that an attacker with physical access could switch Secure Boot off when no firmware password is set.

MBR variant. On machines without UEFI, the infected MBR copies the first loader stage from the last megabyte of the disk into memory below the Extended BIOS Data Area, hooks BIOS interrupts 13h and 15h, and starts the original MBR. The 13h hook patches the Windows loader as it is read from disk, and a chain of later hooks ends in a kernel thread that injects the same Trojan loader into winlogon.exe. On 32-bit Windows the injection goes through explorer.exe first, which Kaspersky reads as an attempt to confuse security products.

Traces on disk

LocationWhatSource
ESP\EFI\Microsoft\Boot\bootmgfw.efiReplaced by the bootkit's loader; Secure Boot does not accept itKaspersky
ESP\EFI\Microsoft\Boot\en-us\<hexadecimal name>The original Windows Boot Manager, the Winlogon injector and the Trojan loader (the last two RC4-encrypted); this folder normally holds language resource filesKaspersky
MBR (legacy machines)Infected boot code that hooks INT 13h and 15hKaspersky
Last megabyte of the disk (legacy machines)The first loader stage, read by the infected MBRKaspersky

On a running system, Kaspersky also lists mutexes (SessionImmersiveMutex, WininetStartupMutex0) and events (WinlogonLogon, TermSrvReadyEvent followed by hexadecimal digits) created by the Windows implant. Those exist in memory only. The report lists MD5 hashes of samples; take them from the report itself, and remember that the encrypted ESP files will not match any hash.

How to check a host

Offline, from an image or a collection:

  • Copy the whole ESP. In EFI\Microsoft\Boot\en-us\, any file whose name is a run of hexadecimal characters is suspect: compare the folder's contents with a clean machine of the same Windows build.
  • Check the Authenticode signature of EFI\Microsoft\Boot\bootmgfw.efi. The real Windows Boot Manager is signed by Microsoft; the bootkit's loader is not accepted by Secure Boot. Check the signature first: a hash that differs from C:\Windows\Boot\EFI\bootmgfw.efi can also come from a legitimate boot manager update.
  • In the Measured Boot logs (C:\Windows\Logs\MeasuredBoot\), check the Secure Boot state and whether the boot manager's measurement changed between two boots. See Reading Measured Boot logs.
  • For BIOS machines, image the whole disk, or at least its first and last megabyte, and compare the MBR with standard Windows boot code.

Live, elevated:

mountvol S: /S
dir /a S:\EFI\Microsoft\Boot\en-us
powershell -c "Get-AuthenticodeSignature S:\EFI\Microsoft\Boot\bootmgfw.efi | Format-List Status, StatusMessage, SignerCertificate"
powershell -c "Confirm-SecureBootUEFI"
mountvol S: /D

A live listing comes from a system the spyware controls in kernel mode, so prefer an ESP copy read on another machine. The full collection steps are in How to check the EFI system partition offline.

What the checker looks for

  • esp lists every file on the partition. The bootkit's bootmgfw.efi raises "An unsigned EFI binary on a boot path" if it carries no signature, or "The Windows Boot Manager is not signed by a Windows production CA" if another signer signed it. Each file with a hexadecimal name in EFI\Microsoft\Boot\en-us\ raises "does not belong in the Windows boot folder": that folder holds .mui resource files, and the moved original boot manager and the encrypted loaders match none of the names Windows uses there. The checker does not decrypt the RC4-encrypted files.
  • measuredboot raises "Secure Boot was off during this boot", and "The digest of \EFI\Microsoft\Boot\bootmgfw.efi changed since the previous boot" when saved logs from before and after the infection exist; Windows updates also change it. If the firmware measured the original boot manager when the bootkit started it from en-us, that path appears as "A boot application outside the usual boot paths".
  • bootsector, for legacy machines, raises "MBR boot code does not match a known loader" for the infected MBR. It reads the first 4 MiB and the last 1 MiB of a full disk image, so the first loader stage in the disk's last megabyte raises "Data after the last partition" when it lies after the last partition; a disk head alone does not reach it.

The checker cannot decrypt the ESP files and does not see the injected loader, the Trojan, or the mutexes and events in memory.

Removal and recovery

FinSpy is a full surveillance implant: treat everything on the host and everything typed on it as exposed.

  1. Preserve the ESP and a disk image, or the disk's first and last megabyte on BIOS machines, before changing anything.
  2. Rebuild Windows from trusted media and recreate the ESP. Replacing bootmgfw.efi and deleting the en-us files removes the boot stage but not what the spyware did while it ran.
  3. On BIOS machines, wipe the whole disk before reinstalling, so the loader at the end of the disk goes too.
  4. Turn Secure Boot on and set a firmware administrator password, since Kaspersky notes that physical access with Secure Boot off is enough for this bootkit.
  5. Rotate credentials and keys used on the host, and assess what data and communications were reachable from it.

Sources

Primary public reports, newest first.

  1. 2024-09-12FinFisher (S0182)MITRE ATT&CK
  2. 2021-10-05UEFI threats moving to the ESP: Introducing ESPecter bootkitESET
  3. 2021-09-28FinSpy: unseen findingsKaspersky

See also