Xeno Kovah && Corey Kallenberg

Slides:



Advertisements
Similar presentations
Computing Systems Organization
Advertisements

INPUT-OUTPUT ORGANIZATION
1 Dynamic DNS. 2 Module - Dynamic DNS ♦ Overview The domain names and IP addresses of hosts and the devices may change for many reasons. This module focuses.
1 SECURE-PARTIAL RECONFIGURATION OF FPGAs MSc.Fisnik KRAJA Computer Engineering Department, Faculty Of Information Technology, Polytechnic University of.
Institute of Technology Sligo - Dept of Computing Cisco IOS & Router Config Semester 2V2 Chapter 7 Chapter 8.
CCNA 2 v3.1 Module 2.
Compact Flash for CoolRunner™-II CPLDs. Quick Start Training Agenda Introduction What is Compact Flash? CoolRunner-II Implementation Block Diagram Applications.
INPUT-OUTPUT ORGANIZATION
Troubleshooting Hardware Issues Lesson 5. Objectives 2.
Cisco IOS & Router Config Semester 2V2 Chapter 6.
Tel : 同济大学软件学院 UEFI 与固件程序设计.
Computer Organization
Booting in Windows XP Presented and Designed By: Luke Ladd.
Computer Maintenance Unit Subtitle: Basic Input/Output System (BIOS) Excerpted from 1 Copyright © Texas Education Agency, All.
Kenichi Kourai (Kyushu Institute of Technology) Takuya Nagata (Kyushu Institute of Technology) A Secure Framework for Monitoring Operating Systems Using.
A+ Guide to Software Managing, Maintaining and Troubleshooting THIRD EDITION Chapter 9 Managing Memory.
What is system software and what are its parts? Programs that control operation of computer Two parts are operating systems utility programs.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
Firmware Storage : Technical Overview Copyright © Intel Corporation Intel Corporation Software and Services Group.
Ch.2 – Introduction to Routers
Access-Lists Securing Your Router and Protecting Your Network.
SKILL AREA: 1.2 MAIN ELEMENTS OF A PERSONAL COMPUTER.
Advanced x86: BIOS and System Management Mode Internals SPI Flash Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Advanced x86: BIOS and System Management Mode Internals Input/Output
Advanced x86: BIOS and System Management Mode Internals PCI
Advanced x86: BIOS and System Management Mode Internals Conclusion Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Xeno Kovah && Corey Kallenberg LegbaCore, LLC
Advanced x86: BIOS and System Management Mode Internals System Management Mode (SMM) Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals SPI Flash Programming Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals SMRAM (System Management RAM) Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Introduction
Advanced x86: BIOS and System Management Mode Internals SPI Flash Protection Mechanisms Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Memory Map Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Boot Process Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Xeno Kovah && Corey Kallenberg
Advanced x86: BIOS and System Management Mode Internals Flash Descriptor Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Ch.2 – Introduction to Routers CCNA 2 version 3.0 Rick Graziani Cabrillo College.
Advanced x86: BIOS and System Management Mode Internals SMM & Caching Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Computer Maintenance I
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
1 Pertemuan 3 Operating Cisco IOS Software. Discussion Topics The purpose of Cisco IOS software Router user interface Router user interface modes Cisco.
Advanced x86: BIOS and System Management Mode Internals SMI Suppression Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Lecture 2. General-Purpose Computer Systems Prof. Taeweon Suh Computer Science Education Korea University ECM586 Special Topics in Embedded Systems.
Memory Interface EEE 365 [FALL 2014] LECTURER 12 ATANU K SAHA BRAC UNIVERSITY.
Homework Reading Machine Projects Labs
Chapter 6: BIOS.
Computing Systems Organization
Computer Maintenance Unit Subtitle: Basic Input/Output System (BIOS)
COMBINED PAGING AND SEGMENTATION
Discovering Computers 2011: Living in a Digital World Chapter 4
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Introduction of microprocessor
The PCI bus (Peripheral Component Interconnect ) is the most commonly used peripheral bus on desktops and bigger computers. higher-level bus architectures.
CS703 - Advanced Operating Systems
Introduction to Computers
Booting Up 15-Nov-18 boot.ppt.
Xeno Kovah && Corey Kallenberg LegbaCore, LLC
Chapter 2: System Structures
Cisco IOS & Router Config
Option ROM Designs for UEFI
Hardware Security – Highlevel Survey Review for Exam 4
BIOS Chapter 6.
Branch instructions We’ll implement branch instructions for the eight different conditions shown here. Bits 11-9 of the opcode field will indicate the.
Review: The whole processor
Presentation transcript:

Xeno Kovah && Corey Kallenberg Advanced x86: BIOS and System Management Mode Internals PCI {Option/Expansion} ROMs Xeno Kovah && Corey Kallenberg LegbaCore, LLC

All materials are licensed under a Creative Commons “Share Alike” license. http://creativecommons.org/licenses/by-sa/3.0/ Attribution condition: You must indicate that derivative work "Is derived from John Butterworth & Xeno Kovah’s ’Advanced Intel x86: BIOS and SMM’ class posted at http://opensecuritytraining.info/IntroBIOS.html” Attribution condition: You must indicate that derivative work "Is derived from John Butterworth & Xeno Kovah’s ’Advanced Intel x86: BIOS and SMM’ class posted at http://opensecuritytraining.info/IntroBIOS.html”

https://trmm.net/Thunderstrike_31c3

Pierre Chifflier, UEFI and PCI Bootkits, PacSec 2013 [34] http://www.zenzoneforum.com/attachment.php?attachmentid=16863&d=1341138411

Thunderstrike 2: Sith Strike TWO SIGMA Thunderstrike 2: Sith Strike http://img4.wikia.nocookie.net/__cb20111224062752/starwars/images/7/73/TFUII-Force_Lightning.png Trammell Hudson – Two Sigma Xeno Kovah, Corey Kallenberg – LebgaCore

PCI/PCIe Expansion ROMs (XROMs) aka Option ROMs (OROMs) A PCI/PCIe Expansion ROM is x86 native executable code located on a PCI device Can technically have multiple architectures’ native code on it, so that the device can load just as well on a PPC device as an x86 one. Not every device will have one Graphics cards, network cards will likely have one A device can have multiple XROMs (for multiple architectures) Benign or otherwise this code gets executed by the CPU/BIOS during the boot process They are handled the same on PCI Express as they are in PCI They are configured via a separate BAR called the Expansion ROM Base Address Register

Expansion ROMs XROMs have their own BAR called the Expansion ROM Base Address Register On general type PCI devices it’s located at offset 30h On bridge type devices it’s at 38h BIOS initializes the XROM BAR like the other BARs, but hands off execution control to the code it points to XROMs are copied to memory before being executed On legacy systems they are copied to C0000 to DFFFFh range The XROM BAR operates similarly to the other BARs but the interpretation of the field’s bits is slightly different *** UEFI XROM location

Expansion ROM Base Address Register The LSB determines whether accesses to the Expansion ROM are permitted. When asserted to 1, they are permitted Even when a device has an Expansion ROM, its BAR may still be 0 (meaning access to it is not permitted) Like the PCI BARs, the Expansion ROM BAR is also R/W

Command Register and Address Space Access 1 An expansion ROM will only respond to accesses if the Expansion ROM Enable bit and the memory space bit in the Command Register are both set Basically think of it as the PCI device has some default state, e.g. telling you whether it is 32 or 64 bit, whether it is prefetchable, whether it wants to map something into memory or IO, etc. The BIOS then comes along and saves this information, queries the mapping size by doing the write-1s, and then maps it wherever it wants to, and sets the appropriate command bits 1

How CPU/BIOS Discovers XROMs 1111 1111 1111 1111 1111 1 Expansion ROM Base Address Register CPU/BIOS writes FFFF_F800h To determine whether the device has implemented an Expansion ROM base: All 1’s are written to the top 21 bits (31:11) of the Expansion ROM BAR If the device returns anything other than 0, then it has implemented an Expansion ROM I have seen it written that 1’s are written to all bits except bit 0. I know I read it but can’t cite the source. I’ve tried it both ways and get the same output either way. I choose the above way since this is how the Linux kernel does it (PCI_ROM_ADDRESS_MASK = ~7FFUL)

How CPU/BIOS Discovers XROMs 1111 1111 1111 1110 0000 0 Expansion ROM Base Address Register Device returns FFFE_0000h The return address indicates both the size of the ROM and the memory alignment (mask) required by the ROM: Per the above example: Size = ~FFFE_0000 +1 = 2_0000h bytes ROM must be mapped to a 128KB-aligned memory address So addresses like XXX00000, XXX20000, XXX40000, etc I have seen it written that 1’s are written to all bits except bit 0. I know I read it but can’t cite the source. I’ve tried it both ways and get the same output either way. I choose the above way since this is how the Linux kernel does it (PCI_ROM_ADDRESS_MASK = ~7FFUL)

How CPU/BIOS Discovers XROMs 1 ( Some memory address ) Expansion ROM Base Address Register CPU/BIOS maps the ROM and enables it Next the CPU/BIOS maps the ROM to an unused portion of memory Then it sets the enable bit so that the ROM is now accessible at the address defined by the BIOS I have seen it written that 1’s are written to all bits except bit 0. I know I read it but can’t cite the source. I’ve tried it both ways and get the same output either way. I choose the above way since this is how the Linux kernel does it (PCI_ROM_ADDRESS_MASK = ~7FFUL)

How CPU/BIOS Discovers XROMs CPU/BIOS checks memory for Option ROM structure If anything other than the “AA55” signature is present, there is actually no Option ROM provided by the device, despite the fact that it returns a mask as if there were I have some ice cream. Want a lick? Psych! There may still be an option ROM, however, some companies implement them in non-standard ways I have seen it written that 1’s are written to all bits except bit 0. I know I read it but can’t cite the source. I’ve tried it both ways and get the same output either way. I choose the above way since this is how the Linux kernel does it (PCI_ROM_ADDRESS_MASK = ~7FFUL) PCI Express Revision 3.0

CPU/BIOS Expansion ROM Discovery A PCI device can share a decoder between the Expansion ROM BAR and other BARs For example: Some vendors mirror their Expansion ROMs at BAR[n] or at an offset from BAR[n] NVidia sometimes puts them at BAR[0] + 30_0000h (per the developers of Flashrom ) http://flashrom.org/Flashrom It is possible that there simply is no Expansion ROM present on the device Could be located in a compressed module in the BIOS binary This whole process is wonky. The nVidia graphics XROM is at EFFE_0000h and there is NO rhyme or reason as to why that is (at least not per the PCI spec) Writing FFFFF800 to the XROM BAR returns FFFE_0000h. So close… what’s the connection???

Expansion ROM Discovery: User Example (Same as BIOS) This example pertains to the nVidia VGA card on the E6400 laptop Verify that the memory-enable space bit 1 in the command register (offset 04h) is asserted Writing FFFF_F800h to offset 30h returns FFFE_0000h indicating that an Expansion ROM [might be] present Bit 17 is the LSB, which indicates a 128KB ROM Size = ~FFFE_0000 + 1 = 2_0000h bytes

Expansion ROM Discovery: User Example (Same as BIOS) 00100001 We (or the BIOS) should be able to choose a memory address for the ROM to be mapped to Address must meet alignment requirements Address must provide enough room for the XROM Must enable the XROM decoding (assert bit 0, enable)

Expansion ROM Discovery: User Example (Same as BIOS) 00100001 If there is anything other than the “AA55” XROM signature, then there is actually no option ROM present As it turns out, in this case, there is no option ROM located on the device This option ROM is located on the BIOS flash as a compressed module

Expansion ROM Hacking Hacking an Expansion ROM typically requires reflashing the firmware on the device Often the “RO” in “ROM” is a misnomer Although in the case we just saw, modifying the BIOS itself could permit an attacker to insert a malicious XROM If a vendor offers a utility to update the flash then you know the flash is writeable Good reference on XROM hacking: http://resources.infosecinstitute.com/pci-expansion-rom/ It’s important for Option ROMs to be measured (measured boot) before being executed

Secure Boot Systems that support UEFI/Windows 8 Secure Boot require XROMs to be signed before it will execute them Assuming you didn’t turn off SecureBoot Apple systems don’t support SecureBoot, therefore what worked in 2012 still works today The fact that systems load XROMs off external peripherals like the Thunderbolt Ethernet adapter make it just that much easier to attack Macs this way

References https://sites.google.com/site/pinczakko/building-a-kernel-in-pci-expansion-rom (Darmawan Salihun) http://www.blackhat.com/presentations/bh-dc-07/Heasman/Paper/bh-dc-07-Heasman-WP.pdf (John Heasman) http://pacsec.jp/psj13/psj2013-day2_Pierre_pacsec-uefi-pci.pdf (Pierre Chifflier) http://ho.ax/downloads/De_Mysteriis_Dom_Jobsivs_Black_Hat_Slides.pdf (Snare) https://trmm.net/Thunderstrike (Trammel Hudson) http://legbacore.com/Research_files/ts2-blackhat.pdf (Trammel Hudson, Xeno Kovah, Corey Kallenberg)