outline how to besiege a fortress
play

Outline: How to besiege a fortress? Idea: security is weakest at the - PowerPoint PPT Presentation

Outline: How to besiege a fortress? Idea: security is weakest at the input/output interface(!) 1 / 21 Outline: How to besiege a TEE enclave? OpenEnclave SGX-SDK Rust-EDP Graphene SGX-LKL Keystone Runtime Sancus Asylo Vulnerability #1


  1. Outline: How to besiege a fortress? Idea: security is weakest at the input/output interface(!) 1 / 21

  2. Outline: How to besiege a TEE enclave? OpenEnclave SGX-SDK Rust-EDP Graphene SGX-LKL Keystone Runtime Sancus Asylo Vulnerability #1 Entry status flags sanitization ⋆ ⋆ � � � � � � � � Tier1 #2 Entry stack pointer restore ⋆ ⋆ � � � � � � (ABI) #3 Exit register leakage ⋆ � � � � � � � #4 Missing pointer range check ⋆ ⋆ ⋆ ⋆ � � � � � ⋆ #5 Null-terminated string handling � � � � � � #6 Integer overflow in range check � � � � � � � � Tier2 #7 Incorrect pointer range check � � � � � � � � (API) #8 Double fetch untrusted pointer � � � � � � � � ⋆ ⋆ ⋆ ⋆ #9 Ocall return value not checked � � � � #10 Uninitialized padding leakage [LK17] ⋆ ⋆ ⋆ � � � � Summary: > 35 enclave interface sanitization vulnerabilities across 8 projects 1 / 21

  3. Outline: How to besiege a TEE enclave? OpenEnclave SGX-SDK Rust-EDP Graphene SGX-LKL Keystone Runtime Sancus Asylo Vulnerability #1 Entry status flags sanitization ⋆ ⋆ � � � � � � � � Tier1 #2 Entry stack pointer restore ⋆ ⋆ � � � � � � (ABI) #3 Exit register leakage ⋆ � � � � � � � #4 Missing pointer range check ⋆ ⋆ ⋆ ⋆ � � � � � ⋆ #5 Null-terminated string handling � � � � � � #6 Integer overflow in range check � � � � � � � � Tier2 #7 Incorrect pointer range check � � � � � � � � (API) #8 Double fetch untrusted pointer � � � � � � � � ⋆ ⋆ ⋆ ⋆ #9 Ocall return value not checked � � � � #10 Uninitialized padding leakage [LK17] ⋆ ⋆ ⋆ � � � � Impact: 5 CVEs . . . and lengthy embargo periods 1 / 21

  4. Why do we need enclave fortresses anyway?

  5. The big picture: Enclaved execution attack surface App App App App OS kernel Hypervisor TPM CPU Mem HDD Traditional layered designs: large trusted computing base 2 / 21

  6. The big picture: Enclaved execution attack surface App App Enclave app OS kernel Hypervisor TPM CPU Mem HDD Intel SGX promise: hardware-level isolation and attestation 2 / 21

  7. The big picture: Enclaved execution attack surface App App Enclave app OS kernel Hypervisor TPM CPU Mem HDD Previous attacks: exploit microarchitectural bugs or side-channels at the hardware level 2 / 21

  8. The big picture: Enclaved execution attack surface App App Enclave app OS kernel Hypervisor TPM CPU Mem HDD Idea: what about vulnerabilities in the trusted enclave software itself? 2 / 21

  9. What do these projects have in common?

  10. Why isolation is not enough: Enclave shielding runtimes untrusted world secure world "enclave" TEE processor TEE promise: enclave == “secure oasis” in a hostile environment 3 / 21

  11. Why isolation is not enough: Enclave shielding runtimes untrusted world secure world "enclave" TEE processor TEE promise: enclave == “secure oasis” in a hostile environment . . . but application writers and compilers are largely unaware of isolation boundaries 3 / 21

  12. Why isolation is not enough: Enclave shielding runtimes untrusted world secure world "enclave" TEE processor TEE promise: enclave == “secure oasis” in a hostile environment . . . but application writers and compilers are largely unaware of isolation boundaries Trusted shielding runtime transparently acts as a secure bridge on enclave entry/exit 3 / 21

  13. . . . but what if the bridge itself is flawed?

  14. Enclave shielding responsibilities Key questions: how to securely bootstrap from the untrusted world to the enclaved application binary (and back)? Which sanitizations to apply? EENTER enclave shielding runtime 4 / 21

  15. Enclave shielding responsibilities Key insight: split sanitization responsibilities across the ABI and API tiers: machine state vs. higher-level programming language interface Tier 1 Tier 2 Tier 3 EENTER ABI API APP enclave shielding runtime 4 / 21

  16. Tier1: Establishing a trustworthy enclave ABI Tier 1 Tier 2 Tier 3 ABI API APP 5 / 21

  17. Tier1: Establishing a trustworthy enclave ABI ↝ Attacker controls CPU register contents on enclave entry/exit ↔ Compiler expects well-behaved calling convention (e.g., stack) ⇒ Need to initialize CPU registers on entry and scrub before exit! 5 / 21

  18. Tier1: Establishing a trustworthy enclave ABI ↝ Attacker controls CPU register contents on enclave entry/exit ↔ Compiler expects well-behaved calling convention (e.g., stack) ⇒ Need to initialize CPU registers on entry and scrub before exit! ABI vulnerability analysis Relatively well-understood, but special care for stack pointer + status register 5 / 21

  19. Summary: ABI-level attack surface OpenEnclave SGX-SDK Rust-EDP Graphene SGX-LKL Keystone Runtime Sancus Asylo Vulnerability #1 Entry status flags sanitization ⋆ ⋆ � � � � � � � � Tier1 #2 Entry stack pointer restore ⋆ ⋆ � � � � � � (ABI) #3 Exit register leakage ⋆ � � � � � � � Read the paper for several exploitable ABI vulnerabilities! 6 / 21

  20. Summary: ABI-level attack surface OpenEnclave SGX-SDK Rust-EDP Graphene SGX-LKL Keystone Runtime Sancus Asylo Vulnerability #1 Entry status flags sanitization ⋆ ⋆ � � � � � � � � Tier1 #2 Entry stack pointer restore ⋆ ⋆ � � � � � � (ABI) #3 Exit register leakage ⋆ � � � � � � � x86 CISC (Intel SGX) RISC A lesson on complexity Attack surface complex x86 ABI (Intel SGX) >> simpler RISC designs 6 / 21

  21. x86 string instructions: Direction Flag (DF) operation Special x86 rep string instructions to speed up streamed memory operations l e a rdi , buf 1 / ∗ memset ( buf , 0 x0 , 100) ∗ / 2 mov al , 0x0 1 → f o r ( i n t i =0; i < 100; i++) 3 mov ecx , 100 2 buf [ i ] = 0x0 ; 3 rep s t o s [ r d i ] , a l 4 7 / 21

  22. x86 string instructions: Direction Flag (DF) operation Special x86 rep string instructions to speed up streamed memory operations Default operate left-to-right l e a rdi , buf 1 / ∗ memset ( buf , 0 x0 , 100) ∗ / 2 mov al , 0x0 1 → f o r ( i n t i =0; i < 100; i++) 3 mov ecx , 100 2 buf [ i ] = 0x0 ; 3 rep s t o s [ r d i ] , a l 4 00 0000000000000000000000000000 rdi 7 / 21

  23. x86 string instructions: Direction Flag (DF) operation Special x86 rep string instructions to speed up streamed memory operations Default operate left-to-right , unless software sets RFLAGS.DF=1 l e a rdi , buf+100 1 / ∗ memset ( buf , 0 x0 , 100) ∗ / 2 mov al , 0x0 1 → f o r ( i n t i =0; i < 100; i++) 3 mov ecx , 100 2 buf [ i ] = 0x0 ; 3 std ; s e t d i r e c t i o n f l a g 4 rep s t o s [ r d i ] , a l 5 00 0000000000000000000000000000 rdi 7 / 21

  24. SGX-DF: Inverting enclaved string memory operations CVE-2019-14565 x86 System-V ABI 8 / 21

  25. SGX-DF: Inverting enclaved string memory operations CVE-2019-14565 Enter enclave with RFLAGS.DF=0 8 / 21

  26. SGX-DF: Inverting enclaved string memory operations CVE-2019-14565 Intended heap memory initialization: left-to-right 8 / 21

  27. SGX-DF: Inverting enclaved string memory operations CVE-2019-14565 Enter enclave with RFLAGS.DF=1 enclave_func: EENTER buf = malloc (100); memset (buf, 0x00, 100); 000000000 000000000 ... enclave_heap: RFLAGS.DF = 0 RFLAGS.DF = 1 000000000 8 / 21

  28. SGX-DF: Inverting enclaved string memory operations CVE-2019-14565 Enclave heap memory corruption: right-to-left. . . 8 / 21

  29. SGX-AC: Building an intra-cacheline side-channel There’s more! Alignment Check (AC) flag enables exceptions for unaligned data accesses → intra-cacheline side-channel � enclave_func: uint16_t d = lookup_table[secret]; enclave_data: A B C D 64B cacheline 9 / 21

  30. SGX-AC: Building an intra-cacheline side-channel Enter enclave with RFLAGS.AC=1 and secret index=0 → well-aligned data access: no exception enclave_func: EENTER uint16_t d = lookup_table[secret]; secret = 0 RFLAGS.AC = 1 enclave_data: A B C D 64B cacheline 9 / 21

  31. SGX-AC: Building an intra-cacheline side-channel Enter enclave with RFLAGS.AC=1 and secret index=1 → unaligned data access: alignment-check exception. . . 9 / 21

  32. Tier 2: Sanitizing the enclave API Tier 1 Tier 2 Tier 3 ABI API APP 10 / 21

  33. Validating pointer arguments: Confused deputy attacks 11 / 21

  34. Validating pointer arguments: Confused deputy attacks 11 / 21

  35. Validating pointer arguments: Confused deputy attacks 11 / 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend