Skip to content

Persisting in the boot chain

VBR and IPL Infection: Bootkits in the NTFS Boot Sectors

How Rovnix, Gapz and a TDL4 variant hijacked the volume boot record, its BPB hidden-sectors field or the 15-sector IPL, the traces left and how to check them.

Goal
Persisting in the boot chain
Layer
Boot
Where it acts
VBR and IPLOn the boot chain map
Platforms
Windows
Also known as
VBR infection, VBR bootkit, IPL infection, BPB hidden sectors
Checked by
Disk boot sectors

Overview

The master boot record does not start Windows itself. Its code loads the boot sector of the active partition, the volume boot record (VBR), and runs it (Microsoft). On an NTFS system volume, that boot sector and the 15 sectors after it, the initial program loader (IPL), find and start the Windows boot manager. A VBR bootkit takes over one of those three things, the boot sector's code, a field of its BIOS Parameter Block (BPB), or the IPL, and leaves the MBR as it was.

ESET's Virus Bulletin 2014 paper classifies the legacy bootkits by what they change: MBR code (TDL4), the MBR partition table (Olmasco, a TDL4 modification), the IPL code (Rovnix) and the BPB (Gapz), and calls the VBR-based ones the more sophisticated and stealthier. The technique appeared in 2011 with the Olmasco variant of TDL4 and with Rovnix; Gapz followed at the end of 2012, and Kaspersky described a Rovnix-like bootkit that overwrites the VBR in 2020.

Each variant defeats a different shortcut: a check of the MBR finds none of them, and a check of the VBR code misses a changed IPL or BPB field. A responder has to check all three, against the partition table.

How it works

When Windows formats an NTFS volume, it allocates the first 16 sectors to the boot sector and its bootstrap code. NTFS exposes them as the $Boot metafile (MFT record 7).

Partition sectorOffsetContentRead by
0 (VBR)0x00Jump instructionMBR code
00x03OEM ID, NTFS
00x0BBPB, including "Hidden Sectors" at 0x1C (4 bytes)VBR code
00x54Bootstrap code (426 bytes), with messages such as BOOTMGR is missing
00x1FE55 AA
1 to 15 (IPL)Loader that finds BOOTMGR (or NTLDR) in the root folder and starts itVBR code

The hidden-sectors field holds the partition's start on the disk. Microsoft's NTFS reference lists it as "Not used or checked by NTFS", so a wrong value does not stop Windows mounting the volume. The boot code does use it: ESET explains that at boot the VBR code reads the 15 IPL sectors from the position this value gives and runs them.

That gives four ways in, all seen in the wild:

VariantWhat changesWhat still looks cleanFamily
IPL replacedThe 15 IPL sectors hold the bootkit's code, with the original IPL compressed inside itThe MBR and the VBR sectorRovnix (2011)
BPB redirectedThe 4-byte hidden-sectors value points at the bootkit image instead of the partition startThe MBR, the VBR code and the IPL, byte for byteGapz VBR variant (2012)
VBR code overwrittenThe boot sector holds the bootkit's loader; the packed original sits next to itThe MBRRovnix-like bootkit (Kaspersky, 2020)
New active partitionA free partition table entry describes a new partition at the end of the disk, marked active, with the bootkit's own VBRThe original Windows partition's VBR and IPLTDL4, Olmasco variant (2011)

In every case the infected stage then hooks the BIOS disk service (see int 13h hooking) and starts the original code so Windows boots. Writing these sectors needs administrator rights, and Windows allows writes to a volume's boot sectors by design, because setup and antivirus programs update them.

How families use it

FamilyVariantDetailsSource
RovnixIPL replacedReads the 15 IPL sectors, compresses them, appends them to its own bootstrap code and writes the result back. Rovnix.D (2012) varies that code from sample to sampleESET, 2011 and 2012
Rovnix (2020 bootkit)VBR overwritten"Overwrites the VBR with the bootloader, and places the packed original VBR next to it"Kaspersky, 2020
Gapz (Gapz.A)BPB redirectedPoints the active partition's hidden-sectors field at its own code, stored before the first partition or after the last; "all the other data and code of the VBR and IPL remain untouched"ESET, 2012 and 2013
TDL4 (Olmasco variant)New active partitionAdds a partition of up to 50 GB at the end of the disk, marks it active and gives it a VBR that reads a file named boot from TDL4's file system; boot hooks int 13h and loads the original active VBR. ESET's 2014 paper calls it "the first VBR-based bootkit infection"ESET, 2011 and 2014

Traces it leaves

WhereTraceVariant
Partition sector 0, bytes 0x1C to 0x1FA value that differs from the partition's start in the partition table, and points before the first partition, past the last, or into another partitionBPB redirected
Partition sectors 1 to 15Code that is not the Windows NTFS loader: no UTF-16 BOOTMGR / NTLDR and $I30 namesIPL replaced
Partition sector 0, from 0x54Boot code that is not Windows': missing BOOTMGR is missing and related messagesVBR overwritten
MBR partition tableAn extra small entry at the end of the disk with no Windows file system, flagged active; possibly two active entriesNew active partition
Sectors before the first partition or after the lastThe bootkit image or hidden storage, usually high-entropy (see hidden storage)All
TPM, on BIOS machines with BitLockerChanged PCR 8 (NTFS boot sector) and PCR 9 (NTFS boot code), both in BitLocker's default BIOS profile (Microsoft)All

How to check a host

Image from outside. These bootkits need a BIOS boot from an MBR disk (msinfo32 shows "BIOS Mode"), and Rovnix and Gapz protect their sectors on the running system (see disk stack hooking). Boot trusted Linux media and save a full image, or the first 4 MiB and the last MiB (commands on the MBR infection page).

Check each boot sector against the partition table. With S the start of the active NTFS partition, read from mmls:

mmls disk0.img
S=2048
od -An -t u4 -j $((S*512 + 28)) -N 4 disk0.img
dd if=disk0.img bs=512 skip=$S count=1 2>/dev/null | strings -n 8
dd if=disk0.img bs=512 skip=$((S+1)) count=15 2>/dev/null | sha256sum
  • The od line prints the hidden-sectors field in decimal (on a little-endian analysis machine): it should equal S. A different value on a disk that still boots is the Gapz pattern; read the sectors it points to. Some imaging tools leave a stale value, but a volume cloned that way usually fails to boot.
  • The strings should include Windows' VBR messages, and the IPL hash should match a clean volume formatted by the same Windows version.
  • In the mmls output, look for a small partition at the end of the disk, or an active entry that is not the Windows system partition.

What Windows reports. Get-Partition -DiskNumber 0 | Select-Object PartitionNumber, Offset, IsActive lists partition offsets and the active flag as Windows sees them, for comparison with the image; live reads of the boot sectors themselves may come back clean. A collected $Boot file holds the VBR and IPL but not the partition's start, so it cannot settle the hidden-sectors question.

What the checker looks for

The bootsector module reads each partition's first sectors from a disk image or disk head, and $Boot files. It raises:

  • "VBR hidden-sectors value differs from the partition start" (high when the partition is active or its code is Windows'), linked to the Gapz page, with where the value points. It allows the different value logical partitions legitimately carry.
  • "NTFS loader sectors do not match a known loader" when sectors 1 to 15 lack the names Windows' IPL carries, where Rovnix writes its code.
  • "Volume boot code does not match a known loader" for a boot sector whose code is not Windows', GRUB's, Syslinux's or a known non-bootable stub.
  • "Small last partition with no recognised file system" for a partition like the one TDL4's Olmasco variant adds (high when it is active and an NTFS partition exists), and "More than one active partition".
  • "Data before the first partition does not match a known loader" and "Data after the last partition" for the code kept outside the partitions.

The IPL and VBR findings rest on "not a loader the checker knows", not on a signature, since Rovnix.D varies its code per sample. The module does not read boot sectors beyond the first 4 MiB and last 1 MiB of a large image, does not decrypt what it finds, and cannot check the hidden-sectors value of a lone $Boot file. A disk head copied through the infected system can show clean sectors. The sample's LAB-VM-01 host reproduces the Gapz layout: see the sample walk-through.

Mitigation and recovery

Prevention. Boot through UEFI from a GPT disk with Secure Boot on: the firmware then runs a signed boot manager from the EFI system partition and never executes a VBR or IPL. On remaining BIOS machines, BitLocker with a TPM turns a changed boot sector or IPL into a recovery prompt. Restrict administrator rights.

Recovery.

  1. Preserve a full image, or at least the disk head, each partition's first 16 sectors and the disk tail, taken from a clean environment.
  2. bootrec /fixboot from Windows RE writes a new boot sector to the system partition. Whether it rewrites the IPL and corrects the BPB depends on the tool and version: afterwards, check the hidden-sectors value against the partition start and the IPL against a clean reference. A repair that leaves the IPL in place leaves Rovnix in place. For the Olmasco variant, remove the extra entry and mark the Windows partition active again.
  3. Prefer a rebuild. The kernel code had full control of the host; wipe the whole disk, including the space outside the partitions (diskpart, clean all), reinstall from trusted media, and rotate the credentials used on the host.

Sources

Primary public reports, newest first.

  1. 2020-06-23Oh, what a boot-iful mornin'Kaspersky
  2. 2018-05-31ProtectKeyWithTPM method of the Win32_EncryptableVolume classMicrosoft
  3. 2014-11-12Bootkits: past, present & futureVirus Bulletin (ESET)
  4. 2013-04-08Mind the Gapz: The most complex bootkit ever analyzed?ESET
  5. 2012-12-27Win32/Gapz: New Bootkit TechniqueESET
  6. 2012-07-13Rovnix bootkit framework updatedESET
  7. 2011-10-18TDL4 rebootedESET
  8. 2011-08-23Hasta La Vista, Bootkit: Exploiting the VBRESET
  9. 2009-10-08How NTFS WorksMicrosoft
  10. 2009-10-08How Basic Disks and Volumes WorkMicrosoft

See also

Related techniques

Families that use it