hardware enclaves & intel sgxcs261/fa18/slides/...•epc pages are limited: currently 93.5 mb on...

18
Hardware Enclaves & Intel SGX CS261

Upload: others

Post on 11-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Hardware Enclaves & Intel SGX

CS261

Page 2: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Hardware Enclaves

• HW abstractions for distributing trusted execution to

untrusted platforms

2

Page 3: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Hardware Enclaves

• HW abstractions for distributing trusted execution to

untrusted platforms

3

Sensitive data(e.g., medical records)

Encrypted Encrypted Encrypted Encrypted Encrypted

Page 4: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

System Threats to Trusted Execution

• What can go wrong?

• Side channels

• out of scope for Intel SGX

• Counterfeit software

• Inject rootkits into OS

• Privilege escalation

• Install malicious kernel

• Compromised HW devices

• Cold-boot attacks

4

Medical System

Operating System

Login

DL from server

Decrypted

Page 5: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Process

Threat Model of Hardware Enclaves

5

Enclave

EnclaveCode

EnclaveData

Trusted

IntelAttestation

Service(IAS)

Process Process

OtherEnclave

OS and/or Hypervisor

Untrusted

Off-chip devices

Page 6: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Elements of Hardware Enclaves

• Secure boot: HW-verified measurement + first instruction

• On-chip program isolation

• Cryptographically protected external memory

• Execution integrity; no interference from attackers

• Attestation and/or secret sealing

6

Page 7: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Process

Enclave

SECS

ECREATE

Enclave Creation with Intel SGX

• ECREATE(SECS):

create an enclave range

• EADD(SECS, addr, prot),

EEXTEND(SECS, addr):

add a page to enclave and measure

the content

• EINIT(SECS, license):

check & initialize an enclave

7

OS

CPU

TCS

Code

Data

EADDEEXTEND

EINIT

Page 8: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Enclave Enter & Exit

• EENTER(SECS, TCS):

enter at a static enclave addr

• EEXIT(addr):

exit enclave to any addr

• Enclave can accept parameters

after the entry

• Attackers cannot interfere

control flow unpredictably

8

Process

Enclave

SECS

TCS

Code

Data

Entry addr

entry:

EENTER

cmp 0, rax…

EEXIT

exit:cmp 0, rsi…

Page 9: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Enclave Isolation

9

Process

Enclave

Process

x = *(encl_addr);

x = *(encl_addr);

Enclave ModeNon-Enclave

ModePhysical Memory

EPC

Page MappingControlled byPage Table + EPCM

Abort page semantic:EPC pages contains all 0s for execution outside the enclave

Page 10: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Memory Encryption Engine

• EPC pages are encrypted in DRAM

• Memory Encryption Engine (MEE) sits at the edge of CPU,

connected to Memory Controller (MC)

• Cachelines are decrypted at cache misses, and re-encrypted

when being written back to DRAM

10

Page 11: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

EPC (plaintext)

Memory Encryption Engine

11

0x802000000x802000400x802000800x802000c00x802001000x802001400x80200180

Enc (e.g., AES-GCM)

Cipher

MAC

Counter (nonce)

Page 12: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

EPC Paging

• EPC pages are limited: currently 93.5 MB on each platform

• Untrusted OS swaps the pages for enclaves

• Swapped-out pages are not in EPC, so no longer protected

by MEE

12

Page 13: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

VA

EPC Paging

• EWB:

copy a EPC page to non-

EPC page

• ELDU:

copy a non-EPC page to

EPC page

13

Process

Enclave

Physical Memory

EPC

EWBELDU Enc

MAC

Counter(nonce)

Page 14: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Execution Integrity

• Program states in either enclave memory or registers

• Enclave can be interrupted

• Page faults (Paging)

• Scheduling events

• Exceptions or signals

• Interrupt Asynchronous Exit (AEX)

• Register values dumped inside enclave before exit

• OS can only: (1) resume the enclave execution(2) re-enter enclave for exception handling

14

Page 15: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Attestation

• Proof that the program runs in a genuine enclave

• Each enclave has a set of unique keys

• Report key – intra-platform (local) attestation

• Attestation key – inter-platform (remote) attestation

• Seal key – Sealing enclave secrets

• Other keys – see Intel SDM

• Generated by a root secret (EPID) hidden in Intel CPU

• Verified by Intel Attestation Service

15

Page 16: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

LocalAttestation

Attestation Procedure

16

IASRemoteEntity

EnclaveCPUQuotingEnclave

NonceEREPORT(Nonce, MRQuote)

Report, MACReport

EGETKEY(MRX)

Report KeyQuote,X

Verifyreport

EGETKEY

Attestation Key(Only accessiblein Quoting Enclave)

CertificateMR, Nonce CertificateMR, Nonce

VerifyCertificate

Page 17: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Use Cases for Hardware Enclaves

• Digital Right Management (DRM)

• Computation outsourcing, NFV

• Distributed system, edge computing, blockchains

• Alternative to HME or MPC

• Protection for antivirus, JIT compilers, etc

• Used for concealing attacks

17

Page 18: Hardware Enclaves & Intel SGXcs261/fa18/slides/...•EPC pages are limited: currently 93.5 MB on each platform •Untrusted OS swaps the pages for enclaves •Swapped-out pages are

Questions?Hardware Enclaves & Intel SGX

18