Hiding and protecting itself
Disk Stack Hooking: How Bootkits Return Clean Boot Sectors
How TDL4, Rovnix and Gapz hooked the Windows disk driver stack to hide infected sectors and block repairs, why live disk reads lie, and how to check a host.
- Goal
- Hiding and protecting itself
- Layer
- Boot
- Where it acts
- In memoryOn the boot chain map
- Platforms
- Windows
- ATT&CK
- T1014
- Also known as
- Disk miniport hooking, IRP hooking of the disk driver, Sector spoofing
- Checked by
- None: no module reads its traces
Overview
A legacy bootkit is safe from Windows until Windows starts. After that, any tool with administrator rights can read sector 0, the boot sectors and the end of the disk, and see the infection. So the bootkits that infect the MBR or the volume boot record also load a kernel component that sits in the Windows disk driver stack. When something reads a protected sector, it answers with the original, clean content or with nothing. When something tries to overwrite the infected code or the hidden store, it blocks the write.
This turns every live disk check into a question about the bootkit's honesty. A disk head copied through the running system, a raw read by an antivirus product, or an MBR repair tool run from Windows all go through the hooked stack. TDL4, Rovnix and Gapz all do this. ESET's Gapz white paper describes it as protection "from being removed from the system".
The technique belongs to the operating system's kernel, but it only exists because of the boot infection: it guards the MBR, the VBR and IPL and the hidden storage. Its consequence for responders is the rule that runs through this site: read the disk from outside the infected system.
How it works
A raw read of the disk, such as a tool opening \\.\PhysicalDrive0, travels down the disk stack to the port or miniport driver that talks to the disk controller. Tools can also send SCSI or ATA commands directly with pass-through requests (IOCTL_SCSI_PASS_THROUGH, IOCTL_ATA_PASS_THROUGH and their _DIRECT forms), which Windows documents as one of the ways to write to a disk. A bootkit that controls the lowest driver in the stack sees both.
Each Windows driver has a DRIVER_OBJECT whose MajorFunction table points to the routines that handle each kind of request (IRP). ESET describes two ways the bootkits took over the disk miniport driver's handlers:
| Method | What changes | Used by, per ESET | What finds it |
|---|---|---|---|
| Pointer replacement | An entry of the miniport's MajorFunction table points into the bootkit's code | TDL4, Olmasco, Rovnix | A listing of IRP handlers: the handler is outside the driver's own image |
| Splicing (inline patch) | Code near the start of the legitimate handler, inside the driver image in memory (scsiport.sys in ESET's figure), is overwritten to divert execution | Gapz | A comparison of the handler's code in memory with the driver file; the pointer itself looks normal |
ESET adds that Gapz skips a few instructions at the start of the routine before placing its patch, "possibly done in order to increase the stability and stealthiness" of the hook.
What the hook does with a request:
- Read of a protected sector: returns the original content kept in the hidden store (TDL4 returns the clean MBR) or other fake content.
- Write to a protected sector: blocked, so a repair appears to succeed or fails.
- Anything else: passed on unchanged, so the disk works normally.
TDL4 adds a watchdog thread that, per Kaspersky, "checks that system objects are hooked and that the MBR contains an infected copy of the sector", and re-infects it if not.
How families use it
| Family | Hook | What it protects | Source |
|---|---|---|---|
| TDL4 | Hooks in the disk stack set "using the same technique as the previous variant, TDL-3"; ESET groups it with the pointer-replacing bootkits | "Whenever disk sectors containing the rootkit's critical components are accessed, fake content is returned"; the watchdog restores the infected MBR | Kaspersky, 2011; ESET, 2013 |
| Rovnix | IRP_MJ_INTERNAL_DEVICE_CONTROL handler (ESET writes IRP_MJ_INTERNAL_CONTROL) of the disk miniport DRIVER_OBJECT, to intercept reads and writes | The infected bootstrap code, the stored kernel driver and the hidden "Virtual FAT" partition | ESET, February 2012 |
| Gapz | IRP_MJ_INTERNAL_DEVICE_CONTROL and IRP_MJ_DEVICE_CONTROL handlers of the disk miniport, spliced; in the latter it watches only the SCSI and ATA pass-through requests | The infected MBR or VBR from being read or overwritten, and its image on the disk from being overwritten | ESET, 2013 |
UEFI-era bootkits face the same problem on the EFI system partition and solve it differently. BlackLotus's driver, for example, keeps handles open on its ESP files so they cannot be changed or deleted, rather than hooking the disk stack (ESET).
Traces it leaves
| Where | Trace |
|---|---|
| Disk | Nothing of the hook. The sectors it protects carry the infection, readable from outside |
| Live disk reads | Sector 0, boot sectors or the gaps read through Windows differ from the same sectors read from an offline image |
| Kernel memory | A miniport MajorFunction entry pointing outside the driver's image (pointer method), or patched code in the first bytes of a handler (splicing) |
| Kernel memory | A driver object or code block with no driver file behind it: the bootkit's own kernel component |
| Behaviour | An MBR or boot sector repair that "succeeds" from Windows but does not persist, or is undone after a reboot |
| Event logs | Nothing specific |
How to check a host
The decisive check: compare a live read with an offline read. On a suspect BIOS machine:
- On the running system, image the disk head (and, if possible, the tail) with your forensic imager's physical-disk acquisition.
- Shut down, boot trusted external media, and image the same regions (the commands are on the MBR infection page).
- Hash and compare sector 0, the first 16 sectors of each NTFS partition, the gap before the first partition and the tail.
Any difference between the two, on sectors that should not change, is evidence of a filter, whatever the offline sectors contain. The offline image is the one to analyse.
Memory analysis. Acquire memory from the running system before shutting down, and analyse it with Volatility 3:
vol -f mem.raw windows.driverirp
vol -f mem.raw windows.drivermodule
vol -f mem.raw windows.devicetree
windows.driverirplists each driver's IRP handlers with the module that owns the address. For the disk drivers (disk, the port drivers such asstorport,scsiportorataport, and the miniport such asatapi,storahcior a vendor driver), a handler that resolves to another module or to no module is the pointer-replacement pattern.windows.drivermodulereports driver objects not backed by a loaded module, as a bootkit's own kernel component often is.windows.devicetreeshows the devices attached to each disk stack.
Splicing, as Gapz uses it, does not change the handler's address: dump the miniport driver from memory and compare the first bytes of each handler, not only its first instruction, with the driver file, allowing for relocations. Memory acquisition itself runs on the compromised system; a rootkit could interfere with it, so treat a clean memory image as weaker than a positive finding.
Historic tools. At the time, vendors shipped dedicated removal tools that detected these hooks, such as Kaspersky's TDSSKiller for TDL4. They are a lead on old systems, not a reference today.
What the checker looks for
Nothing directly: the hooks exist only in kernel memory, and the checker reads files. That is why checks is empty for this technique.
What it reads is the evidence these hooks falsify, and it says so. The bootsector module adds this note to every analysis with a disk image: "A disk imaged from the running system can look clean: MBR and VBR bootkits such as TDL4 and Gapz hook disk reads and return the original sectors." Give it both the live head and the offline head of the same disk, each in its own folder (for example PC01-live/disk0.img and PC01-offline/disk0.img), which it reads as two hosts: if the offline one raises "MBR boot code does not match a known loader", "VBR hidden-sectors value differs from the partition start" or "NTFS loader sectors do not match a known loader" and the live one does not, the difference is this technique at work. The checker does not compare the two images for you, and it does not read memory. See what an offline bootkit check can and cannot prove.
Mitigation and recovery
Prevention. The hook needs a kernel component, and the kernel component needs the boot infection to get past driver signing (see turning off driver signing from the boot chain). Removing the legacy boot path, with UEFI, GPT and Secure Boot, removes the reason for the hook. Memory integrity (HVCI) moves kernel code integrity decisions into a hypervisor-protected environment and, as Microsoft puts it, helps prevent attacks that "modify kernel-mode code". A bootkit that runs before the hypervisor can still try to turn it off, as BlackLotus does.
Recovery.
- Never trust a repair made from the running, infected system. The hook blocks or undoes writes to the protected sectors, and TDL4's watchdog restores its MBR.
- Preserve memory first, then the disk image from trusted media.
- Repair or, better, wipe the disk from external media, where the bootkit is not running. Wipe every sector (
diskpart,clean all) so the hidden store goes too. - Reinstall from trusted media and rotate the credentials used on the host. The kernel component had full control of the system.
Sources
Primary public reports, newest first.
- 2026-10-21Enable memory integrityMicrosoft
- 2023-03-01BlackLotus UEFI bootkit: Myth confirmedESET
- 2017-06-01Restricted Direct Disk Access and Volume Access in WindowsMicrosoft
- 2013-04-08Mind the Gapz: The most complex bootkit ever analyzed?ESET
- 2012-02-22Rovnix Reloaded: new step of evolutionESET
- 2011-06-27TDL4 – Top BotKaspersky
- 2011-01-25TDSS. TDL-4Kaspersky
See also
Related techniques
- Replacing the MBR boot codePersisting in the boot chain
- Infecting the VBR, its BPB or the IPLPersisting in the boot chain
- Hidden storage outside the partitionsPersisting in the boot chain
- Turning off driver signing from the boot chainTaking over the boot
Families that use it
- GapzVBR bootkit
- RovnixVBR bootkit
- TDL4 (TDSS / Alureon)MBR bootkit