Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware...

14
Enable UEFI Secure Boot Using OP-TEE as Secure Partition Sahil Malhotra ([email protected]) Ilias Apalodimas ([email protected])

Transcript of Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware...

Page 1: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Enable UEFI Secure Boot Using OP-TEE as Secure PartitionSahil Malhotra ([email protected])Ilias Apalodimas ([email protected])

Page 2: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Agenda● UEFI Overview● UEFI Secure Boot Overview● Authenticated Variables in UEFI Secure Boot● Authenticated Variables Requirement● Management Mode (MM)● Secure Partition on ARM v8 systems● Secure Storage Service in UEFI● Problem in the current implementation● Solution: Secure Partition in OP-TEE OS

Page 3: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

UEFI Overview

Hardware

Arm Trusted Firmware

UEFI Firmware

OS Loader

UEFI Apps

UEFI drivers

OS

App 1 App 2 App 3● The Unified Extensible Firmware Interface (UEFI) is a specification that defines a software interface between an operating system and platform firmware.

● UEFI replaces the legacy Basic Input/OutputSystem (BIOS) firmware interface.

● Intel developed the original Extensible Firmware Interface (EFI) specifications.

● In 2005, UEFI deprecated EFI 1.10 (final release of EFI).

● The latest UEFI specification, version 2.8, was approved in March 2019.

Page 4: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

UEFI Secure Boot Overview

Hardware

Arm Trusted Firmware

UEFI Firmware

OS Loader

UEFI Apps

UEFI drivers

● UEFI Secure boot is a verification mechanism for ensuring that code launched by the device firmware is trusted and that each efi payload loaded is validated.

● What is covered by UEFI Secure Boot:○ Next boot stage (kernel, GRUB etc).○ Authenticated Variable Store (Which

stores all keys, certificates, hashes for authenticating the EFI payloads).

OS

App 1 App 2 App 3

= Signed Image

Page 5: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Authenticated Variables in UEFI Secure Boot● According to the UEFI Specs, Authenticated Variables are one of the building

block of UEFI Secure Boot.● The keys, certificates, hashes that are required for UEFI Secure Boot are stored

as the Authenticated variables on the secure flash device.● There are set of predefined authenticated variables that need to be

programmed for enablement and working of UEFI secure boot.

Secure Flash

Platform Key (PK)

Key Exchange Key (KEK)

db (allow)

dbx (deny)

PK: Establishes trust relationship b/w Platform Owner (PO) and Platform Firmware (PF).• PKpriv owned by the PO• PKpub enrolled into PF

KEK: Establishes trust relationship between Software Vendor (SV) & Platform Firmware (PF)• Different KEKpriv for each SV• Each SV enrolls KEKpub into PF

db: db will contain a list of public keys that are from sources that are considered to be securedb can also hold the hash of binaries that are considered to be secure.

dbx: These are basically anti-db keys i.e. dbx holds the key sources and hashes that are blacklisted from being secure or marked as malware

Page 6: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Authenticated Variables Requirement● An authenticated variable implementation requires

an isolated execution environment to do the authentication and update variables.

● If there is no isolated environment, malicious code can bypass authentication check and update variable region directly.

● Now a days to fulfill this requirement, most CPU vendors are providing a kind of hardware partition which provides an isolated execution environment for high security sensitive use cases.

Secure Flash

Platform Key (PK)

Key Exchange Key (KEK)

db (allow)

dbx (deny)

Page 7: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Management Mode (MM)● Management Mode (MM) is a generic term used to describe a secure isolated

execution environment provided by the CPU.○ For x86 systems, this can be implemented with System Management Mode (SMM).○ For ARM systems, this can be implemented with TrustZone (TZ).

● Two Types of MM supported by UEFI PI Specification○ Traditional Mode - MM execution environment is setup during DXE phase○ Standalone Mode - MM execution environment can be setup during or prior to SEC

phase. An MM standalone mode driver can only run in the MM environment which provides an isolated environment.

● Standalone MM is ideal for securing EFI variables required for UEFI secure boot● Allow access to the secure non-volatile storage only via code executing in MM

mode

Page 8: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Secure Partition on ARM v8 systems● A Secure Partition is an unprivileged

software sandbox environment running in the Secure World, under the control of privileged software.

● SPM currently implemented in TF-A at EL3

● Shim layer to relay SVC from S-EL0 into SMC to EL3

● Enable early development of SPM code before S-EL2 availability in ARM v8.4 architecture.

● It can be used to instantiate PI Standalone Management Mode, in order to execute MM (secure) services.

Guest OS

Hypervisor

App1 App2 SP

SPM shim(SVC/SMC

Trampoline)

Trusted Firmware - A

Secure Partition Manager

EL0

EL1

EL2

S-EL0

S-EL1

S-EL3

S-EL2

Normal World Secure World

UEFI

Page 9: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Secure Storage service in UEFI

OS Kernel

App1 App2

SPM shim(SVC/SMC Trampoline)

Trusted Firmware - A

Secure Partition Manager

EL0

EL2

S-EL0

S-EL1

S-EL3

S-EL2

Normal World Secure World

UEFI Firmware

EL1

MM Interface

db/dbx

PK

KEK

UEFI Variables inSecure Storage• Keys• SignatureDB

SP StMM

VariableSmmRuntimeDxe

Get/SetVariable()

VariableSmmFlashDriver

AuthVariableLib

R/W

Page 10: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Problem in current implementation● SPD or SPM:

○ SPD and SPM are mutually exclusive○ SPD is required for communication between Normal world and Secure OS.○ SPM instead takes directly care of all lifecycle of SPs (at EL3 today, potentially at

S-EL2 in future evolutions)

● Secure OS in server market had limited usage up to now, but starting with secure device onboarding, it has great usage on IoT/Edge devices.

Page 11: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Solution: Secure Partition in OP-TEE

OS Kernel

App1 App2

OP-TEE OS

Trusted Firmware - A

Secure Partition Dispatcher

EL0

EL2

S-EL0

S-EL1

S-EL3

S-EL2

Normal World Secure World

UEFI Firmware

EL1

Get/SetVariable()

MM Interface

db/dbx

PK

KEK

UEFI Variables inSecure Storage• Keys• SignatureDB

OP-TEE Interface

SP

R/WStMMTrusted Application

Page 12: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

What’s done and next steps● This setup is tested on NXP LX2160A-RDB board.● Currently support for Secure Partition with StandAlone MM is being

upstreamed in the OP-TEE.○ https://github.com/OP-TEE/optee_os/pull/3973

● We created a new Dxe driver MmcommunicationOpteeDxe which is using the OpteeLib

● We have added support for saving the variables on I2C EEPROM and eMMC RPMB in StandAlone MM.

● We are in the process of upstreaming all code changes to EDK2 also and patches will be available soon.

Page 13: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

Thank youAccelerating deployment in the Arm Ecosystem

Page 14: Enable UEFI Secure Boot Using OP-TEE as Secure Partition · 2020. 12. 22. · Arm Trusted Firmware UEFI Firmware OS Loader UEFI Apps UEFI drivers UEFI Secure boot is a verification

References● https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface● https://www.slideshare.net/linaroorg/lca14-105-uefisecureboot● https://2018.osfc.io/uploads/talk/paper/18/osfc_secure_partitions.pdf● https://www.uefi.org/sites/default/files/resources/UEFI%20Updates%2C%20S

ecure%20Firmware%20and%20Secure%20Services%20on%20Arm%20%E2%80%93%20Matteo%20Carlini%20and%20Dong%20Wei%20.pdf

● http://connect.linaro.org.s3.amazonaws.com/hkg18/presentations/hkg18-104.pdf

● https://s3.amazonaws.com/connect.linaro.org/yvr18/presentations/yvr18-421.pdf