40
Intel Software Guard Extensions (SGX) Prashant Pandey ([email protected]) Applied Algorithms Lab, Stony Brook University

Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

  • Upload
    others

  • View
    25

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Intel Software Guard Extensions (SGX)

Prashant Pandey ([email protected])Applied Algorithms Lab, Stony Brook University

Page 2: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Story boardüProblem StatementüAttack Surface and OverviewüProgramming environmentü Enclave Life-CycleüDeveloping with SGXü SGX usage models

Page 3: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Are compute devices trustworthy?

Page 4: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Basic Issue: Why aren’t compute devices trustworthy ?

App Code

Privileged Code

App Code

OKX

X X

Protected Mode protects OS from app

Page 5: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Basic Issue: Why aren’t compute devices trustworthy ?

Malicious App

Privileged Code

App Code

OKX

X X

Bad Code

Attack

Apps not protected from privileged code attacks

Page 6: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Basic Issue: Why aren’t compute devices trustworthy ?

Malicious App

Privileged Code

App CodeX

X X

Bad Code

Apps not protected from privileged code attacks

Bad Code

Info

Page 7: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Attack surface

App App App

OS

VMM

Hardware

Attack Surface

Page 8: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Reduced attack surface with SGX

üApplication gains ability to defend its own secret

üMalware that subverts OS/VMM, BIOS, Drivers etc. cannot steal app secrets

ü Single application environment

App App App

OS

VMM

Hardware

Attack Surface

XX

Page 9: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

SGX Programming Environment

OS

App Code

App Data

Enclave (.so)

Enclave Code

SECS

TCS (*n)

Enclave Data

User Process Enclave

Enclave:üHas its own code and dataüProvides ConfidentialityüProvides IntegrityüHas controlled entry pointsü Supports multiple threadsüHas full access to app

memory

Page 10: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Intel SGX Technologyü At its root, Intel SGX is a set of new CPU instructions that

can be used by applications to set aside private regions of code and data

ü Allows app developers to protect sensitive data by rogue software running at higher privilege levels

ü Enable apps to preserve the confidentiality and integrity of sensitive code and data

Page 11: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

SGX high-level HW/SW picture

Enclave Enclave

SGX User Runtime

SGX User Runtime

SGX Module

Platform

ApplicationRuntime

OS Data StrHardware

HW Data Str

Page Tables

EPC EPCM

Application Environment

PrivilegedEnvironment

ExposedHardware

InstructionsEGETKEYEEXITEREPORTEENTERERESUME

InstructionsECREATE ETRACKEADD EWBEEXTEND ELDEINIT EPAEBLOCK EREMOVE

Page 12: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

Page 13: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

EPC

System Memory

Enclave

Page 14: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS

EPC

System Memory

Enclave

Page 15: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

EPC

System Memory

Enclave

Page 16: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

EPC

System Memory

Enclave

Page 17: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

Code/Data

EPC

System Memory

Enclave

Page 18: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Enclave

Page 19: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Enclave

Page 20: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Code/DataEnclave

Code/Data

Code/Data

Page 21: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Code/Data

Valid, ID

Enclave

Code/Data

Code/Data

Page 22: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Valid, ID

Enclave

Code/Data

Code/Data

Page 23: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Valid, ID

EEXTEND

Enclave

Code/Data

Code/Data

Page 24: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Valid, ID

EEXTEND

Enclave

Code/Data

Code/Data

Page 25: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Code/DataValid, ID

EEXTEND

Enclave

Code/Data

Page 26: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Valid, ID

EEXTENDEINITEnclave

Code/Data

Code/Data

Page 27: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Valid, ID

EEXTENDEINITEENTEREnclave

Code/Data

Code/Data

Page 28: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

SECS Valid, ID

Code/Data

Code/Data

EPC

System Memory

Valid, ID

EADD

Code/Data

Valid, ID

EEXTENDEINITEENTEREEXIT

Enclave

Code/Data

Page 29: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

EPC

System Memory

EADDEEXTENDEINITEENTEREEXITEREMOVE

Enclave

Page 30: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Life Cycle of EnclaveVirtual Address Space Physical Address Space

InvalidInvalidInvalid

EPCM

Invalid

ECREATE

AESM

EPC

System Memory

EADDEEXTENDEINITEENTEREEXITEREMOVE

Page 31: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Protection vs. Memory Snooping

ü Security perimeter is 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

Page 32: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Developing with SGX

Intel SGX enabled CPU

Application

AppCode

Trusted

ProcessingComponent

GlueCodeSGXSDKSGXSDKGlueCode

ArchitecturalEnclave

ProcessingComponent

ArchitecturalEnclaveArchitecturalEnclave

Page 33: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Intel SGX Call Gates

OS

App Code

App Data

Enclave (.so)

User Process

Ocalls Ecalls

Page 34: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Intel SGX advantages

• Intel SGX, provides an ability to create a secure enclave [a secure memory area] within a potentially compromised OS

• You can create an enclave with the desired code, then lock it down, measure the code there and if everything is fine, ask the processor to start executing the code

• A nice surprise is that SGX infrastructure no longer depends upon the TPM to perform the measurement

Page 35: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

SGX Technical Summary

ü Provides any application the ability to keep a secretü Provide capability using new processor instructionsü Application can support multiple enclaves

ü Provides integrity and confidentiality ü Resists hardware attacks ü Prevent software access, including privileged software

ü Applications run within OS environmentü Low learning curve for application developersü Open to all developers**

ü Resources managed by system software

Page 36: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

SGX usage models

ü Running a LibOS inside an enclave ü [https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-baumann.pdf]

ü Running hadoop map-reduce jobs inside enclaveü [http://research.microsoft.com/apps/pubs/?id=210786]

ü Building an encrypted file system using SGX to protect against cold boot attacks and DMA attacksü [Not published yet]

ü Running privacy protected genomics workload inside enclaveü [Not published yet]

Page 37: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME
Page 38: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME

Referencesü http://software.intel.com/en-us/articles/innovative-instructions-and-

software-model-for-isolated-executionü http://software.intel.com/en-us/articles/innovative-technology-for-cpu-

based-attestation-and-sealingü http://software.intel.com/sites/default/files/article/413938/hasp-2013-

innovative-instructions-for-trusted-solutions.pdfü http://web.stanford.edu/class/ee380/Abstracts/150415-slides.pdfü AgoodreadtounderstandSGX:

http://theinvisiblethings.blogspot.com/2013/08/thoughts-on-intels-upcoming-software.html

Page 39: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME
Page 40: Intel Software Guard Extensions (SGX) · 2020-01-21 · EPC EPCM Application Environment Privileged Environment Exposed Hardware Instructions EGETKEY EEXIT EREPORT EENTER ERESUME