powerpoint presentation€¦ · title: powerpoint presentation author: jean-ian boutin created...

88
First Sednit UEFI Rootkit Unveiled Jean-Ian Boutin | Senior Malware Researcher Frédéric Vachon | Malware Researcher

Upload: others

Post on 15-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

First Sednit UEFI Rootkit Unveiled

Jean-Ian Boutin | Senior Malware Researcher

Frédéric Vachon | Malware Researcher

Page 2: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Frédéric VachonMalware Researcher

@Freddrickk_

Page 3: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Agenda

•What is Sednit

•LoJack and Past research

•Compromised LoJack agents

•UEFI Rootkit and related tools

Page 4: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks

Page 5: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks• Democratic National Committee (DNC)

Page 6: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks• Democratic National Committee (DNC)

•World Anti-Doping Agency (WADA)

Page 7: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks• Democratic National Committee (DNC)

•World Anti-Doping Agency (WADA)

• TV5 Monde

• etc

Page 8: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks• Democratic National Committee (DNC)

•World Anti-Doping Agency (WADA)

• TV5 Monde

• etc

Page 9: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Sednit(AKA Fancy Bear/APT28/STRONTIUM/etc)

•Espionage group active since the early 2000s

•Very visible in the past few years as allegedly behind these notorious hacks• Democratic National Committee (DNC)

•World Anti-Doping Agency (WADA)

• TV5 Monde

• etc

Page 10: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Example of phishing email

Page 11: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Computrace/LoJack

Page 12: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Absolute Software

Page 13: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Past Research

Page 14: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Black Hat USA 2009

•Exposed design vulnerabilities in agent

Page 15: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

LoJack Architecture back then

Page 16: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Configuration file vulnerability

Page 17: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Configuration file vulnerability

Page 18: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Configuration file vulnerability

Page 19: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Digging in

Page 20: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

LoJax - Cat is out of the bag

•Found modified small agent

•Links old Sednit domains to Lojax domains

Page 21: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Where is the attack?

Page 22: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Where is the attack?

Page 23: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Changed only configuration file?

•Almost, and used only one agent version to do so…

Page 24: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Changed only configuration file?

•Almost, and used only one agent version to do so…

•Bulk detection now possible – time to dive in

Page 25: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

The Balkans, Central and Eastern Europe victims

•Few organizations hit

•Military and diplomatic organizations

•Presence of several Sednit tools in the organization

Page 26: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Analyst ramblings

Page 27: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

autochk.exe mechanism?

Page 28: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

autochk.exe mechanism?

Page 29: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

autochk.exe vs. autoche.exe

Page 30: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

autochk.exe vs. autoche.exe

Page 31: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

autochk.exe vs. autoche.exe

Page 32: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

RWEverything

•Found on some organizations with LoJaxcompromise

• info_efi.exe

Page 33: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

RWEverything

•Uefi read tool

Page 34: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

RWEverything

•Legitimate software using legitimate kernel driver

•Not the first time it is reused for other purposes

Page 35: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Did they get there?

Page 36: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Down the rings we go

Page 37: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

ReWriter_read.exe

•Tool to dump SPI flash memory content found alongside LoJax sample

IOCTL code Description

0x22280c Writes to memory mapped I/O space

0x222808 Reads from memory mapped I/O space

0x222840 Reads a dword from given PCI Configuration Register

0x222834 Writes a byte to given PCI Configuration Register

Page 38: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

ReWriter_read.exe

•Contains *lots* of debug strings

•Consists of the following operations• Log information on BIOS_CNTL register

• Locate BIOS region base address

• Read UEFI firmware content and dump it to a file

Page 39: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

ReWriter_binary.exe

•Contains *lots* of debug strings

•Uses RWEverything’s driver

•Consists of the following operations• Add the rootkit to the firmware

•Write it back to the SPI flash memory

Page 40: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Patching the UEFI firmware

Page 41: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Unified Extensible Firmware Interface (UEFI)

• Replacement for the legacy BIOS

•New standard for firmware development

• Provides a set of services to UEFI applications• Boot services

• Runtime services

•No more MBR/VBR

Page 42: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Driver Execution Environment (DXE) Drivers

• PE/COFF images

• Abstract the hardware

• Produce UEFI standard interface

• Register new services (protocols)

• Loaded during the DXE phase of the Platform initialization

• Loaded by the DXE dispatcher (DXE Core)

Page 43: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI firmware layout

• Located in the BIOS region of the SPI flash memory

• Contains multiple volumes• Volumes contain files identified by GUIDs

• File contain sections

• One of these sections is the actual UEFI image

• It’s more complex than that but it suffices for our purpose

Page 44: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

SPI flash memory layout

Page 45: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

SPI flash memory layout

Page 46: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

SPI flash memory layout

Page 47: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

SPI flash memory layout

Page 48: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS region layout

Page 49: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS region layout

Page 50: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS region layout

Page 51: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS region layout

Page 52: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Parsing the firmware volumes

• Parses all the firmware volumes of the UEFI firmware

• Looks for 4 specific files• Ip4Dxe (8f92960f-2880-4659-b857-915a8901bdc8)

• NtfsDxe (768bedfd-7b4b-4c9f-b2ff-6377e3387243)

• SmiFlash (bc327dbd-b982-4f55-9f79-056ad7e987c5)

• DXE Core

Page 53: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Ip4Dxe and DXE Core

• Used to find the firmware volume to install the rootkit

• All DXE drivers are usually in the same volume

• DXE Core may be in a different volume

• The chosen volume will be the one with enough free space available

Page 54: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

NtfsDxe and SmiFlash

•NtfsDxe the AMI NTFS driver

•Will be removed if found

• SmiFlash metadata are not used

• SmiFlash is a known-vulnerable DXE driver

Page 55: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Adding the rootkit

• Creates a FFS file header (EFI_FFS_FILE_HEADER)

• Append the Rootkit file

•Write it at the end of the DXE drivers volume or the DXE Core volume• Checks if there’s enough free space available

Page 56: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Write the compromised firmware to the SPI Flash

memory

Page 57: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• Platform exposes write protection mechanisms

•Need to be properly configured by the firmware

•We’ll only cover relevant protections to our research• Won’t cover Protected Range Registers

• Exposed via the BIOS Control Register (BIOS_CNTL)

Page 58: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• To write to the BIOS region BIOS Write Enable (BIOSWE) must be set to 1

• BIOS Lock Enable (BLE) allows to lock BIOSWE to 0

Page 59: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• To write to the BIOS region BIOS Write Enable (BIOSWE) must be set to 1

• BIOS Lock Enable (BLE) allows to lock BIOSWE to 0

Page 60: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• The implementation of BLE is vulnerable

•When BIOSWE is set to 1, its value change in BIOS_CNTL

• A System Management Interrupt (SMI) is triggered

• The SMI handler sets BIOSWE back to 0• The SMI handler must be implemented by the firmware

Page 61: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

•What if we write to the SPI flash memory before the SMI handler sets BIOSWE to 0?

• Race condition vulnerability (Speed racer)• A thread continuously set BIOSWE to 1

• Another thread tries to write data

•Works on multicore processors and single core processors with hyper-threading enabled

Page 62: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• Platform Controller Hub family of Intel chipsets introduces a fix for this issue

• The firmware must set this bit

Page 63: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

BIOS Write Protection Mechanisms

• Platform Controller Hub family of Intel chipsets introduces a fix for this issue

• The firmware must set this bit

Page 64: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

ReWriter_Binary.exe

• ReWriter_Binary.exe checks these settings

• Checks if the platform is properly configured

• Implements the exploit for the race condition

Page 65: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Writing process decision tree

Page 66: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Writing process decision tree

Page 67: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Writing process decision tree

Page 68: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Writing process decision tree

Page 69: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Let’s take a step back

•Software implementation to flash firmware remotely• Hacking Team’s UEFI rootkit needed physical access

•We extracted the UEFI rootkit

•Looked at ESET’s UEFI scanner telemetry

•And…

Page 70: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Let’s take a step back

•Found the UEFI rootkit in the SPI flash memory of a victim’s machine

•First publicly known UEFI rootkit to be used in a cyber-attack

Page 71: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit

Page 72: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit

•DXE Driver loaded by the DXE Dispatcher

•File Name• SecDxe

•File GUID• 682894B5-6B70-4EBA-9E90-A607E5676297

Page 73: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit Workflow

Page 74: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit Workflow

Page 75: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit Workflow

Page 76: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: SecDxe

•Notify function• Installs NTFS driver

• Drops autoche.exe and rpcnetp.exe

• Patch a value in the Windows Registry

Page 77: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: NTFS driver

•NTFS driver needed to get file-based access to Windows’ partition

•Hacking Team’s NTFS driver from HT’s leak•NtfsDxe project from vector-edk

Page 78: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: Dropping files

Page 79: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: Dropping files

Page 80: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: Dropping files

Page 81: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit: Patching Windows Registry Value

•Modifies Windows Registry via %WINDIR%\System32\config\SYSTEM

•Changes “autocheck autochk *” to “autocheckautoche *”

•HKLM\SYSTEM\CurrentControlSet\Control\

Session Manager\BootExecute

Page 82: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

UEFI Rootkit Workflow

Page 83: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Prevention and Remediation

Page 84: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Prevention

•Keep your UEFI firmware up-to-date

•Enable Secure Boot

•Hardware Root of Trust (ex. Intel BootGuard)

•Hope that your firmware configures security mechanisms properly :-(

•Firmware security assessments can be done with CHIPSEC

Page 85: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Remediation

•You need to reflash your UEFI firmware

• If it’s not an option for you then…

Page 86: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Remediation

•You need to reflash your UEFI firmware

• If it’s not an option for you then…

Page 87: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Conclusion

•UEFI rootkits are real-word threats

•Firmware must be built with security in mind

•Share knowledge about how to prevent and mitigate UEFI-based threats

Page 88: PowerPoint Presentation€¦ · Title: PowerPoint Presentation Author: Jean-Ian Boutin Created Date: 12/27/2018 9:45:10 AM

Thanks!Questions?

White paper available at welivesecurity.com

@jiboutin

@Freddrickk_