Advanced x86: BIOS and System Management Mode Internals More Fun with SMM Xeno Kovah && Corey Kallenberg LegbaCore, LLC.

Slides:



Advertisements
Similar presentations
Confidential 1 Phoenix Security Architecture and DevID July 2005 Karen Zelenko Phoenix Technologies.
Advertisements

Lecture 13 Page 1 CS 111 Online File Systems: Introduction CS 111 On-Line MS Program Operating Systems Peter Reiher.
An Evaluation of the Google Chrome Extension Security Architecture
Lecture 12 Page 1 CS 111 Online Devices and Device Drivers CS 111 On-Line MS Program Operating Systems Peter Reiher.
Basic Input Output System
Crucial Security Programs Ring -1 vs. Ring -2: Containerizing Malicious SMM Interrupt Handlers on AMD-V Pete Markowsky Senior Security Researcher
Copyright © Clifford Neuman - UNIVERSITY OF SOUTHERN CALIFORNIA - INFORMATION SCIENCES INSTITUTE USC CSci530 Computer Security Systems Lecture.
IT Systems Memory EN230-1 Justin Champion C208 –
EET 2261 Unit 2 HCS12 Architecture
Jiang Wang, Joint work with Angelos Stavrou and Anup Ghosh CSIS, George Mason University HyperCheck: a Hardware Assisted Integrity Monitor.
Computers They're Not Magic! (for the most part)‏ Adapted from Ryan Moore.
OpenInfreno An Open Source RootWars Platform Dennis W. “LittleW0lf” Mattison
1 Chap 10 Malicious Software. 2 Viruses and ”Malicious Programs ” Computer “Viruses” and related programs have the ability to replicate themselves on.
Computer Organization
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Practical Malware Analysis Ch 8: Debugging Rev
1 UCR Firmware Attacks and Security introduction.
Kenichi Kourai (Kyushu Institute of Technology) Takuya Nagata (Kyushu Institute of Technology) A Secure Framework for Monitoring Operating Systems Using.
Computer Security and Penetration Testing
1 Chap 10 Virus. 2 Viruses and ”Malicious Programs ” Computer “Viruses” and related programs have the ability to replicate themselves on an ever increasing.
Processes and OS basics. RHS – SOC 2 OS Basics An Operating System (OS) is essentially an abstraction of a computer As a user or programmer, I do not.
Firmware Storage : Technical Overview Copyright © Intel Corporation Intel Corporation Software and Services Group.
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Understanding Computer Viruses: What They Can Do, Why People Write Them and How to Defend Against Them Computer Hardware and Software Maintenance.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Advanced x86: BIOS and System Management Mode Internals Tools
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 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.
Operating Systems Security
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.
Protecting Browsers from Extension Vulnerabilities Paper by: Adam Barth, Adrienne Porter Felt, Prateek Saxena at University of California, Berkeley and.
Xeno Kovah && Corey Kallenberg
Advanced x86: BIOS and System Management Mode Internals Flash Descriptor Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Xeno Kovah && Corey Kallenberg
Advanced x86: BIOS and System Management Mode Internals SMM & Caching Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Lecture 7 Page 1 CS 111 Summer 2013 Another Option Fixed partition allocations result in internal fragmentation – Processes don’t use all of the fixed.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Advanced x86: BIOS and System Management Mode Internals SMI Suppression Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
Cosc 4765 Antivirus Approaches. In a Perfect world The best solution to viruses and worms to prevent infected the system –Generally considered impossible.
Bootloaders Many embedded processors have flash memory. This allows us to alter a product even though it is in the users hands: -fix bugs -upgrade or enhance.
Common System Exploits Tom Chothia Computer Security, Lecture 17.
Introduction to Operating Systems
Bootloaders Many embedded processors have flash memory. This allows us to alter a product even though it is in the users hands: -fix bugs -upgrade or.
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
^ About the.
Modularity and Memory Clearly, programs must have access to memory
Introduction to Computers
Introduction to Operating Systems
Booting Up 15-Nov-18 boot.ppt.
Xeno Kovah && Corey Kallenberg LegbaCore, LLC
Chap 10 Malicious Software.
Embedded System Development Lecture 13 4/11/2007
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Chap 10 Malicious Software.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Lecture 12 Input/Output (programmer view)
Presentation transcript:

Advanced x86: BIOS and System Management Mode Internals More Fun with SMM Xeno Kovah && Corey Kallenberg LegbaCore, LLC

All materials are licensed under a Creative Commons “Share Alike” license. 2 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

Other ways to break into SMM 3

Ways to break into SMM so far Break into the SPI flash chip, because it sets up the contents of SMRAM Get lucky and find out that the vendor didn’t set D_LCK Be on a system that’s too old to support SMRR (auto-win) Be on a system where the vendor didn’t set the SMRR Other? 4

Q35 chipset remapping bug There is a remapping feature present in chipsets that allows them to remap and reclaim space “lost” to the PCI Memory Mapped IO region of the memory map It turned out you could also use that bug to remap the protected SMRAM into non- protected space! Then it was a simple matter to read and write it 5

6

7 Xeno note: This implies that other BIOSes could be vulnerable, if they’re not setting the configuration correctly. We never got around to re-investigating this, and therefore it’s not a Copernicus built in check. It could be that similar issues are lurking in deployed BIOSes.

What if… What if the SMI handler code was poorly written, and it basically reached out and grabbed resources outside of its protected SMRAM area? What if it executed code completely outside of its protected area?! 8

ITL Attack Untrusted ACPI function pointer called by SMM led to easily exploitable vulnerability

“ASUS Eee PC and other series: BIOS SMM privilege escalation vulnerabilities” by core collapse Numerous instances of untrusted code execution by SMM in OEM firmware Probably lots more of these in proprietary SMM modules

11 SMMNOT-SMM

We did a little RE work to determine which SMM code we could invoke from the OS by writing to port 0xB2 In this case, function 0xDB05EDCC within SMM can be reached by writing 0x61 to port 0xB2 Almost every UEFI system we surveyed used this format to record reachable SMM code

We found a lot of these vulnerabilities They were so easy to find, we could write a ~300 line IDAPython script that found so many I stopped counting and (some) vendors stopped ing me back

Seriously HP?

ACPI remapping attack “Memory sinkhole attack” by Domas at BlackHat 2015 Fixed in Sandy Bridge (2 nd generation Core I series) & Atom 2013 processors – Vulnerable on older 19

TODO: Intel SMRAM overlap bugs 20

21

22

“Unpatchable”? Domas claimed that it’s unpatchable It can be patched by making the SMI handler entry point check if the APIC is mapped overlapping SMRAM, and then setting it back to the typical default address (either temporarily or permanently.) Yes, that breaks the “feature” of being able to relocate the APIC, but it’s highly unlikely anyone’s using it anyway, and if they were, technically they should be reading the current location anyway 23

Other things to do from SMM 24

Defeat Intel TXT Intel added new CPU instructions (“Safer Mode Extensions” in the manual, “Trusted Execution Technology” (TXT) for marketing) that try to make the system more secure The basic idea of TXT is to tear down your existing computing environment and build it back up from a secure starting point, so that you can trust whatever runs next 25

26

Defeat Intel TXT Unfortunately TXT does not measure SMRAM, and thus an attacker who has already broken into SMRAM can remain un-measured 27

28

29

30 Ring 0 Ring -1 Ring -2 Ring ;)

So IF you had an STM Then you could place it in a portion of SMRAM called MSEG (“measured segment”), and when you do a TXT launch, you would get a measurement of whether your special SMM- jailing-hypervisor (STM) is intact or not. And then that STM would need to be the main entry point to SMM so that it could run before any potentially malicious code 31

32

33 DOESN’T EXIST ON MOST SYSTEMS! GAPING HOLE! DOESN’T EXIST ON MOST SYSTEMS! GAPING HOLE! Building an STM is one of LegbaCore’s core business goals – because we’re all architecturally vulnerable until that happens – But you have to tell your OEM that you want to *not* be vulnerable, otherwise they won’t deploy it From Intel Press “Dynamics of a Trusted Platform” - Grawrock

Late-breaking news! 34 As of TODO, Intel finally released their reference STM and STM spec documentation! Still doesn’t mean it’s on anyone’s machines… but it’ a start! transfer-monitor-stm transfer-monitor-stm

MitM Copernicus! And all the other flash tools We found a generic way for an SMM attacker to MitM flash reader tools’ reading of the BIOS, so that the SMM attacker can hide his changes to the SPI flash chip Moved into the SPI Programming slide deck 35

What might an SMM backdoor look like? 36

37 Means to implement legacy PS2 keylogging without having to modify anything in the OS

38

The Watcher From 14/materials/us-14-Kallenberg-Extreme- Privilege-Escalation-On-Windows8-UEFI- Systems.pdfhttps:// 14/materials/us-14-Kallenberg-Extreme- Privilege-Escalation-On-Windows8-UEFI- Systems.pdf 39

| 40 | © 2014 The MITRE Corporation. All rights reserved. Presenting the first appearance of The Watcher! Marvel Comics Fantastic Four #13, 1963

| 41 | The Watcher  The Watcher lives in SMM (where you can't look for him)  It has no build-in capability except to scan memory for a magic signature  If it finds the signature, it treats the data immediately after the signature as code to be executed  In this way the Watcher performs arbitrary code execution on behalf of some controller, and is completely OS independent  A controller is responsible for placing into memory payloads for The Watcher to find  These payloads can make their way into memory through any means –Could be sent in a network packet which is never even processed by the OS –Could be embedded somewhere as non-rendering data in a document –Could be generated on the fly by some malicious javascript that's pushed out through an advertisement network –Could be pulled down by a low-privilege normal-looking dropper –Use your imagination © 2014 The MITRE Corporation. All rights reserved.

| 42 | The Watcher, watching © 2014 The MITRE Corporation. All rights reserved. 0 0x1000 0x2000 0x RAM Periodic continuous payload signature search all RAM 0x2F7FE000 Web Page … Attached (non-rendering) payload Web Page … Attached (non-rendering) payload System Management RAM (SMRAM) System Management RAM (SMRAM) Design tradeoffs: We don't want to scan every 4 byte chunk of memory. So instead we scan every 0x1000-aligned page boundary. How do we guarantee a payload will be found on a page-aligned boundary? a)Another agent puts it there b)Controller prefixes the payload with a full 0x1000 worth of signatures and pointers to the code to be executed (this guarantees a signature will always be found at the boundary or boundary+4) There are obviously many different ways it could be built. Controller positions payload

| 43 | © 2014 The MITRE Corporation. All rights reserved. Demo Marvel Comics Fantastic Four #48, 1966 Impel 1991 Marvel Universe Series 2

| 44 | Watcher Stats  A week to get dev env set up (I didn't have my SPI programmer) and to find where to insert the code into SMM so it got called on every SMI  2 days to write Watcher + basic print payload  Watcher itself: ~ 60 lines of mixed C and inline assembly  Print payload: 35 bytes + string, 12 instructions  Ultimate Nullifier payload: 37 bytes, 11 instructions  Overall point: very simple, very small, very powerful  How likely do you think it is that there aren't already Watchers watching?  But we can't know until people start integrity checking their BIOSes © 2014 The MITRE Corporation. All rights reserved. Impel 1992 Marvel Universe Series 2

Hello my friends. Welcome to my home in the Deep Dark Hello my friends. Welcome to my home in the Deep Dark LightEater From

Time to rethink this…

LightEater on HP For a change of pace, let’s see how easy evil- maid / border-guard / interdiction attacks are! NIC-agnostic exfiltration of data via Intel Serial-Over-LAN Option to “encrypt” data with bitwise rot13 to stop network defenders from creating a “Papa Legba” snort signature :P 47

LightEater on ASUS Uses hook-and-hop from DXE IPL to SMM From SMM attacks Windows 10 Gets woken up every time a process starts, prints information about the process 48