Chapter 01

Installation and Setup

The choices made at install time define the attack surface for the machine's entire lifetime. Firmware type, partition layout, and edition selection are not administrative preferences — they are security decisions with consequences measured in years.

Scenario

A forensic investigator is called in after a ransomware attack. The infected machine booted normally after the infection — the OS loaded, the desktop appeared, everything looked fine. But the ransom note was already on screen. The payload had executed before Windows even started. How? The machine's firmware had been replaced with a malicious UEFI module — a bootkit — that ran at firmware boot time, before the OS loader, before any endpoint protection, before any logging began. The machine was bought secondhand. Secure Boot was disabled. Nobody checked.

This chapter explains why that was possible, what Secure Boot actually defends against, and how install-time decisions made years before an attack determine whether that attack can even happen.

The Boot Chain and Its Security Implications

Before Windows starts, a significant amount of code has already executed. That code determines what the OS can trust about the environment it's running in. Understanding the boot chain is not academic — it's the foundation for understanding why a compromised firmware means no endpoint control matters.

  The Windows Boot Chain — and where attacks can hide
  ══════════════════════════════════════════════════════════════════════

  POWER ON
      │
      ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  FIRMWARE (UEFI / BIOS)                                         │
  │  Runs from flash memory on the motherboard                      │
  │  Initializes CPU, RAM, storage controllers                      │
  │                                                                  │
  │  Attack surface: UEFI bootkits (e.g., LoJax, MoonBounce,        │
  │  CosmicStrand) flash malicious modules here. Survives OS        │
  │  reinstall, survives disk replacement. Only solution is         │
  │  firmware reflash or board replacement.                         │
  └────────────────────────────┬────────────────────────────────────┘
                               │  (Secure Boot checks signature here)
                               ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  BOOTLOADER (bootmgfw.efi)                                      │
  │  Stored on the EFI System Partition (ESP)                       │
  │  Reads the Boot Configuration Database (BCD)                    │
  │  Selects and loads the OS kernel                                │
  │                                                                  │
  │  Attack surface: ESP is a FAT32 partition on disk — an          │
  │  attacker with admin access can replace bootmgfw.efi with       │
  │  a malicious loader. This is the classic "bootkit" approach.    │
  │  Secure Boot prevents this by requiring a valid signature.      │
  └────────────────────────────┬────────────────────────────────────┘
                               │
                               ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  WINDOWS KERNEL (ntoskrnl.exe)                                  │
  │  Loaded by bootmgfw.efi                                         │
  │  Initializes the executive, drivers, services                   │
  │                                                                  │
  │  Attack surface: rootkits that load as boot-start drivers.      │
  │  Driver signing enforcement (DSE) requires kernel-mode code     │
  │  to have a valid Microsoft-issued signature. BYOVD attacks      │
  │  bypass this by loading a legitimate but vulnerable driver.     │
  └────────────────────────────┬────────────────────────────────────┘
                               │
                               ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  EARLY LAUNCH ANTI-MALWARE (ELAM)                               │
  │  First non-Microsoft driver loaded (if enrolled)                │
  │  AV vendors register an ELAM driver that can classify other     │
  │  boot drivers as good/bad/unknown before they load              │
  └────────────────────────────┬────────────────────────────────────┘
                               │
                               ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  USER SESSION (winlogon, services, applications)                │
  │  The environment your endpoint security tools run in            │
  │  By this point, any attack that happened above is invisible     │
  └─────────────────────────────────────────────────────────────────┘
    
Why bootkits are the worst-case compromise

A bootkit executes before the OS. That means it executes before Windows Defender, before any EDR driver, before any logging. From the OS's perspective, it woke up in an already-compromised environment. The bootkit can patch kernel structures, intercept system calls, hide processes, and alter security policies — all before a single line of endpoint software runs. Known real-world UEFI bootkits include LoJax (APT28, 2018), MoonBounce (2022), and CosmicStrand (2022). All three survived OS reinstallation because they lived in firmware, not on disk.

UEFI vs BIOS/MBR — The Security Divide

Every machine manufactured since roughly 2012 uses UEFI firmware. Older machines use legacy BIOS. The security difference is substantial — not in terms of obscure edge cases, but in terms of whether fundamental protections like Secure Boot and measured boot can exist at all.

Property Legacy BIOS + MBR UEFI + GPT
Secure Boot Not available. Any code in the MBR runs unconditionally at boot. Available. Every EFI binary must be signed by a key in the firmware's Secure Boot database.
Measured Boot / TPM chain Not available. No integrity measurement of the boot sequence. Available. UEFI extends PCR values in the TPM at each boot stage, creating a cryptographic log of what ran.
Bootkit surface MBR is 512 bytes of code with no integrity check. Trivially overwritten with admin access. EFI partition is larger but protected by Secure Boot signature validation.
BitLocker auto-unlock Not available without TPM. Key must be manually entered on every boot. TPM-backed auto-unlock. Key released only when measured boot values match expected state.
Windows 11 support Not supported. Windows 11 requires UEFI + TPM 2.0 + Secure Boot. Fully supported.

Secure Boot: How It Actually Works

Secure Boot is widely misunderstood. It does not scan for malware. It does not monitor running processes. It does exactly one thing: before executing any EFI binary at boot time, it checks whether that binary is signed by a key in the firmware's Secure Boot key database. If the signature is absent or invalid, the firmware refuses to execute the binary and halts.

  Secure Boot Verification Flow
  ══════════════════════════════════════════════════════════════════════

  Firmware contains three databases:
  ┌────────────────────────────────────────────────────────────────┐
  │  db  (Allowed Signatures)  — keys/hashes of allowed loaders   │
  │  dbx (Forbidden Signatures) — revoked keys/hashes             │
  │  KEK (Key Exchange Key)    — keys that can update db/dbx       │
  │  PK  (Platform Key)        — root of trust, set by OEM        │
  └────────────────────────────────────────────────────────────────┘

  At boot, for each EFI binary:
      1. Compute hash of binary
      2. Check hash against dbx → if found: BLOCK (revoked)
      3. Verify signature against db → if valid: ALLOW
      4. If neither match: BLOCK (untrusted)

  Microsoft's key is in db on essentially every PC sold.
  This means Windows' bootmgfw.efi loads. A custom Linux
  kernel without a recognized signature does not.

  The attack: an attacker with physical access or firmware
  write access can add their own key to db — or disable
  Secure Boot entirely via firmware settings. This is why
  physical security and BIOS/UEFI password protection matter.
    
Wild: BlackLotus bypassed Secure Boot on fully-patched Windows 11

In 2023, the BlackLotus bootkit was discovered exploiting CVE-2022-21894 (Baton Drop), a vulnerability in the Windows Boot Manager that Microsoft had patched in January 2022. Despite the patch, Secure Boot could still be bypassed because the dbx (revocation list) had not been updated to add the vulnerable bootloader hashes — Microsoft delayed the revocation to avoid breaking dual-boot systems. BlackLotus worked on fully-patched Windows 11 machines because the vulnerable version of bootmgfw.efi was still trusted by Secure Boot. This illustrates that Secure Boot's effectiveness depends on keeping the revocation list current — not just having Secure Boot enabled.

TPM and Measured Boot

The Trusted Platform Module (TPM) is a hardware chip (or firmware equivalent) that performs two security functions relevant to boot security: it stores cryptographic keys in a way that ties them to the machine's hardware, and it records a cryptographic measurement of everything that executes during boot.

Measured Boot works by having UEFI firmware hash each component it loads — the firmware itself, the bootloader, the kernel, early drivers — and extend those hashes into the TPM's Platform Configuration Registers (PCRs). The PCRs are append-only: each extension operation computes PCR_new = SHA256(PCR_old || new_measurement). The result is a tamper-evident chain: if anything in the boot sequence changes — a different kernel version, a new driver, a modified bootloader — the PCR values change.

  TPM Measured Boot — PCR chain
  ══════════════════════════════════════════════════════════════════════

  Boot Stage              PCR Extended    What's Being Measured
  ─────────────────────────────────────────────────────────────────────
  UEFI Firmware           PCR 0           Core firmware code
  UEFI Variables          PCR 1           UEFI config (Secure Boot state)
  Option ROMs             PCR 2           Expansion card firmware
  MBR / ESP               PCR 4           Boot manager code
  Boot Manager            PCR 5           Boot manager config (BCD)
  Boot Loader             PCR 8-9         Windows Boot Loader, kernel
  ELAM Driver             PCR 12          Anti-malware early launch driver
  Loaded Drivers          PCR 13          All boot-start drivers

  BitLocker key is sealed to a set of expected PCR values.
  If any measured component is tampered with, the PCR values
  change → BitLocker refuses to release the key → disk
  remains encrypted → attacker can't read disk contents even
  with physical access.

  This is why BitLocker + TPM + Secure Boot together form a
  chain: Secure Boot prevents loading untrusted code,
  Measured Boot detects if anything changed, BitLocker uses
  the TPM measurements to seal disk encryption.
    
Mental model: the TPM as a lie detector for the boot process

The TPM doesn't prevent attacks — it detects them. If a bootkit replaces bootmgfw.efi, the PCR 5 measurement will be different from the sealed expected value. BitLocker will refuse to auto-unlock. The machine will prompt for the BitLocker recovery key. An attacker who doesn't have that 48-digit key cannot access the encrypted contents. The TPM's job is to ensure the disk key is only released to a boot sequence that looks exactly like the legitimate one — not to stop the bootkit from running, but to make running it pointless without the recovery key.

Windows Editions and Their Security Feature Sets

The edition of Windows installed on a machine determines which security controls are available. This matters for defenders because a machine on Windows Home cannot be domain-joined, cannot use AppLocker, and cannot use Credential Guard — controls that are routinely expected in enterprise environments.

Edition Key Security Features Available Notable Absences
Home Windows Defender, Device Encryption (if TPM present), Windows Hello No Group Policy, no BitLocker (full), no domain join, no AppLocker, no Credential Guard, no Hyper-V
Pro BitLocker, domain join, Group Policy, Hyper-V, Windows Sandbox, Remote Desktop (server), Windows Information Protection No Credential Guard, no AppLocker (rule enforcement), no Windows Defender Application Guard
Enterprise / Education Everything in Pro + Credential Guard, AppLocker enforcement, Windows Defender Application Guard, DirectAccess, LTSC availability, Windows Defender Credential Guard Most enterprise security features available
Server Standard/Datacenter All Enterprise features + server roles (AD DS, DNS, DHCP, IIS), multiple Hyper-V VMs, shielded VMs (Datacenter) N/A — most capable Windows platform
Why Credential Guard requires Enterprise

Credential Guard stores NTLM hashes and Kerberos tickets in an isolated virtual machine (VSM — Virtual Secure Mode) powered by Hyper-V, making them inaccessible to even a compromised OS kernel. This is one of the most effective mitigations against credential theft tools like Mimikatz. It requires Hyper-V and is only available on Enterprise and above. Organizations running Windows Pro across their endpoints have a materially different threat profile for credential-based attacks than those running Enterprise — an important context when reading threat intelligence reports that assume Credential Guard is present.

Server Core: Less Code, Smaller Attack Surface

Server Core is the installation option that removes the Windows desktop shell — no Explorer, no Start menu, no graphical MMC consoles. It is managed entirely via PowerShell remoting, command line tools, or RSAT from a separate management workstation.

The security case for Core is simple: every component installed on a machine is a potential attack surface. Internet Explorer, the Windows desktop shell, the Help and Support Center, Windows Media Player, and dozens of background services that ship with Desktop Experience each represent code that could contain vulnerabilities. Fewer installed components means fewer CVEs applicable to that machine, a smaller patch surface, and fewer potential vectors for privilege escalation.

Metric Server Core Server with Desktop Experience
Disk footprint ~4 GB ~9 GB
Memory footprint Lower (fewer services running) Higher
Patch frequency Fewer patches required per month (fewer components) More patches, more reboots
Attack surface Reduced: no browser, no desktop shell, no media components Full Windows attack surface
Management PowerShell remoting, Server Manager (remote), RSAT Full GUI locally and remotely
Common mistake: treating Server Core as "harder to manage"

Most enterprise environments manage servers via PowerShell remoting anyway — the local GUI on a server is used far less than most people assume. Server Core with RSAT installed on a management workstation provides identical administrative capability with a significantly smaller attack surface. Avoid the reflex of installing Desktop Experience "just in case" — that decision persists for the lifetime of the machine.

Partition Layout as a Security Map

A GPT-partitioned Windows system has a predictable partition layout. Each partition has a distinct security profile, and attackers know this.

  GPT Partition Layout — Security View
  ══════════════════════════════════════════════════════════════════════

  ┌────────────────────────────────────────────────────────────────┐
  │  EFI System Partition (ESP)  ~100 MB   FAT32                   │
  │  Contains: bootmgfw.efi, BCD store, recovery tools             │
  │                                                                 │
  │  Security profile: FAT32 — no NTFS permissions, no encryption. │
  │  Any process with admin rights can write to the ESP.           │
  │  Secure Boot protects against unauthorized code execution      │
  │  from here, but not against modification of files stored here. │
  │  Bootkits target this partition.                               │
  ├────────────────────────────────────────────────────────────────┤
  │  Microsoft Reserved Partition (MSR)  16 MB                     │
  │  No filesystem. Reserved for Windows partition utilities.      │
  │  No direct security relevance.                                 │
  ├────────────────────────────────────────────────────────────────┤
  │  OS Partition (C:)    ~60 GB+   NTFS                           │
  │  Windows, applications, user data                              │
  │                                                                 │
  │  Security profile: NTFS permissions + ACLs. BitLocker-          │
  │  encrypted if properly configured. This is where most          │
  │  endpoint protection operates. The vast majority of            │
  │  attack activity targets this partition.                       │
  ├────────────────────────────────────────────────────────────────┤
  │  Recovery Partition   ~500 MB   NTFS (hidden, no drive letter) │
  │  Contains WinRE (winre.wim) for startup repair                 │
  │                                                                 │
  │  Security profile: Hidden but not encrypted by default.        │
  │  Attackers have used recovery partitions to stage tools        │
  │  that survive OS partition wiping. Recovery environments       │
  │  have limited endpoint protection running.                     │
  └────────────────────────────────────────────────────────────────┘
    
Why the ESP is FAT32 and why that matters

The EFI System Partition must be FAT32 because UEFI firmware needs to read it before any filesystem drivers load — and FAT32 is the only filesystem built into UEFI firmware. The consequence is that FAT32 has no concept of NTFS permissions, no access control lists, no encryption. Any process running with administrator privileges on the OS can write arbitrary files to the ESP. Secure Boot prevents those files from being executed at boot (if Secure Boot is enabled and the file isn't signed), but it does not prevent them from being placed there. A bootkit that patches an existing, signed EFI binary in place rather than replacing it might still pass Secure Boot validation if the binary's signature isn't verified after modification — though modern Secure Boot implementations hash the full binary, making this difficult in practice.

Virtualization-Based Security (VBS)

Modern Windows security depends on a feature called Virtualization-Based Security, which uses the CPU's hypervisor capabilities to create an isolated environment below the OS kernel. When VBS is active, the Windows kernel runs as a guest in a virtual machine managed by Hyper-V. A separate, more trusted environment — called Virtual Trust Level 1 (VTL1) or the "Secure World" — hosts the most sensitive security functions.

  Virtualization-Based Security Architecture
  ══════════════════════════════════════════════════════════════════════

  Hardware (CPU with VT-x / AMD-V)
  └── Hyper-V Hypervisor (Ring -1 / VMX Root Mode)
      │
      ├── VTL0: Normal World (the OS you see)
      │   ├── Windows Kernel (Ring 0)  ← ntoskrnl.exe, drivers
      │   └── User Mode (Ring 3)       ← applications, malware
      │
      └── VTL1: Secure World (isolated, higher privilege than VTL0)
          ├── Credential Guard (lsaiso.exe)
          │   └── NTLM hashes and Kerberos tickets stored here
          │       Unreachable by compromised VTL0 kernel
          │
          └── HVCI (Hypervisor-Protected Code Integrity)
              └── Validates all kernel code pages before execution
                  Even a compromised kernel can't inject unsigned code

  VTL0 (the normal OS) cannot reach into VTL1 even with
  kernel-level code. Credential Guard protection survives
  a kernel compromise. This is why BYOVD attacks still work
  against the kernel but don't recover Credential Guard secrets.
    

VBS is enabled automatically when certain features are turned on: Credential Guard, Windows Defender Application Guard, Windows Sandbox, and Hyper-V itself all require VBS. On Windows 11 with Secure Boot and TPM 2.0, VBS is enabled by default on new installations.

Q & A

1. If Secure Boot is enabled on a machine, can an attacker with local admin access still install a bootkit?

With Secure Boot enabled, an attacker with local admin access cannot execute an unsigned EFI binary at boot time — Secure Boot will block it. However, there are several realistic attack paths. First, the attacker could disable Secure Boot through the firmware settings if there is no firmware password protecting UEFI setup. Second, if the attacker has kernel-level access (via a BYOVD exploit or a compromised driver), they could potentially modify the Secure Boot key database to add their own key — though this requires Ring 0 access and modern Windows attempts to protect the firmware interface from user mode. Third, signed-but-vulnerable boot components can be placed on the ESP and will pass Secure Boot validation as long as they haven't been added to the dbx revocation list. This is the BlackLotus scenario: the vulnerable bootloader binary is genuinely signed by Microsoft, so Secure Boot allows it, but it can then be exploited to load unsigned code. The takeaway: Secure Boot is a meaningful control against opportunistic attacks and unsigned bootkits, but it is not an absolute barrier for a sophisticated attacker with appropriate access.

2. What does "BYOVD" mean and how does it relate to boot security?

BYOVD stands for Bring Your Own Vulnerable Driver. Windows requires all kernel-mode drivers to be signed by Microsoft. Attackers cannot load their own unsigned kernel code directly — but they can load a legitimate, signed driver that contains a known vulnerability, then exploit that vulnerability to gain kernel-mode code execution. The driver is signed, so Driver Signature Enforcement (DSE) allows it. Once the driver is loaded and the vulnerability exploited, the attacker has Ring 0 access. From Ring 0, they can: disable Secure Boot by writing to firmware via kernel APIs, disable HVCI (Hypervisor-Protected Code Integrity), modify PatchGuard structures, and install rootkit code. Real examples include BlackByte ransomware using a vulnerable RTCore64 driver, Lazarus Group using Dell's dbutil_2_3.sys, and multiple ransomware groups using gigabyte driver vulnerabilities. Microsoft's Vulnerable Driver Blocklist (enforced via HVCI) is the primary defense — it prevents known-vulnerable drivers from loading even though they have valid signatures.

3. Why does BitLocker require TPM rather than just a password for maximum security?

A password-only BitLocker configuration protects the disk from someone who doesn't know the password — but it doesn't protect against an attacker who can modify the boot environment before the password prompt appears. The classic attack: boot from a USB drive, replace the bootloader or kernel with a malicious version that captures the password when the user types it, reboot, let the user unlock the drive, then use the captured password to decrypt. This is the "evil maid attack." TPM-backed BitLocker defends against this by sealing the encryption key to specific PCR values — the TPM will only release the disk key if the boot sequence matches exactly what it measured when BitLocker was set up. If an attacker modifies the bootloader, the PCR values change, the TPM refuses to release the key, and the disk stays encrypted. The attacker's malicious bootloader runs, but it can't access the encrypted data because the TPM won't cooperate. Password-only BitLocker requires you to trust that nothing in the boot path was tampered with before you typed your password — which is exactly what the attacker controls. TPM-backed BitLocker moves that trust to hardware measurements instead of to the user's visual inspection.

4. What's the security difference between an OEM Windows installation and a clean install?

OEM installations frequently include pre-installed software — drivers, utilities, bloatware — that represents additional attack surface. More importantly, OEM machines have sometimes shipped with pre-installed malware, compromised drivers, or misconfigured security settings. The Superfish affair (Lenovo, 2015) installed a root CA certificate that allowed HTTPS traffic interception. Several OEM vendors have shipped with self-signed root certificates that could be exploited for man-in-the-middle attacks. From a security perspective, a clean Windows installation from Microsoft media, verified by checking the ISO hash against Microsoft's published values, starts from a known-good state. An OEM image starts from a state defined by a third party whose security practices may not match yours. For sensitive environments — forensics workstations, security tools, privileged access workstations — always prefer clean installation from verified media over OEM images.

5. Does disabling Secure Boot affect the TPM's measured boot values?

Yes. The Secure Boot configuration — including whether it's enabled and the contents of the key databases — is measured into TPM PCR 7 during the UEFI boot process. If you disable Secure Boot, PCR 7 gets a different value than it had when Secure Boot was enabled. If BitLocker was sealed to PCR 7, disabling Secure Boot will cause BitLocker to stop auto-unlocking and prompt for the recovery key. This is the correct security behavior — Secure Boot state is a meaningful security property that BitLocker should care about. The practical consequence: an attacker who wants to disable Secure Boot to load a bootkit, and also wants to read BitLocker-encrypted data, needs both the firmware access to disable Secure Boot AND the BitLocker recovery key. Without the recovery key, disabling Secure Boot gets them the ability to run unsigned code at boot time, but they still can't read the encrypted disk contents.