Intel BootGuard PDF
Intel BootGuard PDF
Intel BootGuard
Alexander Ermolov
#whoami
Security researcher at
a.ermolov@dsec.ru
flothrone@gmail.com
2
#disclaimer
3
Intel x86 platform firmware
4
Desktop (Laptop) system overview
Display
CPU
DRAM
PCI-E 3.0
Execution environments: DDR4
Skylake
• Intel CPU
DMI 3.0
• Intel chipset subsystems PCH Flash memory
HDD
• ACPI EC SATA3
SPI
PCI-E + SMLink
TPM 1.2\TPM 2.0
Platform firmware is
stored on common SPI USB eSPI LPC
flash memory
NIC PHY
6
Intel CPU
Skylake
Privilege levels:
Ring 3 User Mode
…
Ring 0 Kernel Mode
Ring -1 Hypervisor Mode
Ring -2 System Management Mode (SMM)
7
Intel CPU
Root of Trust
8
Intel ME
Chipset subsystem integrated into:
• Q-type chipsets since 960 series (2006)
Intel ME 2.x – 5.x
• All chipsets since 5 series (2010)
Intel ME 6.x – 11.x, TXE 1.x – 3.x, SPS 1.x – 4.x
Platforms affected:
• Desktop, Laptop Intel Management Engine (ME)
• Mobile Intel Trusted Execution Engine (TXE)/Security Engine
• Server Intel Server Platform Services (SPS)
9
Intel ME
Intel
CPU DDR
DRAM
Most privileged and hidden
execution environment (Ring -3): IMC
SPI flash
memory DMI
• Hidden from CPU runtime
memory in DRAM SPI Intel chipset
BIOS
• Full access to DRAM ME
• Working even when CPU is in S5 ME FW ME UMA
(system shutdown) MEI (HECI)
• Out-of-Band (OOB) access to NIC MAC NIC MAC
network interface
• Runs firmware (based on RTOS PCI-E
ThreadX) from common SPI flash
NIC PHY
10
Intel ME
Internal bus
ROM
• ARC (ARC32/ARCompact) Interrupt
Cryptography
controller
• TXE 1.x – 2.x engine
C-Link
• SPARC HPT\WDT
DMA
• ME 11.x, SPS 4.x, TXE 3.x Memory
• x86 HECI
controllers
11
Intel ME
Root of Trust
12
ME FW code partition Intel ME
ME ROM Partition manifest
Bootcode Manifest header
Intel ME FW is divided RSA2048
into partitions of various SHA256 hash
pubkey
type: RSA2048
signature
• Code
Code modules table
• Data
Module 0 header
• File System SHA256 hash Code module 0
•… Module 1 header
SHA256 hash Code module 1
Code partitions
... ...
Module N header
verification flow -> SHA256 hash Code module N
13
Intel Integrated Sensor Hub (ISH)
Integrated in Intel SoC since ? Bay Trail ?
14
Advanced Control and Power Interface (ACPI)
Embedded Controller (EC)
MCU, present only on laptops to make power-management and ACPI-related
features:
• Fn-buttons
• Touchpad/keyboard
• Battery supply
• …
15
BIOS protection mechanisms
• Hardware Write Protect jumper
• Protected Range (PR) registers
• BLE (BIOS_WE)
• SMM_BWP
• Intel BIOS Guard (PFAT)
• Intel Boot Guard
Though some vendors using a few of these, but there are always many
that don’t care…
16
Intel Boot Guard 1.x *
17
Intel Boot Guard
Operating modes:
• Measured Boot (MB)
• Verified Boot (VB)
• MB + VB
18
Intel BG. Measured Boot
Measure (data):
PCR = H(PCR | H(data))
19
Intel BG. Verified Boot
20
Intel BG. Configuration
21
Intel Boot Guard
22
Intel BG. Configuration
typedef struct BG_PROFILE
{
unsigned long Force_Boot_Guard_ACM : 1;
unsigned long Protect_BIOS_Environment : 1;
unsigned long CPU_Debugging : 1;
unsigned long BSP_Initialization : 1;
unsigned long Measured_Boot : 1;
unsigned long Verified_Boot : 1;
unsigned long Key_Manifest_ID : 4;
unsigned long Enforcement Policy : 2; // 00b – do nothing
// 01b – shutdown timeout
// 11b – immediate shutdown
unsigned long : 20;
};
23
Intel BG. Configuration
BG profiles
• No_FVME Disabled
• VE VB, shutdown timeout
• VME VB + MB, shutdown timeout
• VM VB + MB, do nothing
• FVE VB, immediate shutdown
• FVME VB + MB, immediate shutdown
24
Intel BG. Configuration
25
Intel BG. Verification flow
26
Researched systems
Let’s take a deeper look on BG implementation…
27
Intel CPU boot ROM
28
Intel CPU boot ROM
Intel CPU
0xFFFFFFC0
29
Intel CPU boot ROM
The FIT is a table of few entries and the first entry is a FIT header
30
Intel CPU boot ROM
Other FIT entries have the same format
They describes Intel blobs that are to be parsed\executed before the BIOS,
hence before the Legacy RESET-vector (0xFFFFFFF0)
31
Intel CPU boot ROM
enum FIT_ENTRY_TYPES
{
FIT_HEADER = 0,
MICROCODE_UPDATE,
BIOS_ACM,
BIOS_INIT = 7,
TPM_POLICY,
BIOS_POLICY,
TXT_POLICY,
BG_KEYM,
BG_IBBM
};
32
Intel CPU boot ROM
typedef struct BIOS_ACM_HEADER
{
unsigned short ModuleType; // 2
unsigned short ModuleSubType; // 3
unsigned long HeaderLength; // in dwords
unsigned long : 32;
unsigned long : 32;
unsigned long ModuleVendor; // 8086h
unsigned long Date; // in BCD format
unsigned long TotalSize; // in dwords
unsigned long unknown1[6];
unsigned long EntryPoint;
unsigned long unknown2[16];
unsigned long RsaKeySize; // in dwords
unsigned long ScratchSize; // in dwords
unsigned char RsaPubMod[256];
unsigned long RsaPubExp;
unsigned char RsaSig[256];
};
33
Intel CPU Intel CPU boot ROM
RESET SPI flash
Intel CPU FIT
boot ROM
Intel BIOS
Intel BIOS ACM
ACM
0xFFFFFFC0
34
Intel BIOS ACM
35
Intel BIOS ACM
Parse FIT:
1) Retrieve hash of OEM Root Pubkey and Boot Policies from Intel ME
2) Locate Key Manifest (KEYM) and verify it
3) Locate IBB Manifest (IBBM) and verify it
36
Intel CPU boot ROM
enum FIT_ENTRY_TYPES
{
FIT_HEADER = 0,
MICROCODE_UPDATE,
BIOS_ACM,
BIOS_INIT = 7,
TPM_POLICY,
BIOS_POLICY,
TXT_POLICY,
BG_KEYM,
BG_IBBM
};
37
Intel CPU Intel CPU boot ROM
RESET SPI flash
Intel CPU FIT
boot ROM
Intel BIOS
Intel BIOS ACM
ACM
KEYM
IBBM
FPFs
0xFFFFFFC0
Intel ME
38
Intel BIOS ACM
typedef struct KEY_MANIFEST
{
char Tag[8]; // ‘__KEYM__’
unsigned char : 8; // 10h
unsigned char : 8; // 10h
unsigned char : 8; // 0
unsigned char : 8; // 1
unsigned short : 16; // 0Bh
unsigned short : 16; // 20h == hash size?
unsigned char IbbmKeyHash[32]; // SHA256 of an IBBM public key
BG_RSA_ENTRY OemRootKey;
};
39
Intel BIOS ACM
typedef struct BG_RSA_ENTRY
{
unsigned char : 8; // 10h
unsigned short : 16; // 1
unsigned char : 8; // 10h
unsigned short RsaPubKeySize; // 800h
unsigned long RsaPubExp;
unsigned char RsaPubKey[256];
unsigned short : 16; // 14
unsigned char : 8; // 10h
unsigned short RsaSigSize; // 800h
unsigned short : 16; // 0Bh
unsigned char RsaSig[256];
};
40
Intel BIOS ACM
typedef struct IBB_MANIFEST
{
ACBP Acbp; // Boot policies
41
Intel BIOS ACM
typedef struct ACBP
{
char Tag[8]; // ‘__ACBP__’
unsigned char : 8; // 10h
unsigned char : 8; // 1
unsigned char : 8; // 10h
unsigned char : 8; // 0
unsigned short : 16; // x & F0h = 0
unsigned short : 16; // 0 < x <= 400h
};
42
Intel BIOS ACM
typedef struct IBBS
{
char Tag[8]; // ‘__IBBS__’
unsigned char : 8; // 10h
unsigned char : 8; // 0
unsigned char : 8; // 0
unsigned char : 8; // x <= 0Fh
unsigned long : 32; // x & FFFFFFF8h = 0
unsigned long Unknown[20];
unsigned short : 16; // 0Bh
unsigned short : 16; // 20h == hash size ?
unsigned char IbbHash[32]; // SHA256 of an IBB
unsigned char NumIbbDescriptors;
};
43
Intel BIOS ACM
Initial Boot Block (IBB) content is described in IBB_DESCRIPTORS
So the concatenation of blocks (usually all SEC/PEI modules in UEFI image) that are
pointed by IBB descriptors forms the IBB
44
Intel BIOS ACM
typedef struct PMSG
{
char Tag[8]; // ‘__PMSG__’
unsigned char : 8; // 10h
BG_RSA_ENTRY IbbKey;
};
45
Intel CPU Intel CPU boot ROM
RESET SPI flash
IBB
Intel CPU FIT
boot ROM
Intel BIOS
Intel BIOS ACM
ACM
KEYM
IBBM
IBB
FPFs BIOS
0xFFFFFFC0
Intel ME
46
IBB
Hence, the SEC/PEI code is verified before the CPU starts executing from the
RESET vector (FFFFFFF0h)
Then the BootGuard supporting code in PEI must verify the DXE volumes
47
IBB
48
LenovoVerifiedBootPei
if (EFI_PEI_SERVICES->GetBootMode() != BOOT_ON_S3_RESUME)
{
if (!FindHashTable())
return EFI_NOT_FOUND;
if (!VerifyDxe())
return EFI_SECURITY_VIOLATION;
}
49
LenovoVerifiedBootPei
Hash table PEI module {389CC6F2-1EA8-467B-AB8A-78E769AE2A15}
typedef struct HASH_TABLE
{
char Tag[8]; // ‘$HASHTBL’
unsigned long NumDxeDescriptors;
DXE_DESCRIPTORS[];
};
50
BootGuardPei
int bootMode = EFI_PEI_SERVICES->GetBootMode();
if (!VerifyDxe())
return EFI_SECURITY_VIOLATION;
}
51
BootGuardPei
Hash table PEI module {389CC6F2-1EA8-467B-AB8A-78E769AE2A15}
52
Safeguarding rootkits
53
The issue
One day I found out that some systems have the SPI flash regions unlocked
and the BootGuard configuration not set (nor enabled, nor disabled):
• All Gigabyte systems
• All MSI systems
• 21 Lenovo branded notebook machine types and 4 ThinkServer machine
types
• other few vendors I cannot mention at the moment
That’s because of the close manufacturing fuse was not set at the end of the
manufacturing line.
54
Lenovo statement
«Lenovo has released fixes for the affected products, which can be
found at https://support.lenovo.com/solutions/LEN_9903 or via our
security advisory website,
https://support.lenovo.com/product_security, and we have adjusted
manufacturing processes, where necessary, to prevent reoccurrence of
this issue in the future. We sincerely appreciate Mr. Ermolov's
responsible disclosure and partnership in this matter.»
55
Intel statement
56
Safeguarding rootkits
This will permanently enable Intel BG on the system and will protect
modified BIOS
57
DEMO
58
Safeguarding rootkits
59
Safeguarding rootkits
• to create hidden, black box and irremovable (even with SPI flash
programmer) rootkit on a platform
• to modify the ISH firmware on the platform which opens a new attack
surface
60
Safeguarding rootkits
61
Conclusion
63
Mitigation
64
Mitigation
65
Mitigation
66
Thank you
67