SGXBounds Memory Safety for Shielded Execution Dmitrii Kuvaiskii , - - PowerPoint PPT Presentation

sgxbounds
SMART_READER_LITE
LIVE PREVIEW

SGXBounds Memory Safety for Shielded Execution Dmitrii Kuvaiskii , - - PowerPoint PPT Presentation

SGXBounds Memory Safety for Shielded Execution Dmitrii Kuvaiskii , Oleksii Oleksenko , Sergei Arnautov , Bohdan Trach , Pramod Bhatotia * , Pascal Felber , Christof Fetzer TU Dresden, * The University of Edinburgh,


slide-1
SLIDE 1

Eurosys 2017

SGXBounds

Memory Safety for Shielded Execution

Dmitrii Kuvaiskii †, Oleksii Oleksenko †, Sergei Arnautov †, Bohdan Trach †, Pramod Bhatotia *, Pascal Felber ‡, Christof Fetzer †

† TU Dresden, * The University of Edinburgh, ‡ University of Neuchâtel

slide-2
SLIDE 2

Eurosys 2017

Security in the Cloud

1

  • Security is a key barrier to adoption of cloud computing
slide-3
SLIDE 3

Eurosys 2017

Security in the Cloud

1

  • Security is a key barrier to adoption of cloud computing
  • Attackers compromise confjdentiality and integrity
slide-4
SLIDE 4

Eurosys 2017

Security in the Cloud

1

  • Security is a key barrier to adoption of cloud computing
  • Attackers compromise confjdentiality and integrity

➥ Malicious host (e.g., cloud provider) ➥ Software vulnerabilities

slide-5
SLIDE 5

Eurosys 2017

Security in the Cloud

Shielded execution (SGX Enclave) Malicious OS

Virtual Address Space

1

  • Security is a key barrier to adoption of cloud computing
  • Attackers compromise confjdentiality and integrity

➥ Malicious host (e.g., cloud provider) ➥ Software vulnerabilities

slide-6
SLIDE 6

Eurosys 2017

Security in the Cloud

Shielded execution (SGX Enclave)

Virtual Address Space

1

  • Security is a key barrier to adoption of cloud computing
  • Attackers compromise confjdentiality and integrity

➥ Malicious host (e.g., cloud provider) ➥ Software vulnerabilities

slide-7
SLIDE 7

Eurosys 2017

Security in the Cloud

Shielded execution (SGX Enclave)

Virtual Address Space

1

Heartbleed Cloudbleed

  • Security is a key barrier to adoption of cloud computing
  • Attackers compromise confjdentiality and integrity

➥ Malicious host (e.g., cloud provider) ➥ Software vulnerabilities

slide-8
SLIDE 8

Eurosys 2017

Protecting against Attacks

2

SGX Enclave

(malicious host)

slide-9
SLIDE 9

Eurosys 2017

Protecting against Attacks

2

SGX Enclave Memory safety

+

(malicious host) (vulnerabilities)

slide-10
SLIDE 10

Eurosys 2017

Protecting against Attacks

SGX Enclave Memory safety

+

AddressSanitizer

(software-based)

Intel MPX

(hardware-based)

2

(malicious host) (vulnerabilities)

slide-11
SLIDE 11

Eurosys 2017

Protecting against Attacks

SGX Enclave Memory safety

+

State-of-the-art memory-safety mechanisms are ineffjcient!

2

(malicious host) (vulnerabilities) AddressSanitizer

(software-based)

Intel MPX

(hardware-based)

slide-12
SLIDE 12

Eurosys 2017

State-of-the-Art: SQLite example

3

slide-13
SLIDE 13

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

slide-14
SLIDE 14

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

slide-15
SLIDE 15

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

slide-16
SLIDE 16

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

slide-17
SLIDE 17

Eurosys 2017

3

SGX Enclave Memory safety

+

How to make it effjcient?

(malicious host) (vulnerabilities)

slide-18
SLIDE 18

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

slide-19
SLIDE 19

Eurosys 2017

lower better

3

State-of-the-Art: SQLite example

SGXBounds is practical

slide-20
SLIDE 20

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-21
SLIDE 21

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-22
SLIDE 22

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-23
SLIDE 23

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

☹ Increased latency of memory accesses Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-24
SLIDE 24

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

Enclave Page Cache (94MB) CPU Cache (8MB) DRAM (64GB)

☹ Increased latency of memory accesses

Physical Address Space

Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-25
SLIDE 25

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

Enclave Page Cache (94MB) CPU Cache (8MB) DRAM (64GB)

☹ Increased latency of memory accesses

MEE encryption (1-12x)

Physical Address Space

Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-26
SLIDE 26

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

Enclave Page Cache (94MB) CPU Cache (8MB) DRAM (64GB)

☹ Increased latency of memory accesses

MEE encryption (1-12x) EPC paging (2-2000x)

Physical Address Space

Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-27
SLIDE 27

Eurosys 2017

Constraints of SGX Enclaves

Shielded execution (SGX Enclave)

Virtual Address Space

4

Enclave Page Cache (94MB) CPU Cache (8MB) DRAM (64GB)

☹ Increased latency of memory accesses ☹ Limited enclave memory (4GB)

MEE encryption (1-12x) EPC paging (2-2000x)

4GB Physical Address Space

Why AddressSanitizer and Intel MPX perform poorly under SGX?

slide-28
SLIDE 28

Eurosys 2017

State-of-the-Art: Metadata Layout

5

Assumptions of AddressSanitizer and Intel MPX violated in SGX!

slide-29
SLIDE 29

Eurosys 2017

State-of-the-Art: Metadata Layout

5

Assumptions of AddressSanitizer and Intel MPX violated in SGX!

  • bject

red zone

512MB

shadow object

red zone

pointer pointer

Bounds Directory

  • bject

Bounds Table 1

AddressSanitizer Intel MPX

slide-30
SLIDE 30

Eurosys 2017

State-of-the-Art: Metadata Layout

5

☹ Fast accesses to metadata ☹ Almost endless memory Assumptions of AddressSanitizer and Intel MPX violated in SGX!

  • bject

red zone

512MB

shadow object

red zone

pointer pointer

Bounds Directory

  • bject

Bounds Table 1

AddressSanitizer Intel MPX

slide-31
SLIDE 31

Eurosys 2017

State-of-the-Art: Metadata Layout

5

☹ Fast accesses to metadata ≠ increased latency ☹ Almost endless memory ≠ limited enclave memory Assumptions of AddressSanitizer and Intel MPX violated in SGX!

  • bject

red zone

512MB

shadow object

red zone

pointer pointer

Bounds Directory

  • bject

Bounds Table 1

AddressSanitizer Intel MPX

slide-32
SLIDE 32

Eurosys 2017

State-of-the-Art: Metadata Layout

5

☹ Fast accesses to metadata ≠ increased latency ☹ Almost endless memory ≠ limited enclave memory Assumptions of AddressSanitizer and Intel MPX violated in SGX!

  • bject

red zone

512MB

shadow object

red zone

pointer pointer

Bounds Directory

  • bject

Bounds Table 1

AddressSanitizer Intel MPX

Ineffjcient!

slide-33
SLIDE 33

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-34
SLIDE 34

Eurosys 2017

SGXBounds: Metadata Layout

6

Memory contraints of SGX dictated design of SGXBounds

slide-35
SLIDE 35

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata Memory contraints of SGX dictated design of SGXBounds

slide-36
SLIDE 36

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

slide-37
SLIDE 37

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

pointer

31 63

  • bject

SGXBounds

slide-38
SLIDE 38

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

pointer

31 63

  • bject

SGXBounds

slide-39
SLIDE 39

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

pointer UB

31 63

  • bject

LB

SGXBounds

4B

slide-40
SLIDE 40

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

pointer UB

31 63

  • bject

SGXBounds

4B

– Upper bound (UB) in pointer – Lower bound (LB) per object

LB

slide-41
SLIDE 41

Eurosys 2017

SGXBounds: Metadata Layout

6

☺ Increased latency → minimize accesses to metadata ☺ Limited enclave memory → minimize space of metadata Memory contraints of SGX dictated design of SGXBounds

pointer UB

31 63

  • bject

SGXBounds

4B

– Upper bound (UB) in pointer – Lower bound (LB) per object – Out-of-the-box multithreading (unlike MPX)

LB

slide-42
SLIDE 42

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds

LB

slide-43
SLIDE 43

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB LB

slide-44
SLIDE 44

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB

☹ Data leak through write(socket, pointer, objlen)

LB

slide-45
SLIDE 45

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB

☹ Data leak through write(socket, pointer, objlen)

LB

slide-46
SLIDE 46

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB

Bounds-check before each memory access:

LB ≤ pointer ≤ UB

☹ Data leak through write(socket, pointer, objlen) ☺ Protect using effjcient bounds checks

LB

slide-47
SLIDE 47

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB embedded in tagged pointer

Bounds-check before each memory access:

LB ≤ pointer ≤ UB

☹ Data leak through write(socket, pointer, objlen) ☺ Protect using effjcient bounds checks

LB

slide-48
SLIDE 48

Eurosys 2017

SGXBounds: Detecting Vulnerabilities

7

How SGXBounds detects vulnerabilities like Heartbleed?

pointer UB

  • bject

SGXBounds password

LB loaded from memory based on UB embedded in tagged pointer

Bounds-check before each memory access:

LB ≤ pointer ≤ UB

☹ Data leak through write(socket, pointer, objlen) ☺ Protect using effjcient bounds checks

LB

slide-49
SLIDE 49

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-50
SLIDE 50

Eurosys 2017

SGXBounds: Implementation

8

SGXBounds (LLVM pass)

slide-51
SLIDE 51

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Shielded app (e.g., SCONE) Source code

8

slide-52
SLIDE 52

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Operating System Shielded app (e.g., SCONE) Source code CPU RAM

SGX

8

slide-53
SLIDE 53

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Operating System Shielded app (e.g., SCONE) Source code CPU RAM

SGX

Advanced features:

8

slide-54
SLIDE 54

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Operating System Shielded app (e.g., SCONE) Source code CPU RAM

SGX

Advanced features:

➥ Tolerating errors with boundless memory ➥ Metadata management support ➥ Compile-time optimizations

8

slide-55
SLIDE 55

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Operating System Shielded app (e.g., SCONE) Source code CPU RAM

SGX

Advanced features:

➥ Tolerating errors with boundless memory ➥ Metadata management support ➥ Compile-time optimizations

See paper for details

8

slide-56
SLIDE 56

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-57
SLIDE 57

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

➥ Benchmark suites ➥ Case studies ➥ Security

slide-58
SLIDE 58

Eurosys 2017

9

Benchmark Suites

ASan MPX SGXBounds

slide-59
SLIDE 59

Eurosys 2017

9

Benchmark Suites

ASan MPX SGXBounds Phoenix 1.41 2.27 1.13

slide-60
SLIDE 60

Eurosys 2017

Benchmark Suites

* some programs failed due to insuffjcient memory

9

ASan MPX SGXBounds Phoenix 1.41 2.27 1.13 PARSEC 1.60 1.43* 1.20

slide-61
SLIDE 61

Eurosys 2017

Benchmark Suites

ASan MPX SGXBounds Phoenix 1.41 2.27 1.13 PARSEC 1.60 1.43* 1.20 SPEC 1.76 1.52* 1.41

* some programs failed due to insuffjcient memory

9

slide-62
SLIDE 62

Eurosys 2017

10

Case Studies

slide-63
SLIDE 63

Eurosys 2017

Case Studies

10

slide-64
SLIDE 64

Eurosys 2017

Case Studies

10

slide-65
SLIDE 65

Eurosys 2017

Case Studies ☹ MPX: EPC thrashing on Memcached

10

slide-66
SLIDE 66

Eurosys 2017

Case Studies ☹ MPX: EPC thrashing on Memcached ☹ ASan: metadata overload on Nginx

10

slide-67
SLIDE 67

Eurosys 2017

Case Studies ☹ MPX: EPC thrashing on Memcached ☹ ASan: metadata overload on Nginx ☺ SGXBounds: no corner cases

10

slide-68
SLIDE 68

Eurosys 2017

Security guarantees

11

slide-69
SLIDE 69

Eurosys 2017

Security guarantees ☺ RIPE synthetic benchmark:

➥ Similar guarantees as ASan and MPX

11

slide-70
SLIDE 70

Eurosys 2017

Security guarantees ☺ RIPE synthetic benchmark:

➥ Similar guarantees as ASan and MPX

☺ Real-world vulnerabilities detected and tolerated:

➥ Memcached denial-of-service ➥ Nginx stack bufger overfmow ➥ Apache Heartbleed

11

slide-71
SLIDE 71

Eurosys 2017

– Motivation – Constraints of SGX enclaves – Design of SGXBounds – Implementation of SGXBounds – Evaluation

slide-72
SLIDE 72

Eurosys 2017

Conclusion

12

slide-73
SLIDE 73

Eurosys 2017

Conclusion

12

  • Security is barrier to adoption of cloud computing

➥ Use shielded execution with Intel SGX

slide-74
SLIDE 74

Eurosys 2017

Conclusion

12

  • Security is barrier to adoption of cloud computing

➥ Use shielded execution with Intel SGX

  • Insuffjcient to protect against SW vulnerabilities

➥ Use memory defense like ASan and MPX

slide-75
SLIDE 75

Eurosys 2017

Conclusion

  • Security is barrier to adoption of cloud computing

➥ Use shielded execution with Intel SGX

  • Insuffjcient to protect against SW vulnerabilities

➥ Use memory defense like ASan and MPX

  • ASan and MPX perform poorly in SGX enclaves

➥ Their memory assumptions are violated in SGX

12

slide-76
SLIDE 76

Eurosys 2017

Conclusion

  • Security is barrier to adoption of cloud computing

➥ Use shielded execution with Intel SGX

  • Insuffjcient to protect against SW vulnerabilities

➥ Use memory defense like ASan and MPX

  • ASan and MPX perform poorly in SGX enclaves

➥ Their memory assumptions are violated in SGX

  • SGXBounds: memory safety for shielded execution

12

slide-77
SLIDE 77

Eurosys 2017

Conclusion

  • Security is barrier to adoption of cloud computing

➥ Use shielded execution with Intel SGX

  • Insuffjcient to protect against SW vulnerabilities

➥ Use memory defense like ASan and MPX

  • ASan and MPX perform poorly in SGX enclaves

➥ Their memory assumptions are violated in SGX

  • SGXBounds: memory safety for shielded execution

12

Thank you!

dmitrii.kuvaiskii@tu-dresden.de https://github.com/tudinfse/sgxbounds

slide-78
SLIDE 78

Eurosys 2017

Backup slides

slide-79
SLIDE 79

Eurosys 2017

Intel SGX and SCONE

SGX Enclave (legacy app with SCONE) Asynchronous syscalls

Virtual Address Space – V. Costan, S. Devadas. „Intel SGX Explained“. IACR Cryptology ePrint Archive '16 – S. Arnautov et al. „SCONE: Secure linux containers with Intel SGX“. OSDI'16 Application Libraries Network shield FS shield M:N user threading Modifjed Musl C library

SCONE

slide-80
SLIDE 80

Eurosys 2017

SGXBounds: Implementation

a = add x, i store 42, a x = specify_bounds(x, x+N) a = add x, i aptr = extract_ptr(a) UB = extract_upper_bound(a) LB = load_lower_bound(UB) if (aptr < LB or aptr >= UB): handle_error(aptr) store 42, a

Native SGXBounds

SGXBounds (LLVM pass)

Operating System Application Source code CPU RAM

SGX

slide-81
SLIDE 81

Eurosys 2017

Related Work (SPEC CPU2006 outside of SGX enclave)

Perf Mem Comments

Intel MPX 146% 116% FP/FN for multithreaded AddressSanitizer 38% 292% – BaggyBounds1 70% 12% Not publicly available Low-Fat Pointers2 54% 12% Not publicly available SGXBounds 55% 0% (this work)

1 P. Akritidis et al. „Baggy Bounds Checking: An effjcient and backwards-compatible

defense against out-of-bounds errors“. Usenix Security'09

2 G. Duck et al. „Stack Bounds Protection with Low Fat Pointers“. NDSS'17

slide-82
SLIDE 82

Eurosys 2017

SGXBounds: Implementation

SGXBounds (LLVM pass)

Operating System App (in SCONE) Source code CPU RAM

SGX

Instrumentation:

data: lower bound metadata after each allocated object pointers: upper bound metadata in each data pointer code: bounds-check before each memory access

slide-83
SLIDE 83

Eurosys 2017

Security guarantees

MPX ASan SGXBounds

RIPE benchmark 2/16 8/16 8/16 Memcached CVE-2011-4971

D (T) D (T) D (T)

Nginx CVE-2013-2028

D (T) D (T) D (T)

Apache Heartbleed

D (T) D (T) D (T)

D detected? T tolerated?

slide-84
SLIDE 84

Eurosys 2017

Case Studies: Full Picture

slide-85
SLIDE 85

Eurosys 2017

Classes of Defenses against Attacks

CF – control fmow hijack, DO – data-only attack, IL – information leak

slide-86
SLIDE 86

Eurosys 2017

SGXBounds and Boundless Memory

UB pointer p LRU cache victim object LB referent object

*(p+offset)

  • ut-of-bounds

access chunk chunk chunk redirect access

mapping: aligned(p) -> chunk Lower Bound (LB) Upper Bound (UB) 31 63 (p+offset) < LB (p+offset) ≥ UB

  • ut-of-

bounds

rcx

1 M. Rinard et al. „A dynamic technique for eliminating bufger overfmow vulnerabilities (and

  • ther memory errors)“. ACSAC'04
slide-87
SLIDE 87

Eurosys 2017

SGXBounds: Outside of Enclaves