BIOS and Secure Boot Attacks Uncovered Ruxcon 2014
Advanced Threat Research, Intel Security John Loucaides (presenting)
BIOS and Secure Boot Attacks Uncovered Ruxcon 2014 Advanced Threat - - PowerPoint PPT Presentation
BIOS and Secure Boot Attacks Uncovered Ruxcon 2014 Advanced Threat Research, Intel Security John Loucaides (presenting) In n The he Be Begi ginnin nning Was as The he Leg egacy acy BI BIOS.. S.. Leg egacy acy BI BIOS 1. CPU
BIOS and Secure Boot Attacks Uncovered Ruxcon 2014
Advanced Threat Research, Intel Security John Loucaides (presenting)
In n The he Be Begi ginnin nning Was as The he Leg egacy acy BI BIOS.. S..
Leg egacy acy BI BIOS
1. CPU Reset vector in BIOS ’ROM’ (Boot Block) 2. Basic CPU, chipset initialization 3. Initialize Cache-as-RAM, load and run from cache 4. Initialize DIMMs, create address map.. 5. Enumerate PCIe devices.. 6. Execute Option ROMs on expansion cards 7. Load and execute MBR 8. 2nd Stage Boot Loader OS Loader OS kernel
Also Technical Note: UEFI BIOS vs. Legacy BIOS, Advantech
The hen n Wor
ld Mo Moved ed to
EFI..
UEFI FI Bo Boot
From Secure Boot, Network Boot, Verified Boot, oh my and almost every publication on UEFI
UEFI FI [C [Complian mpliant] t] Fi Firmwar mware
SEC Pre-EFI Init (PEI) Driver Exec Env (DXE) Boot Dev Select (BDS) Runtime / OS
S-CRTM; Init caches/MTRRs; Cache-as-RAM (NEM); Recovery; TPM Init S-CRTM: Measure DXE/BDS Early CPU/PCH Init Memory (DIMMs, DRAM) Init, SMM Init Continue initialization of platform & devices Enum FV, dispatch drivers (network, I/O, service..) Produce Boot and Runtime Services Boot Manager (Select Boot Device) EFI Shell/Apps; OS Boot Loader(s)
ACPI, UEFI SystemTable, SMBIOS table CPU Reset
Si Signed gned BI BIOS OS Upd pdate e & O & OS S Se Secu cure e Bo Boot
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders (winload.efi, winresume.efi) System Firmware (SEC/PEI) UEFI OROM UEFI Boot Loader Bootx64.efi Bootmgfw.efi
Signed BIOS Update
UEFI OROM UEFI App UEFI App DXE Driver DXE Driver OS Kernel / Early Launch Anti-Malware (ELAM)
UEFI Secure Boot
OS Driver OS Driver
Windows 8 Secure Boot
Attacks acks Aga gains nst t Pla latf tform
Firmwar mware... e...
BI BIOS OS Attac ack k Su Surface: face: SP SPI Fla I Flash h Pr Protection ection System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
SP SPI I Fl Flas ash h Wr Writ ite e Pr Protection ection
BIOS_CONTROL[SMM_BWP]
PR4 in SPI MMIO), they often don’t cover entire BIOS & NVRAM
for boot block/startup code or SPI Flash descriptor region
tion: n: BIOS_CONTROL[SMM_BWP] = 1 and SPI PRx
Ch Chec ecking king Ma Manu nually.. ally..
Windows: RWEverything Linux:
setpci -s 00:1F.0 DC.B
Better er Way y to Che heck ck If If Your r BIO IOS S Is Is Wr Write-Protect ected ed
[*] running module: chipsec.modules.common.bios_wp [x][ ======================================================================= [x][ Module: BIOS Region Write Protection [x][ ======================================================================= [*] BIOS Control = 0x02 [05] SMM_BWP = 0 (SMM BIOS Write Protection) [04] TSS = 0 (Top Swap Status) [01] BLE = 1 (BIOS Lock Enable) [00] BIOSWE = 0 (BIOS Write Enable) [!] Enhanced SMM BIOS region write protection has not been enabled (SMM_BWP is not used) [*] BIOS Region: Base = 0x00500000, Limit = 0x007FFFFF SPI Protected Ranges
PR1 (78) | 00000000 | 00000000 | 00000000 | 0 | 0 PR2 (7C) | 00000000 | 00000000 | 00000000 | 0 | 0 PR3 (80) | 00000000 | 00000000 | 00000000 | 0 | 0 PR4 (84) | 00000000 | 00000000 | 00000000 | 0 | 0 [!] SPI protected ranges write-protect parts of BIOS region (other parts of BIOS can be modified) [!] BIOS should enable all available SMM based write protection mechanisms or configure SPI protected ranges to protect the entire BIOS region [-] FAILED: BIOS is NOT protected completely
# chipsec_main.py --module common.bios_wp
SP SPI I Fl Flas ash h & B & BIO IOS S Is Is No Not Wr Writ ite e Pr Protect ected ed
(Insecure SPI Flash Protection)
From Analytics, and Scalability, and UEFI Exploitation by Teddy Reed Patch attempts to enable BIOS write protection (sets BIOS_CONTROL[BLE]). Picked up by Subzero
SP SPI I Fl Flas ash h Wr Writ ite e Pr Protection ection
(BIOSWE) and setting BIOS Lock Enable (BLE) but don’t use SMM based write-protection BIOS_CONTROL[SMM_BWP]
BIOS didn’t lock SMI config: Setup for Failure: Defeating SecureBoot
er varian iant is to disable specific TCO SMI source used for BIOSWE/BLE (clear SMI_EN[TCO_EN] if BIOS didn’t lock TCO config.)
Mitigation: tion: BIOS_CONTROL[SMM_BWP] = 1 and lock SMI config
SMI Suppression Attack Variants
Are e All ll Req equi uired ed SM SMIs Is Ena nabl bled ed an and L d Lock cked ed?
[*] running module: chipsec.modules.common.bios_smi [x][ ======================================================================= [x][ Module: SMI Events Configuration [x][ ======================================================================= [-] SMM BIOS region write protection has not been enabled (SMM_BWP is not used) [*] PMBASE (ACPI I/O Base) = 0x0400 [*] SMI_EN (SMI Control and Enable) register [I/O port 0x430] = 0x00002033 [13] TCO_EN (TCO Enable) = 1 [00] GBL_SMI_EN (Global SMI Enable) = 1 [+] All required SMI events are enabled [*] TCOBASE (TCO I/O Base) = 0x0460 [*] TCO1_CNT (TCO1 Control) register [I/O port 0x468] = 0x1800 [12] TCO_LOCK = 1 [+] TCO SMI configuration is locked [*] GEN_PMCON_1 (General PM Config 1) register [BDF 0:31:0 + 0xA0] = 0x0A14 [04] SMI_LOCK = 1 [+] SMI events global configuration is locked [+] PASSED: All required SMI sources seem to be enabled and locked!
SP SPI I Fl Flas ash h Wr Writ ite e Pr Protection ection
MMIO) to provide write protection of regions of SPI Flash
down by BIOS via Flash Lockdown
FLOCKDN bit in HSFSTS SPI MMIO register), malware can disable SPI protected ranges re-enabling write access to SPI Flash
Locking SPI Flash Configuration
Is Is SP SPI I Fl Flas ash h Configur figuration tion Lock cked ed?
[+] imported chipsec.modules.common.spi_lock [x][ ======================================================================= [x][ Module: SPI Flash Controller Configuration Lock [x][ ======================================================================= [*] HSFSTS register = 0x0004E008 FLOCKDN = 1 [+] PASSED: SPI Flash Controller configuration is locked
BI BIOS OS Attac ack k Su Surface: face: BI BIOS S Upd pdate System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Leg egacy acy BI BIOS S Upd pdate e an and Sec d Secur ure e Bo Boot
components
ROM with legitimate BIOS image mod utility
patched BIOS binary Signed BIOS Updates
No Signature Checks of OS boot loaders (MBR)
UEFI FI BI BIOS OS Upd pdate e Pr Prob
lems
logo BMP image)
protection was enabled
memory corruption during DXE while parsing BMP image
Parsing of Unsigned BMP Image in UEFI FW Update Binary
UEFI FI BI BIOS OS Upd pdate e Pr Prob
lems
DRAM split into RBU packets
image from RBU packets in SMRAM and verifies signature
when copying RBU packet to a buffer with reconstructed BIOS image
RBU Packet Parsing Vulnerability
UEFI FI BI BIOS OS Upd pdate e Pr Prob
lems
update is called, BIOS parses the data provided by the attacker.
made contiguous, an integer overflow allowed attackers to control a memory copy operation.
parsed, an integer overflow allowed attackers to cause a small allocation and large memory copy operation.
Recent Capsule Update Issues
BI BIOS OS Attac ack k Su Surface: face: SM SMRA RAM M Pr Protectio ection System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
configuration (SMRAMC)
decode to system bus rather than to DRAM where SMI handlers are when CPU is not in System Management Mode (SMM)
changed to open access to CSEG when CPU is not in SMM: Using CPU SMM to Circumvent OS Security Functions
Unlocked Compatible/Legacy SMRAM
Compa patible ible SM SMM M Sp Spac ace: e: No Normal mal Dec ecode de
0xBFFFF
Compatible SMRAM (CSEG)
SMM access s to CSEG is decode
d to DRAM, , non-SMM access ss is sent to sy system em bus
0xA0000 Non
M acces ess
SMRA RAMC C [D_LCK] CK] = 1 1 SMRAMC C [D_O _OPEN] PEN] = 0
Compa patible ible SM SMM M Sp Spac ace: e: Unl nlock cked ed
0xBFFFF
Compatible SMRAM (CSEG)
Non-SMM MM access ss to CSEG is decode
d to DRAM where SMI handlers rs can b be modified ified
0xA0000 Non
M acces ess
SMRA RAMC C [D_LCK] CK] = 0 SMRAMC C [D_O _OPEN] PEN] = 1 1
Is Is Compa patible tible SM SMRA RAM M Lock cked? ed?
[+] imported chipsec.modules.common.smm [x][ ================================================================= [x][ Module: SMM memory (SMRAM) Lock [x][ ================================================================= [*] SMRAM register = 0x1A ( D_LCK = 1, D_OPEN = 0 ) [+] PASSED: SMRAM is locked
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
SMI exploit code (ex. modify SMBASE) and trigger SMI
and blocking access to SMRAM when CPU is not in SMM
SMRAM “Cache Poisoning” Attacks
Is Is SM SMRAM RAM Exp xposed sed To Cach che Poisoning soning Attack? tack?
[*] running module: chipsec.modules.common.smrr [x][ ======================================================================= [x][ Module: CPU SMM Cache Poisoning / SMM Range Registers (SMRR) [x][ ======================================================================= [+] OK. SMRR are supported in IA32_MTRRCAP_MSR [*] Checking SMRR Base programming.. [*] IA32_SMRR_BASE_MSR = 0x00000000BD000006 BASE = 0xBD000000 MEMTYPE = 6 [+] SMRR Memtype is WB [+] OK so far. SMRR Base is programmed [*] Checking SMRR Mask programming.. [*] IA32_SMRR_MASK_MSR = 0x00000000FF800800 MASK = 0xFF800000 VLD = 1 [+] OK so far. SMRR are enabled in SMRR_MASK MSR [*] Verifying that SMRR_BASE/MASK have the same values on all logical CPUs.. [CPU0] SMRR_BASE = 00000000BD000006, SMRR_MASK = 00000000FF800800 [CPU1] SMRR_BASE = 00000000BD000006, SMRR_MASK = 00000000FF800800 [CPU2] SMRR_BASE = 00000000BD000006, SMRR_MASK = 00000000FF800800 [CPU3] SMRR_BASE = 00000000BD000006, SMRR_MASK = 00000000FF800800 [+] OK so far. SMRR MSRs match on all CPUs [+] PASSED: SMRR protection against cache attack seems properly configured
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
“lost” for Low MMIO
Controller PCIe config. space
(above “Top Of Low DRAM”)
REMAP*, TOLUD/TOUUD
SMRAM Memory Remapping/Reclaim Attack
Me Memory ry Rem emap appi ping: ng: No Normal rmal Me Memory
Map
Memory Reclaim/Remap Range Low MMIO Range
TOLUD 4GB
SMRAM REMAPBASE REMAPLIMIT
Ac Acces ess s is remapped ped to DRAM range ‘lost’ to MMIO O (memory
recla laim imed ed)
Acc Acces ess
Memory
apping: ng: SM SMRAM RAM Remappi apping g Attack ack
Memory Reclaim/Remap Range Low MMIO Range
TOLUD 4GB
SMRAM REMAPBASE REMAPLIMIT
Target range of memory y reclaim laim changed ed to SMRAM
Acc Acces ess
Is Is Me Memory ry Rem emap appi ping ng Attack ack Possible? sible?
[*] running module: chipsec.modules.remap [x][ ======================================================================= [x][ Module: Memory Remapping Configuration [x][ ======================================================================= [*] Registers: [*] TOUUD : 0x000000013E000001 [*] REMAPLIMIT: 0x000000013DF00001 [*] REMAPBASE : 0x0000000100000001 [*] TOLUD : 0xBFA00001 [*] TSEGMB : 0xBD000001 [*] Memory Map: [*] Top Of Upper Memory: 0x000000013E000000 [*] Remap Limit Address: 0x000000013DFFFFFF [*] Remap Base Address : 0x0000000100000000 [*] 4GB : 0x0000000100000000 [*] Top Of Low Memory : 0x00000000BFA00000 [*] TSEG (SMRAM) Base : 0x00000000BD000000 [*] checking locks.. [+] TOUUD is locked [+] TOLUD is locked [+] REMAPBASE and REMAPLIMIT are locked [*] checking alignment.. [+] All REMAP*/TOUUD/TOLUD addresses are 1MB aligned [*] checking remap programming.. [*] Memory Remap is enabled [+] Remap window is programmed correctly: 4GB <= REMAPBASE <= REMAPLIMIT [+] PASSED: Memory Remap is configured correctly and locked
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
DRAM and MMIO (TOLUD) can be moved somewhere else. E.g. malware can move it below SMRAM to make SMRAM decode as MMIO
redirect MMIO access to memory range defined by PTE entries in Graphics Translation Table (GTT)
handler, access is redirected to unprotected memory range somewhere else in DRAM
configuration (i.e. TOLUD) to mitigate this attack
SMRAM Redirection via Graphics Aperture
SM SMRA RAM M Acc ccess ess in in SM SMM M : : No Normal mal Me Memory ry Ma Map
Low MMIO Range
TOLUD 4GB
SMRAM
CPU PU exec ecut utes instruction tructions s (mov) ) from
RAM normally rmally
mov ebx,imm32
Co Code de fetch h at SMBASE E in SMM
Graphics Aperture GTT MMIO
Acc Acces ess s to GFx Aper ertur ure
GFx Memory
Acc Acces ess s to GFx aper ertur ure (MMIO) MIO) is red edir irected ted to GFx DRAM M rang nge per er GTT PTEs
GTT PTEs
SM SMRA RAM M Acc ccess ess in in SM SMM M : : Red edir irect ection ion Attac ack
Low MMIO Range
TOLUD 4GB
SMRAM
CPU PU exec ecut utes s instructions tructions from
e SMRAM AM red edir irected ected to by MMIO IO GFx Fx Apert rture e per er maliciou icious s GTT PTEs Es
mov ebx,imm32
Co Code de fetch h at SMBASE E in SMM
Graphics Aperture GTT MMIO GFx Memory Fake SMRAM GTT PTEs
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
programming TSEG range
malware can move TSEG outside of where actual SMRAM is
protecting SMRAM from inbound DMA access (e.g. TSEG range)
DMA/GFx Aperture Attacks Against SMRAM
DMA MA Acc cces ess s to SM SMRA RAM: M: No Normal mal Me Memory ry Ma Map
Low MMIO Range
TOLUD 4GB
SMRAM
DMA acc cces ess to SMRAM RAM is blo locked d due to TSEG EG cover ering ing SMRAM AM TSEG Base GFx Mem Base
DMA MA Acc cces ess s to SM SMRA RAM: M: DMA MA Attacks acks
Low MMIO Range
TOLUD 4GB
SMRAM
DMA acces ess s to SMRAM RAM is not t block
d as TSEG EG Base se moved ed
Graphics Aperture GTT MMIO
Acc Acces ess s to GFx Aper ertur ure is red edir irecte cted d to SMRAM RAM TSEG Base GFx Mem Base
GTT PTEs
Is Is SM SMRA RAM M Pr Protect ected ed Fr From m DMA MA Attacks? acks?
[*] running module: chipsec.modules.smm_dma [x][ ======================================================================= [x][ Module: SMRAM DMA Protection [x][ ======================================================================= [*] Registers: [*] TOLUD : 0xBFA00001 [*] BGSM : 0xBD800001 [*] TSEGMB : 0xBD000001 [*] SMRR_BASE: 0x00000000BD000006 [*] SMRR_MASK: 0x00000000FF800800 [*] Memory Map: [*] Top Of Low Memory : 0xBFA00000 [*] TSEG Range (TSEGMB-BGSM): [0xBD000000-0xBD7FFFFF] [*] SMRR Range : [0xBD000000-0xBD7FFFFF] [*] checking locks.. [+] TSEGMB is locked [+] BGSM is locked [*] checking TSEG covers entire SMRR range.. [+] TSEG covers entire SMRAM [+] PASSED: TSEG is properly configured. SMRAM is protected from DMA attacks
BI BIOS OS Attac ack k Su Surface: face: Ha Hardw dwar are e Configur figuration ion System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Pr Prob
lems Wi With h HW HW Configur figuration/ ion/Pr Protections ections
the address targeting ROM, e.g. when CPU fetches reset vector on reboot
than from 0xFFFFFFF0
vector to alternate (backup) boot-block
General Control & Status register) & protect swap boot-block range in SPI
BIOS Top Boot-Block Swap Attack
BI BIOS OS Top S p Swap ap
Original BIOS Boot-Block 0xFFF FFFF FFFF FF0
CPU normally fetches ches reset t vector
FFFF0 F0
0xFFF FFEFFF FF0 Alternate BIOS Boot-Block (BUC[TS] = 1)
When TS i is not locked ed:
ts BUC[T [TS] S]
t, CPU st starts ts @ reset t vector
pset t inverts ts A16
ches es inst
altern rnate te BB (at FFF FFFEFFF0) FFF0) instea stead d of FFFFFFF FFFFF0
Is Is BI BIOS S In Interfa erface ce Lock cked? ed?
[+] imported chipsec.modules.common.bios_ts [x][ ======================================================================= [x][ Module: BIOS Interface Lock and Top Swap Mode [x][ ======================================================================= [*] RCBA General Config base: 0xFED1F400 [*] GCS (General Control and Status) register = 0x00000021 [10] BBS (BIOS Boot Straps) = 0x0 [00] BILD (BIOS Interface Lock-Down) = 1 [*] BUC (Backed Up Control) register = 0x00000000 [00] TS (Top Swap) = 0 [*] BC (BIOS Control) register = 0x2A [04] TSS (Top Swap Status) = 0 [*] BIOS Top Swap mode is disabled [+] PASSED: BIOS Interface is locked (including Top Swap Mode)
BI BIOS OS Attac ack k Su Surface: face: SM SMI Han I Handl dlers ers System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Leg egacy acy SM SMI Han I Handl dlers ers Ca Call lling ing Out ut of SM f SMRA RAM
Phys Memory
SMRAM
CALL F000:8070
Legacy BIOS Shadow (F/ E-segments) PA = 0xF0000
1 MB 1 MB
Leg egacy acy SM SMI Han I Handl dlers ers Ca Call lling ing Out ut of SM f SMRA RAM
Phys Memory
SMRAM
CALL F000:8070
Legacy BIOS Shadow (F/ E-segments) PA = 0xF0000
1 MB 1 MB Cod
in SMM MM
Leg egacy acy SM SMI Han I Handl dlers ers Ca Call lling ing Out ut of SM f SMRA RAM
Phys Memory
SMRAM
CALL F000:8070
Legacy BIOS Shadow (F/ E-segments) PA = 0xF0000
1 MB 1 MB
0xF8070: payload 0F00 000:080 0:08070 70 = 0xF8 F807 070 0 PA
Cod
in SMM MM
Leg egacy acy SM SMI Han I Handl dlers ers Ca Call lling ing Out ut of SM f SMRA RAM
(0xF8070 Physical Address)
just one SMI Handler)
Branch Outside of SMRAM
Function nction Pointers ers Ou Outside side of f SM SMRAM RAM (D (DXE XE SM SMI) I)
Phys Memory
SMRAM
mov ACPINV+x, %rax call *0x18(%rax)
ACPI NV Area payload
pointer from ACPI NVS memory (outside SMRAM)
Pointer to payload
pointer (payload
Attacking Intel BIOS
BI BIOS OS Attac ack k Su Surface: face: Se Secu cure e Bo Boot System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Se Secu cure e Bo Boot Key Hi Hier erar arch chy
Platform
Key Exchange ge Keys (KEK EKs) s)
Au Authoriz rized ed Databa abase se (db) Forbidden bidden Databas base e (dbx)
Pl Platform
y (Root Key) ) ha has to be be V Val alid id
PK variable able exists ts in NVRAM? AM? Yes es. . Set SetupMode variable to USER_MODE No.
Sec ecur ureBoo BootEnab tEnable le variable able exists ts in NVR VRAM? AM? Yes es
SetupMode variable is USER_MODE? Set SecureBoot variable to ENABLE
No No
Fi First t Pu Publ blic ic Wi Wind ndows ws 8 Sec 8 Secur ure e Bo Boot By Bypa pass ss
A Tale Of One Software Bypass Of Windows 8 Secure Boot
Pl Platform
y in in NVR VRAM M Ca Can n Be Be Mo Modi difie fied
Corrup upt t Platform
ariab able le in N NVRAM AM
AA0D-00E098032B8C}
enters Secure Boot SETUP_MODE when correct “PK” EFI variable cannot be located in EFI NVRAM
PK PK Mo Mod: d: Be Before e an and A d Aft fter er
Exp xploit
grams ams SP SPI I Contr troller
difies ies SP SPI I Flash sh
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders System Firmware (SEC/PEI) DXE Driver UEFI Boot Loader Bootx64.efi Bootmgfw.efi
Signed BIOS Update
DXE Driver OS Kernel OS Driver OS Exploit
Modify y Secur ure e Boot t FW or config ig in ROM
Th Then en In Installs alls UEFI FI Bo Bootkit tkit on n ESP SP
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders System Firmware (SEC/PEI) DXE Driver UEFI Bootkit
Signed BIOS Update
DXE Driver OS Kernel OS Driver OS Exploit
Insta stall UEFI I Bootkit tkit
Modified FW Doesn’t Enforce Secure Boot
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders System Firmware (SEC/PEI) DXE Driver UEFI Bootkit
Signed BIOS Update
DXE Driver OS Kernel OS Driver OS Exploit
(Bypassing Secure Boot by Corrupting Platform Key in SPI)
Turn rn On On/Of Off f Se Secur cure Boot in BIO IOS S Se Setup up
Ho How to Dis isab able le Se Secu cure e Bo Boot? t?
SecureBootEnable UEFI Variable
Hmm.. but there is no SecureBootEnable variable
Should be NV somewhere in SPI Flash..
Yea eah. h.. . Go Good Luck d Luck Wi With h Th That ;( ;(
There’s A Better Way..
Secure Boot On Secure Boot Off
Secure Boot On Secure Boot Off
Se Secu cure e Bo Boot Dis isab able le is is Rea eall lly y in in Se Setup up!
chipsec_util.py spi dump spi.bin chipsec_util.py uefi nvram spi.bin chipsec_util.py decode spi.bin
(Attack Disabling Secure Boot)
Se Secu cure e Bo Boot: : Im Imag age e Ver erifica ification tion Policies licies
DxeIm eImage geVerifi erifica catio tionLib Lib defin fines es policie icies applied lied to diff ffer eren ent t types es of images es and on securit ity violation tion
IMAGE_FROM_FV (ALWAYS_EXECUTE), IMAGE_FROM_FIXED_MEDIA, IMAGE_FROM_REMOVABLE_MEDIA, IMAGE_FROM_OPTION_ROM ALWAYS_EXECUTE, NEVER_EXECUTE, ALLOW_EXECUTE_ON_SECURITY_VIOLATION DEFER_EXECUTE_ON_SECURITY_VIOLATION DENY_EXECUTE_ON_SECURITY_VIOLATION QUERY_USER_ON_SECURITY_VIOLATION
SecurityPkg\Library\DxeImageVerificationLib http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=SecurityPkg
Se Secu cure e Bo Boot: : Im Imag age e Ver erifica ification tion Policies licies
Image Verification Policy? (IMAGE_FROM_FV) ALWAYS_EXECUTE? EFI_SUCCESS NEVER_EXECUTE? EFI_ACCESS_DENIED
Storing ring Im Imag age e Ver erifi ifica cation ion Poli licies cies in in Se Setup up
then write modified ‘Setup’ variable
Mo Modi difying fying Im Imag age e Ver erifica ificatio tion n Polici licies es
[CHIPSEC] Reading EFI variable Name='Setup' GUID={EC87D643-EBA4-4BB5-A1E5- 3F3E36B20DA9} from 'Setup_orig.bin' via Variable API.. EFI variable: Name : Setup GUID : EC87D643-EBA4-4BB5-A1E5-3F3E36B20DA9 Data : .. 01 01 01 00 00 00 00 01 01 01 00 00 00 00 00 00 | 00 00 00 00 00 00 01 01 00 00 00 04 04 | [CHIPSEC] (uefi) time elapsed 0.000 [CHIPSEC] Writing EFI variable Name='Setup' GUID={EC87D643-EBA4-4BB5-A1E5- 3F3E36B20DA9} from 'Setup_policy_exploit.bin' via Variable API.. Writing EFI variable: Name : Setup GUID : EC87D643-EBA4-4BB5-A1E5-3F3E36B20DA9 Data : .. 01 01 01 00 00 00 00 01 01 01 00 00 00 00 00 00 | 00 00 00 00 00 00 01 01 00 00 04 00 00 | [CHIPSEC] (uefi) time elapsed 0.203 OptionRomPolicy FixedMediaPolicy RemovableMediaPolicy
All llows ws By Bypa passing ssing Se Secur cure e Bo Boot
Issue was co-discovered with Corey Kallenberg, Xeno Kovah, John Butterworth and Sam Cornwell from MITRE All Your Boot Are Belong To Us, Setup for Failure: Defeating SecureBoot
(Bypassing Secure Boot via Image Verification Policies)
Ho How To Avoid id Th Thes ese? e?
1. Do not store critical Secure Boot configuration in UEFI variables accessible to potentially compromised OS kernel or boot loader
2. Set Image Verification Policies to secure values
Rec ecap ap on n Im Imag age e Ver erifica ificatio tion n Ha Hand ndle ler
SecureBoot EFI variable doesn’t exist or equals to SECURE_BOOT_MODE_DISABLE? EFI_SUCCESS File is not valid PE/COFF image? EFI_ACCESS_DENIED SecureBootEnable NV EFI variable doesn’t exist or equals to SECURE_BOOT_DISABLE? EFI_SUCCESS SetupMode NV EFI variable doesn’t exist or equals to SETUP_MODE? EFI_SUCCESS
EFI FI Exec ecutable utables
In an effort to reduce image size, a new executable image header (TE)
was created that includes only those fields from the PE/COFF headers required for execution under the PI Architecture. Since this header contains the information required for execution of the image, it can replace the PE/COFF headers from the original image. http://wiki.phoenix.com/wiki/index.php/Terse_Executable_Format
TE is is no not PE PE/COFF OFF
PE PE/TE E He Head ader er Ha Hand ndli ling ng by by the he BI BIOS
PE PE/TE E He Head ader er Ha Hand ndli ling ng by by the he BI BIOS
CORE_ E_DXE.e E.efi fi:
PE PE/TE E He Head ader er Confusion fusion
read an executable file.
PE header. It returns EFI_LOAD_ERROR if executable is not PE/COFF.
in case GetFileBuffer returns an error
ture e Check cks s ar are Skipped! d!
PE PE/TE E He Head ader er Confusion fusion
BIOS allows running TE images w/o signature check
header with TE header
(Secure Boot Bypass via PE/TE Header Confusion)
Othe her r Se Secu cure e Bo Boot t Pr Prob
lems
CSM Enabled with Secure Boot
executable fails Mitigations
Clearing Platform Key… from Software
“Clear Secure Boot keys” takes effect after reboot The switch that triggers clearing of Secure Boot keys is in UEFI Variable (happens to be in ‘Setup’ variable) But recall that Secure Boot is OFF without Platform Key PK is cleared Secure Boot is Disabled
Install Default Keys… From Where?
Default Secure Boot keys can be restored [When there’s no PK] Switch that triggers restore of Secure Boot keys to their default values is in UEFI Variable (happens to be in ‘Setup’) Nah.. Default keys are protected. They are in FV But we just added 9 hashes to the DBX blacklist
Did id You u No Notice ice Se Secu cure e Bo Boot Was as Dis isab abled? led?
The system protects Secure Boot configuration from modification but has an implementation bug Firmware stores integrity of Secure Boot settings & checks on reboot Upon integrity mismatch, beeps 3 times, waits timeout then… Keeps booting with modified Secure Boot settings
BI BIOS OS Attac ack k Su Surface: face: BI BIOS S Se Settings ings System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Ha Hand ndling ling Se Sens nsitiv itive e Data
BIOS keyboard buffer in BIOS data area (at PA = 0x41E)
Pre-Boot Passwords Exposure
Se Secr crets s in in the he K Keybo boar ard d Bu Buff ffer? er?
[*] running module: chipsec.modules.common.bios_kbrd_buffer [x][ ======================================================================= [x][ Module: Pre-boot Passwords in the BIOS Keyboard Buffer [x][ ======================================================================= [*] Keyboard buffer head pointer = 0x3A (at 0x41A), tail pointer = 0x3A (at 0x41C) [*] Keyboard buffer contents (at 0x41E): 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 | 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 | [-] Keyboard buffer tail points inside the buffer (= 0x3A) It may potentially expose lengths of pre-boot passwords. Was your password 15 characters long? [*] Checking contents of the keyboard buffer.. [+] PASSED: Keyboard buffer looks empty. Pre-boot passwords don't seem to be exposed
* Better check from EFI shell as OS/pre-boot app might have cleared the keyboard buffer
BI BIOS OS Attac ack k Su Surface: face: SM SMI Han I Handl dlers ers System FW/BIOS
SPI Flash Protection BIOS Update SMRAM Protection Hardware Config. SMI Handlers Secure Boot BIOS Settings (NVRAM, Variables) …
Wha What? ? Mo More e Is Issue ues s Wi With h SM SMI Han I Handl dlers ers ?
and platform manufacturers
Multiple UEFI BIOS SMI Handler Vulnerabilities
Do BI BIOS OS Attac acks ks Req equi uire e Ker ernel nel Pr Privilege ivileges? s?
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders System Firmware (SEC/PEI) OS Kernel OS Exploit
To attack BIOS, exploit needs access to HW:
So, gener erall lly, yes. Kernel l privilege ileges s are requir ired.. ed..
Signed OS Driver
Unl nles ess s Su Suit itabl able e Ker ernel nel Driv iver er Alr lready eady Si Sign gned ed
Hardware I/O Memory Network Graphics
UEFI DXE Core / Dispatcher UEFI OS Loaders System Firmware (SEC/PEI) OS Kernel
Legitimate signed OS kernel driver which can do all this on behalf of a user mode app (as a confused deputy). We found suitable driver signed for Windows 64bit versions (co- discovered with researchers from MITRE)
User-mode Exploit
Be Best Pr Pract actices ices
tables, ACPI NVS, CPU GP registers, HW registers..)
Key Tak akea eaways ys
CHIPSEC framework MITRE Copernicus
Newly formed USRT (UEFI Security Response Team) USST (UEFI Security) and PSST (PI Security) sub-teams
complex, system/BIOS specific, obscure & unneccessary
CHI HIPSEC SEC Frame mework
ilable No Now! w!
Growing set of modules to test for low level vulnerabilities Support for:
modules (vulnerability checks and security test tools)
Try it and contribute to platform security https:/ ps://git githu hub.c b.com
/chipse hipsec/chi /chipse psec
THANK NK YOU!
Ref: f: BI BIOS OS Se Securi curity ty Gu Guid idel elines ines / Be Best Pr Practi actices ces
Ref: f: BI BIOS OS Se Securi curity ty Res esea earch ch