intel® software guard extensions (intel®...

105
Intel® Software Guard Extensions (Intel® SGX) Dror Caspi Intel September 9, 2015 Copyright © 2015 Intel Corporation. All rights reserved.

Upload: others

Post on 23-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Intel® Software GuardExtensions (Intel® SGX)

Dror Caspi

Intel

September 9, 2015

Copyright © 2015 Intel Corporation. All rights reserved.

Page 2: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

2

Legal Disclaimers

• The comments and statements are the presenter’s and not necessarily Intel’s

• Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Learn more at intel.com, or from the OEM or retailer.

• No computer system can be absolutely secure.

Page 3: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Principles of Operation

3

Page 4: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

The Basic Issue: Vulnerabilities in Privileged Code

Privileged Code

App

Protected Mode (rings) protects OS from apps …

X

OK

4

Page 5: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

App

The Basic Issue: Vulnerabilities in Privileged Code

Privileged Code

App

Protected Mode (rings) protects OS from apps …

… and apps from each other …

X

OK

X X

4

Page 6: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

AppMalicious

App

The Basic Issue: Vulnerabilities in Privileged Code

Privileged Code

App

Protected Mode (rings) protects OS from apps …

… and apps from each other …

X

X X

… UNTIL a malicious app exploits a flaw to gain full privileges and then tampers with the OS or other apps

Apps not protected from privileged code attacks

attack

4

BadCode

Page 7: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

AppMalicious

App

The Basic Issue: Vulnerabilities in Privileged Code

Privileged Code

App

Protected Mode (rings) protects OS from apps …

… and apps from each other …

X

X X

… UNTIL a malicious app exploits a flaw to gain full privileges and then tampers with the OS or other apps

Apps not protected from privileged code attacks

attack

4

BadCode

Privileged Code

Info BadCode

Page 8: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface today

Reduced attack surface with SGX

Attack Surface

5

Page 9: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface today

Reduced attack surface with SGX

Attack Surface

5

Page 10: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secretsProxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 11: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secrets

Familiar development/debug

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 12: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secrets

Familiar development/debug– Single application environment

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 13: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secrets

Familiar development/debug– Single application environment– Build on existing ecosystem expertise

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 14: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secrets

Familiar development/debug– Single application environment– Build on existing ecosystem expertise

Familiar deployment model

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 15: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Application gains ability to defend its own secrets– Smallest attack surface (app + processor)– Malware that subverts OS/VMM, BIOS,

Drivers etc. cannot steal app secrets

Familiar development/debug– Single application environment– Build on existing ecosystem expertise

Familiar deployment model– Platform integration not a bottleneck to

deployment of trusted apps

Proxy Proxy Proxy

Hardware

VMM (Hypervisor)

OS

App App App

Scalable security within mainstream environment

Attack surface with Enclaves

XX

Reduced attack surface with SGX

Attack Surface

5

Page 16: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

What is an Enclave?

App Code

App Data

OS

User Process

6

Page 17: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EnclaveEnclave

What is an Enclave?

Enclave: trusted execution environment embedded in a process

App Code

App Data

OS

User Process

6

Page 18: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Enclave

What is an Enclave?

Enclave: trusted execution environment embedded in a process

App Code

App Data

OSEnclave

Code

Enclave Data

• Own code and data

User Process

• Provides Confidentiality

• Provides integrity

• Controlled entry points

Enclave

6

SECS

Page 19: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Enclave

What is an Enclave?

Enclave: trusted execution environment embedded in a process

App Code

App Data

OSEnclave

Code

Enclave Data

• Own code and data

User Process

• Provides Confidentiality

• Provides integrity

• Controlled entry points

• Supporting multiple threads

Enclave

6

TCS (*n)TCS (*n)TCS (*n)

SECS

Page 20: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Enclave

What is an Enclave?

Enclave: trusted execution environment embedded in a process

App Code

App Data

OSEnclave

Code

Enclave Data

• Own code and data

User Process

• Provides Confidentiality

• Provides integrity

• Controlled entry points

• Full access to app memory

• Supporting multiple threads

Enclave

6

TCS (*n)TCS (*n)TCS (*n)

SECS

Page 21: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

How SGX Works: Protection vs. Software Attack

Application

Privileged System Code:OS, VMM, BIOS, SMM, …

7

Page 22: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

How SGX Works: Protection vs. Software Attack

Untrusted Partof App

Trusted Partof App

Application

Privileged System Code:OS, VMM, BIOS, SMM, …

1. App is built with trusted and untrusted parts

7

Page 23: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

How SGX Works: Protection vs. Software Attack

Untrusted Partof App

Trusted Partof App

Create Enclave

Application

Privileged System Code:OS, VMM, BIOS, SMM, …

CallGate

1. App is built with trusted and untrusted parts

2. App runs & creates enclave which is placed in trusted memory

7

Page 24: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

How SGX Works: Protection vs. Software Attack

Untrusted Partof App

Trusted Partof App

Create Enclave

Call Trusted Func.

Execute

Application

Privileged System Code:OS, VMM, BIOS, SMM, …

CallGate

1. App is built with trusted and untrusted parts

2. App runs & creates enclave which is placed in trusted memory

3. Trusted function is called; code running inside enclave sees data in clear; external access to data is denied

SSN: 999-84-2611

7

Page 25: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

How SGX Works: Protection vs. Software Attack

Untrusted Partof App

Trusted Partof App

Create Enclave

Call Trusted Func.

Execute

Return

(etc.)

Application

Privileged System Code:OS, VMM, BIOS, SMM, …

CallGate

1. App is built with trusted and untrusted parts

2. App runs & creates enclave which is placed in trusted memory

3. Trusted function is called; code running inside enclave sees data in clear; external access to data is denied

4. Function returns; enclave data remains in trusted memory

m8U3bcV#zP49Q

7

Page 26: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Physical Address Space

Enclave Life Cycle – Overview1 /15

8

Page 27: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Physical Address Space

System Memory

Enclave

Page

Cache

Enclave Life Cycle – Overview

EPCM

Invalid

Invalid

Invalid

2

Invalid

Invalid

/15

BIOS setup

8

Page 28: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Enclave Life Cycle – Overview

EPCM

Invalid

Invalid

Invalid

3

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 29: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

Enclave Life Cycle – Overview

Plaintext Code/Data

EPCM

Invalid

Invalid

Invalid

4

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 30: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Plaintext Code/Data

EPCM

Valid, REG, LA,SECS

Invalid

Invalid

5

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 31: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Update PTE

Enclave Life Cycle – Overview

EPCM

Valid, REG, LA,SECS

Invalid

Invalid

6

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 32: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

PlaintextCode/Data

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

7

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 33: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

PlaintextCode/Data

EEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

8

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave creation

8

Page 34: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

Code/Data

Code/Data

Code/Data

PlaintextCode/Data

PlaintextCode/DataPlaintext

Code/DataEEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

9

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave init

SECS

8

Page 35: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

Code/Data

Code/Data

Code/Data

PlaintextCode/Data

PlaintextCode/DataPlaintext

Code/DataEEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

10

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave active

SECS

8

Page 36: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

Code/Data

Code/Data

Code/Data

PlaintextCode/Data

PlaintextCode/DataPlaintext

Code/DataEEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

11

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave active

SECS

8

Page 37: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EEXITEENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

Code/Data

Code/Data

Code/Data

PlaintextCode/Data

PlaintextCode/DataPlaintext

Code/DataEEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

12

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave active

SECS

8

Page 38: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EEXITEENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Code/Data

PlaintextCode/Data

Enclave Life Cycle – Overview

Code/Data

Code/Data

Code/Data

Code/Data

PlaintextCode/Data

PlaintextCode/DataPlaintext

Code/DataEEXTEND

EPCM

Valid, REG, LA,SECS

Invalid

Valid, REG, LA,SECS

13

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave active

SECS

8

Page 39: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EREMOVE

EEXITEENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave

Enclave Life Cycle – Overview

EEXTEND

EPCM

Invalid

Invalid

Invalid

14

SECS InvalidValid, SECS, Range

Invalid

/15

Enclave destruction

SECS

8

Page 40: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

EREMOVE

EEXITEENTER

EINIT

EADD (Copy Page)ECREATE (Range)

Virtual Address Space Physical Address Space

System Memory

Enclave

Page

Cache

Enclave Life Cycle – Overview

EEXTEND

EPCM

Invalid

Invalid

Invalid

15

Invalid

Invalid

/15

Enclave destruction

8

Page 41: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

9

Enclave Life Cycle – Instantiating an Enclave (1)

ECREATE

• Creates a unique instance of an enclave, establishes the linear address range, and sets enclave’s attributes– Enclave mode of operation (32/64)

– Processor features that enclave supports

– Debug is allowed or not

Information is stored within an Secure Enclaves Control Structure (SECS) generated by ECREATE.

Page 42: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

9

Enclave Life Cycle – Instantiating an Enclave (1)

ECREATE

• Creates a unique instance of an enclave, establishes the linear address range, and sets enclave’s attributes– Enclave mode of operation (32/64)

– Processor features that enclave supports

– Debug is allowed or not

Information is stored within an Secure Enclaves Control Structure (SECS) generated by ECREATE.

EADD

• Add Regular (REG) or Thread Control Structure (TCS) pages into the enclave

– System software is responsible for selecting free EPC page, type, and attributes, content of the page and the enclave to which the page added to.

– EADD sets EPCM entry to indicate type of page (REG, TCS), linear address, RWX, parent enclave etc.

Page 43: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

10

Enclave Life Cycle – Instantiating an Enclave (2)

EEXTEND

• Generates a cryptographic hash of the content of the enclave in 256B chunks

Page 44: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

10

Enclave Life Cycle – Instantiating an Enclave (2)

EEXTEND

• Generates a cryptographic hash of the content of the enclave in 256B chunks

EINIT

• Verifies the enclave’s content against the ISV’s signed SIGSTRUCT and initializes the enclave – mark it ready to be used

– Validate SIGSTRUCT is signed using SIGSTRUCT public key

– Enclave measurement matches the measurement specified in SIGSTRUCT

– Enclave attributes compatible with SIGSTRUCT

– Record sealing identity (sealing authority, product id, SVN) in the SECS

Page 45: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

11

Enclave Flow Control – EENTER

• Checks that TCS is not busy

• Saves RSP/RBP for later restore on enclave Asynchronous Exit

• Changes the mode of operation to be in enclave mode

• Flush TLB entries for enclave linear address range

• Save CPU feature set (XCR0), load enclave’s XFRM value

• Transfer control from outside enclave to pre-determined location inside the enclave

• Debug

• If debug enclave and software wishes to debug then allow traps, breakpoints, single step

• Else, set HW so the enclave appears as a single instruction

Page 46: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

12

Enclave Flow Control – EEXIT

• Clears enclave mode and TLB entries for enclave addresses

• Restores CPU feature set (XCR0)

• Marks TCS as not busy

• Transfers control from inside enclave to a location outside enclave (specified by enclave code as a parameter)

• Registers state is not cleared; scrubbing of secrets is the responsibility of enclave code (run time system)

Page 47: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

13

Handling Exceptions – Asynchronous Exit (AEX)

• Initiated by faults, exceptions and interrupts

• Saves registers state inside the enclave, in a pre-allocated State Save Area (SSA), and sets registers to a synthetic state

• Transfers control to a pre-set OS exception handler location

• Before that, sets the exception handler stack so IRET will return to a pre-defined location (trampoline code) in the app code.

Page 48: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

14

Handling Exceptions – ERESUME

• Called by the app’s trampoline code

• Very similar to EENTER, except:

• Restores register state from the State Save Area (SSA) area

• Resumes enclave operation at the RIP stored in SSA on last AEX

Page 49: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

LinearAddress

PhysicalAddress

Page 50: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

LinearAddress

PhysicalAddress

Page 51: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

Address in EPC?

No

AllowMemoryAccess

ReplaceAddress

With Abort Page

Yes

No

LinearAddress

PhysicalAddress

Non-EnclaveAccess

Page 52: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

Address in EPC?

Address in EPC?

CheckEPCM

Yes

Yes

No

AllowMemoryAccess

ReplaceAddress

With Abort Page

Yes

No

LinearAddress

PhysicalAddress

Non-EnclaveAccess

EnclaveAccess

Page 53: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

Address in EPC?

Address in EPC?

CheckEPCM

Yes

Yes

No

AllowMemoryAccess

ReplaceAddress

With Abort Page

Yes

No

LinearAddress

PhysicalAddress

Non-EnclaveAccess

EnclaveAccess

• Is the page valid?• Is the page type correct?• Does page belong to current enclave?• Do RWX attributes match?• Is linear address correct?

Page 54: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

Address in EPC?

Address in EPC?

CheckEPCM

Checks Pass ?

Yes

Yes

No

AllowMemoryAccess

ReplaceAddress

With Abort Page

Yes

No

Yes

LinearAddress

PhysicalAddress

Non-EnclaveAccess

EnclaveAccess

• Is the page valid?• Is the page type correct?• Does page belong to current enclave?• Do RWX attributes match?• Is linear address correct?

Page 55: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – SGX Access Control

15

TraditionalIA Page Table

Checks

EnclaveAccess?

Address in EPC?

Address in EPC?

CheckEPCM

Checks Pass ?

SignalFault

No

Yes

No

Yes

No

AllowMemoryAccess

ReplaceAddress

With Abort Page

Yes

No

Yes

LinearAddress

PhysicalAddress

Non-EnclaveAccess

EnclaveAccess

Page 56: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – EPC Memory Encryption

Cores

Cache

System Memory

CPU Package

16

Non-EnclaveAccess

Page 57: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – EPC Memory Encryption

• Security perimeter is the CPU package boundary

Cores

Cache

System Memory

CPU Package

16

Non-EnclaveAccess

Page 58: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – EPC Memory Encryption

• Security perimeter is the CPU package boundary

• Data and code unencrypted inside CPU package

Cores

Cache

System Memory

AMEX: 3234-134584-26864

CPU Package

16

Non-EnclaveAccess

Page 59: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – EPC Memory Encryption

• Security perimeter is the CPU package boundary

• Data and code unencrypted inside CPU package

• Data and code outside CPU package is encrypted and/or integrity checked

Cores

Jco3lks937weu0cwejpoi9987v80weCache

System Memory

AMEX: 3234-134584-26864

CPU Package

16

Non-EnclaveAccess

Page 60: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Hardware Operation – EPC Memory Encryption

• Security perimeter is the CPU package boundary

• Data and code unencrypted inside CPU package

• Data and code outside CPU package is encrypted and/or integrity checked

• External memory reads and bus snoops see only encrypted data

Cores

Jco3lks937weu0cwejpoi9987v80weCache

System Memory

AMEX: 3234-134584-26864

CPU Package

Snoop

Snoop

16

Non-EnclaveAccess

Page 61: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Protected Memory

SGX High-level HW/SW Picture

EPCMEPC

SGX Driver

SGX Untrusted User

Runtime

Enclave

Ring 0 InstructionsECREATEEADDEEXTENDEINITEBLOCK

Enclave

H/w Data Structure

Hardware

Runtime

Application

OS Data structure

ApplicationEnvironment(Ring 3)

PrivilegedEnvironment(Ring 0)

ExposedHardware

Ring 3 InstructionsEEXITEGETKEYEREPORTEENTERERESUME

Page Tables

ETRACKEWBELDEPAEREMOVE

17

SGX TrustedRuntime

SGX TrustedRuntime

SGX Untrusted User

Runtime

Page 62: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Attestation and Sealing

18

Page 63: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

The Challenge: Provisioning Secrets to the Enclave

• An enclave is in the clear before instantiation

– Sections of code and data could be encrypted, but their decryption key can’t be pre-installed

• Secrets come from outside the enclave

– Keys

– Passwords

– Sensitive data

• The enclave must be able to convince a 3rd party that it’s trustworthy and can be provisioned with the secrets

• Subsequent runs should be able to use the secrets that have already been provisioned

19

Page 64: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Critical Features: Attestation and Sealing

Remote PlatformApplication

Enclave

• App executes on local platform

20

Page 65: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Critical Features: Attestation and Sealing

Remote PlatformApplication

Enclave Intel

• App executes on local platform

• HW based Attestation provides remote platform assurance that “this is the right app executing in the right platform “

20

Page 66: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Critical Features: Attestation and Sealing

Remote PlatformApplication

EnclaveAuthenticated Channel

• App executes on local platform

• HW based Attestation provides remote platform assurance that “this is the right app executing in the right platform “Remote platform can provision local platform with secrets

20

Page 67: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Critical Features: Attestation and Sealing

Remote PlatformApplication

EnclaveAuthenticated Channel

• App executes on local platform

• HW based Attestation provides remote platform assurance that “this is the right app executing in the right platform “Remote platform can provision local platform with secrets

• App can seal secrets to platform for future use

20

Page 68: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Trustworthiness

• Intel® SGX provides the means for an enclave to securely prove to a 3rd

party:

– What software is running inside the enclave

– Which execution environment the enclave is running at

– Which Sealing Identity will be used by the enclave

– What’s the CPU’s security level

• Accomplished by:

– A combination of SGX instructions (local attestation)

– Intel provided attestation enclave (remote attestation)

• Once provisioned a secret, an enclave can seal its data using SGX instructions

21

Page 69: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Enclave Measurement (Software TCB)

• When building an enclave, Intel® SGX generates a cryptographic log of all the build activities

– Content: Code, Data, Stack, Heap

– Location of each page within the enclave

– Security flags being used

• MRENCLAVE (“Enclave Identity”) is a 256-bit digest of the log

– Represents the enclave’s software TCB

• A software TCB verifier should:

– Securely obtain the enclave’s software TCB

– Securely obtain the expected enclave’s software TCB

– Compare the two values

22

Page 70: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Local Attestation

• “Local attestation”: The process by which one enclave attests its TCB to another enclave on the same platform

• Using Intel® SGX’s EREPORT and EGETKEY instructions

– EREPORT generates a cryptographic REPORT that binds MRENCLAVE to the target enclave’s REPORT KEY

– EGETKEY provides the REPORT KEY to verify the REPORT

TCB component Attestation

CPU Firmware & hardware CPU REPORT KEY

Software MRENCLAVE

23

Page 71: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

Client Application Client Application

24

Page 72: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

1. Verifying enclave sends its MRENCLAVE to reporting enclave

2. Reporting enclave creates a cryptographic REPORT that includes its MRENCLAVE

3. Verifying enclave obtains its REPORT key and verifies the authenticity of the REPORT

Client Application

Reporting Enclave

Client Application

Verifying Enclave

24

Page 73: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

1. Verifying enclave sends its MRENCLAVE to reporting enclave

2. Reporting enclave creates a cryptographic REPORT that includes its MRENCLAVE

3. Verifying enclave obtains its REPORT key and verifies the authenticity of the REPORT

Client Application

Reporting Enclave

Client Application

Verifying Enclave

MRENCLAVE

24

Page 74: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

1. Verifying enclave sends its MRENCLAVE to reporting enclave

2. Reporting enclave creates a cryptographic REPORT that includes its MRENCLAVE

3. Verifying enclave obtains its REPORT key and verifies the authenticity of the REPORT

Client Application

Reporting Enclave

Client Application

Verifying Enclave

MRENCLAVE

REPORT

MAC

24

Page 75: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

1. Verifying enclave sends its MRENCLAVE to reporting enclave

2. Reporting enclave creates a cryptographic REPORT that includes its MRENCLAVE

3. Verifying enclave obtains its REPORT key and verifies the authenticity of the REPORT

Client Application

Reporting Enclave

Client Application

Verifying Enclave

MRENCLAVE

REPORT

MAC

24

Page 76: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Processor

Local Attestation - Flow

1. Verifying enclave sends its MRENCLAVE to reporting enclave

2. Reporting enclave creates a cryptographic REPORT that includes its MRENCLAVE

3. Verifying enclave obtains its REPORT key and verifies the authenticity of the REPORT

Client Application

Reporting Enclave

Client Application

Verifying Enclave

MRENCLAVE

REPORT

MAC

24

Page 77: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation

• “Remote attestation”: The process by which one enclave attests its TCB to another entity outside of the platform

• Intel® SGX Extends Local attestation by allowing a Quoting Enclave (QE) to use Intel® EPID to create a QUOTE out of a REPORT

– Intel® EPID is a group signature scheme

TCB component Attestation

CPU Firmware & hardware Asymmetric - Intel® EPID

Software MRENCLAVE

25

Page 78: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation - Flow

Platform

QuotingEnclave

Encl

ave

Remote Platform

VerifyingApplication

REPORT

MACMRENCLAVE

1. Verifying enclave becomes the Quoting Enclave (QE).

2. After verifying the REPORT the, QE signs the REPORT with the EPID private key and converts it into a QUOTE

3. Remote platform verifies the QUOTE with the EPID public key and verifies MRENCLAVE against the expected value

26

Page 79: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation - Flow

Platform

QuotingEnclave

Encl

ave

Remote Platform

VerifyingApplication

MRENCLAVEEPID

QUOTE

1. Verifying enclave becomes the Quoting Enclave (QE).

2. After verifying the REPORT the, QE signs the REPORT with the EPID private key and converts it into a QUOTE

3. Remote platform verifies the QUOTE with the EPID public key and verifies MRENCLAVE against the expected value

26

Page 80: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation - Flow

Platform

QuotingEnclave

Encl

ave

Remote Platform

VerifyingApplication

MRENCLAVEEPID

QUOTE

1. Verifying enclave becomes the Quoting Enclave (QE).

2. After verifying the REPORT the, QE signs the REPORT with the EPID private key and converts it into a QUOTE

3. Remote platform verifies the QUOTE with the EPID public key and verifies MRENCLAVE against the expected value

26

Page 81: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation - Flow

Platform

QuotingEnclave

Encl

ave

Remote Platform

VerifyingApplication

MRENCLAVEEPID

QUOTE

1. Verifying enclave becomes the Quoting Enclave (QE).

2. After verifying the REPORT the, QE signs the REPORT with the EPID private key and converts it into a QUOTE

3. Remote platform verifies the QUOTE with the EPID public key and verifies MRENCLAVE against the expected value

26

Page 82: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Attestation - Flow

Platform

QuotingEnclave

Encl

ave

Remote Platform

VerifyingApplication

MRENCLAVE

1. Verifying enclave becomes the Quoting Enclave (QE).

2. After verifying the REPORT the, QE signs the REPORT with the EPID private key and converts it into a QUOTE

3. Remote platform verifies the QUOTE with the EPID public key and verifies MRENCLAVE against the expected value

26

Page 83: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Intel ProvisioningService

Device

27

Provisioning SGX with HW-based Keys

Intel generates and fuses a unique key during manufacturing. Intel maintains a database of these keys.

Intel generates provisioning blobs for each device specific to the device TCB & Provisioning Enclave.

Protocol between Provisioning Enclave & Provisioning Service:

• Platform proves it has a key that Intel put in a real processor.

• Server certifies an Attestation Key for the platform.

ProvDataProvisioning

Enclave

Intel Key Generation

Facility (iKGF)

Fusekey TCB Keys& EPID issuing

EPID

Page 84: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

28

Intel® EPID

Intel® Enhanced Privacy Identifier (EPID) key is used for platform identity

EPID is a Group based anonymous signature scheme.

EPID requires 3 keys:

• Master Issuing Key

• Group Public Key

• Member Private Key

Member private keys will be generated on platform.

Public keys and revocation lists to need to be issued to EPID verifiers.

Page 85: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Sealing

• “Sealing”: Cryptographically protecting data when it leaves the enclave.

• Enclaves use EGETKEY to retrieve an enclave, platform persistent key and encrypts the data

• EGETKEY uses a combination of enclave attributes and platform unique key to generate keys

– Enclave Sealing Authority

– Enclave Product ID

– Enclave Product Security Version Number (SVN)

29

Page 86: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Sealing Authority

• Every enclave has an Enclave Certificate (SIGSTRUCT) which is signed by a Sealing Authority (typically the enclave writer)

• SIGSTRUCT includes:

– Enclave’s Identity (represented by MRENCLAVE)

– Sealing Authority’s public key (represented by MRSIGNER)

• EINIT instruction verifies the signature over SIGSTRUCT prior to enclave initialization

30

Enclave

SIG_STRUCT Version Measurement Public KeyAttributes

Verify

? HASH

MRENCLAVE MRSIGNER

Signature

VersionAttributes

Page 87: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Client Application

Enclave

Example: Secure Transaction

Remote Platform

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

1

31

Page 88: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Client Application

Enclave

Example: Secure Transaction

Remote Platform

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

1

2

31

Page 89: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Client Application

Enclave

Example: Secure Transaction

Remote Platform

QE

EPID

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

1

2 3

31

Page 90: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Client Application

Enclave

Example: Secure Transaction

Remote Platform

QE

EPID

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

1

2 3 4

31

Page 91: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Client Application

Enclave

Example: Secure Transaction

Remote Platform

QEAuthenticated Channel

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

1

2 4

5

32

3

Page 92: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Platform

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY 8. Secret is encrypted using SEAL KEY & stored for future use

4

5

Client Application

Enclave

Authenticated Channel

1

2

5

Example: Secure Transaction

6

33

3

Page 93: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Platform

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY8. Secret is encrypted using SEAL KEY & stored for future use

3

4

5

Client Application

Enclave

Authenticated Channel

1

2

5

Example: Secure Transaction

7

34

6

Page 94: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Remote Platform

1. Enclave built & measured against ISV’s signed certificate2. Enclave calls EREPORT to obtain a REPORT that includes enclave

specific data (ephemeral key)3. REPORT & user data sent to Quoting Enclave who signs the

REPORT with an EPID private key4. QUOTE sent to server & verified5. Ephemeral key used to create a trusted channel between

enclave and remote server6. Secret provisioned to enclave7. Enclave calls EGETKEY to obtain the SEAL KEY8. Secret is encrypted using SEAL KEY & stored for future use

3

4

5

Client Application

Enclave

Authenticated Channel

1

2

5

Example: Secure Transaction

7

8

34

6

Page 95: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

35

Links• Intel’s SGX Page (Programming Reference, white papers & blogs):

https://software.intel.com/en-us/isa-extensions/intel-sgx

• Joint research poster session: http://sigops.org/sosp/sosp13/

• Public Cloud Paper using SGX2: https://www.usenix.org/sites/default/files/osdi14_full_proceedings.pdf

• HASP Workshop: https://sites.google.com/site/haspworkshop2013/workshop-program

• ISCA 2015 Tutorial: http://sgxisca.weebly.com/

Page 96: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Thank You

36

Page 97: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Backup

37

Page 98: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

SGX Paging Introduction

Requirement:

• Remove an EPC page and place into unprotected memory. Later restore it.

• Page must maintain same security properties (confidentiality, anti-replay, and integrity) when restored

Instructions:

• EWB: Evict EPC page to main memory with cryptographic protections

• ELDB/ELDU: Load page from main memory to EPC with cryptographic protections

• EPA: Allocate an EPC page for holding versions

• EBLOCK: Declare an EPC page ready for eviction

• ETRACK: Ensure address translations have been cleared

38

Page 99: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-out Example

SECS

EnclavePage

EnclavePage

EnclavePage

EWB

BUILD

EPCSystem Memory

39

VA Page

Page 100: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-out Example

SECS

EnclavePage

EnclavePage

EnclavePage

EWB

EncryptedPage

EWB Parameters:

• Pointer to EPC page that needs to

be paged out

• Pointer to empty version slot

• Pointers outside EPC location

BUILD

EPCSystem Memory

PCMD

39

Page 101: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-out Example

SECS

EnclavePage

EnclavePage

EWB

VER

EncryptedPage

EWB Parameters:

• Pointer to EPC page that needs to be

paged out

• Pointer to empty version slot

• Pointers outside EPC location

EWB Operation

• Remove page from the EPC

• Populate version slot

• Write encrypted version to outside

• Write meta-data, PCMD

BUILD

EPCSystem Memory

PCMD

39

Page 102: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-out Example

SECS

EnclavePage

EnclavePage

EWB

VER

EncryptedPage

EWB Parameters:

• Pointer to EPC page that needs to be paged

out

• Pointer to empty version slot

• Pointers outside EPC location

EWB Operation

• Remove page from the EPC

• Populate version slot

• Write encrypted version to outside

• Write meta-data, PCMD

All pages, including SECS and Version

Array can be paged out

BUILD

EPCSystem Memory

PCMD

39

Page 103: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-in Example

SECS

EnclavePage

EnclavePage

ELD

VER

EncryptedPage

BUILD

EPCSystem Memory

MD

40

Free EnclavePage

Page 104: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-in Example

ELD Parameters:

• Encrypted page

• Free EPC page

• SECS (for an enclave page)

• Populated version slot

SECS

EnclavePage

EnclavePage

ELD

VER

EncryptedPage

BUILD

EPCSystem Memory

MD

40

Free EnclavePage

Page 105: Intel® Software Guard Extensions (Intel® SGX)tce.webee.eedev.technion.ac.il/wp-content/uploads/... · Application gains ability to defend its own secrets – Smallest attack surface

Page-in Example

ELD Parameters:

• Encrypted page

• Free EPC page

• SECS (for an enclave page)

• Populated version slot

ELD Operation

• Verify and decrypt the page using

version

• Populate the EPC slot

• Make back-pointer connection (if

applicable)

• Free-up version slot

SECS

EnclavePage

EnclavePage

EnclavePage

ELD

EncryptedPage

BUILD

EPCSystem Memory

MD

40

VA Page

Free EnclavePage