Experiences in Intel SGX research
Dongsu Han and Seongmin Kim
KAIST
Joint work with: Changho Choi, Soham Desai*, Juhyeng Han, Jaehyung Ha, Prerit Jain*, JaeHyuk Lee, Youjung Shin, Brent Byounghoon Kang and Taesoo Kim*
1 APNet 2017
Experiences in Intel SGX research Dongsu Han and Seongmin Kim KAIST - - PowerPoint PPT Presentation
Experiences in Intel SGX research Dongsu Han and Seongmin Kim KAIST Joint work with: Changho Choi, Soham Desai*, Juhyeng Han, Jaehyung Ha, Prerit Jain*, JaeHyuk Lee, Youjung Shin, Brent Byounghoon Kang and Taesoo Kim* * APNet 2017 1 Trend 1:
1 APNet 2017
2 APNet 2017
3 APNet 2017
4
APNet 2017
5
Encrypted code/data
APNet 2017
Challenger
6
Target Enclave
QuoBng Enclave SGX CPU
MAC
CMAC Hash
APNet 2017
7
APNet 2017
8
9
10
11
EPC
Memory (Untrusted) Plaintext Code/Data
Code/Data
Plaintext Code/Data
Code/Data
Plaintext Code/Data Plaintext Code/Data
Code/Data Code/Data
13
Enclave
ApplicaTon code
13
APNet 2017
14
SGX OS EmulaBon SGX QEMU (HW emulaBon) Enclave Program OpenSGX toolchain Enclave loader SGX Libraries
Trampoline Stub
RunBme library Enclave Debugger Performance Monitor
APNet 2017
Binary TranslaTon
15
SGX instrucBons
Wrapper
Lib Stack Heap
Enclave
Code Data
EPC EPC EPC EPC EPC
enclu(){ …
asm(“.byte 0x0f” “.byte 0x01” “.byte 0xd7” “rax=entry”
… }
Entry point
… if(opcode == 0x0f01d7) { helper_enclu(); } …
EENTER
16
EPC_begin EPC_end enclave_begin enclave_end
… Case (Load | Store) { } …
EPC to current enclave’s EPC
from host to EPC
17
– Except for debugging related instrucTons (e.g., EDBGRD) – Instead, it offers rich environment for debugging since it is a “so_ware emulator” (e.g., GDB stub)
APNet 2017
18
– Bootstrapping (EPC allocaTon) – Enclave iniTalizaTon & page translaTon – Dynamic EPC page allocaTon
sys_sgx_init() Allocate EPC memory region sys_init_enclave() Create an enclave, Add and measure EPC pages sys_add_epc() Allocates a new EPC page to the running enclave sys_stat_enclave() Obtains the enclave performance staTsTcs
APNet 2017
…
19
Code Heap Lib
Trampoline
… if (fcode == FUNC_MALLOC) alloc_tramp(); …
fcode mcode argument1 heap_end
Heap
… malloc(100); … malloc(){ … sgx_exit(tram); … }
<SpecificaBon> fcode : FUNC_MALLOC mcode : EAUG size: 100
Stub
Stub
…
20
Code
…
malloc(100);
…
Heap Lib
malloc(){ … sgx_exit(tram); … }
int sys_add_epc() { encls(EAUG, …); …
Trampoline
Call EAUG heap_end
heap_end+4K FUNC_MALLOC EAUG 100
… if (fcode == FUNC_MALLOC) alloc_tramp(); …
alloc_tramp() { … sys_add_epc(); … }
User-level APIs to request system calls
21
APNet 2017
void enclave_main(){ char *hello = “hello sgx!\n”; sgx_enclave_write(hello, strlen(hello)); sgx_exit(NULL); } $opensgx –c hello.c $ opensgx –s hello.sgx –key sign.key $ opensgx hello.sgx hello.conf hello sgx! Code enclave_main() Data “hello sgx\n” 0x0000 EPC1 0x1000 EPC2 Entry point : SigStruct: …
22
SGX-enabled VM migraTon [IEEE SERVICES16], System-level OpenSGX [Computers & Security17], …
APNet 2017
23
24
– Helps users to defend against traffic analysis and keep user’s privacy
(e.g., what sites you visit, IP address) [from Tor project, www.torproject.org] – Freely available as an open source – 1.8 million users on a daily basis
* from Onionview, h6ps://onionview.codeplex.com/
APNet 2017
The geographic locaTon of Tor relays *
25
– Tor is a volunteer-based network: Tor relays are not trusted
Can observe some fracBon of network traffic Can run a Tor relays of his own Can compromise some fracBon of Tor relays Entry Middle Exit Tor client DesTnaTon Plain-text TLS channel TLS channel TLS channel
Processing Unit : Cell (512 Bytes)
APNet 2017
26
Entry Middle Exit Tor clients DesTnaTon
Plain-text TLS channel TLS channel TLS channel
ALackers can modify the behavior
Give false informaTon to others Modify or inject the cell
Bandwidth 20MB/s 150MB/s
Inflated!
Processing Unit: Cell (512 Bytes)
InformaBon visible to aLackers
Cell: header DemulTplex and idenTfy a circuit
Cell Cell
APNet 2017
27
Intel SGX Improved trust model OperaBonal privacy PracBcality Tor network
Middle
Improved trust model OperaBonal privacy PracBcality
trust in pracTce
privacy
and Tor operaTons
more hardware resources donated
deployable
APNet 2017
28
Enclave memory SSL Library ALestaBon Module Sealing Module
Seals/unseals private data Integrity check
Tor code/data (Core)
Crypto/TLS operaTons
Securely obtains the entropy and Tme value Encrypts and stores the sensiTve data outside the enclave Validates the enclave hash of the Tor program
APNet 2017
29
Enclave memory SSL Library ALestaBon Module Sealing Module
Seals/unseals private data Integrity check
Tor code/data (Core)
Crypto/TLS operaTons System Call Enclave CreaTon
Enclave iniTalizaTon
Standard Library (glibc) Tor code/data (Untrusted) SGX RunBme Library Applica0on ECALL OCALL
Request system services
OCALL/ECALL Wrapper
30
Enclave memory SSL Library ALestaBon Module Sealing Module
Seals/unseals private data Integrity check
Tor code/data (Core)
Crypto/TLS operaTons System Call Enclave CreaTon
Enclave iniTalizaTon
Standard Library (glibc) Tor code/data (Untrusted) SGX RunBme Library Applica0on ECALL OCALL
Request system services
OCALL/ECALL Wrapper Narrow interface
Sanity checking
31
Replay Cell counBng
Directory authoriBes Malicious relay (modified Tor)
scanning
consensus document AdverTsed BW Inflated!
APNet 2017
Entry Middle Exit Tor clients DesTnaTon
Plain-text TLS channel TLS channel TLS channel
32
Replay Cell counBng
Directory authoriBes Malicious relay (modified Tor)
scanning
consensus document AdverTsed BW Inflated!
APNet 2017
Entry Middle Exit Tor clients DesTnaTon
Plain-text TLS channel TLS channel TLS channel ALract more clients!
33
ALacks defeated/miBgated by SGX-Tor
Entry Middle Exit Tor clients DesTnaTon
Plain-text TLS channel TLS channel TLS channel
Circuit establishment Cell creaTon EncrypTon/ DecrypTon Onion/SSL key creaTon
Enclave Enclave Enclave
Cell Circuit descriptor Private keys
34
– Establish a private Tor network – For the realisTc scenario, we consider the “locality of relays” (Asia, EU, U.S. West, U.S. East)
0.2 0.4 0.6 0.8 1 250 500 750 1000 CummulaTve Prob.
Time-to-first-byte (ms)
10MB 100MB 30 60 90 120 HTTPS HTTP HTTPS HTTP
Throughput (Mbps)
File Size (MB)
client server Entry (KAIST) Middle (Cloud)
Exit (Gatech)
<EvaluaBon environment>
: SGX-Tor : Original Tor
11.9% degradaTon 3.9% addiTonal latency
Enclave Enclave
35 APNet 2017
36 APNet 2017
37 APNet 2017
38 APNet 2017
39
APNet 2017
40
41
… malloc(); … ApplicaTon In-enclave Lib
Stub
heap_end cur_heap_ptr
void *malloc(int size){ if(cur_heap_ptr == heap_end) { stub->mcode = EAUG; exit(trampoline); }
Trampoline
malloc_tramp() { sys_add_epc(); } enclu(EACCEPT, …); int sys_add_epc() { … }
Bad EPC page Detect!
42
SGX OS EmulaBon QEMU SGX
ENCLS (e.g., EINIT)
Entry point Measurement Key …
SGX Lib
Trampoline Stub
Wrapper
Lib Stack Heap
Enclave Program
Code Data
EPC EPC EPC EPC EPC
Privilege boundary System calls boundary
ENCLU (e.g., EENTER) ENCLU (e.g., EEXIT) System call (e.g., sys_sgxinit())
43
APNet 2017
44
compuTng
OS (untrusted) ApplicaTon (untrusted)
Secure container Integrity checking à Prevents behavior modificaTon Modified Tor code
– NaTve performance in the secure mode – Available on Intel Skylake and Kaby lake CPU Cannot access data, flow control X à Protects the secrecy of the program
edit
Original
APNet 2017
45
Directory authoriBes
Tor client DesTnaTon Anonymity Broken!
APNet 2017
46
Tor client DesTnaTon Anonymity Broken!
…
number of relays Out-of-scope: network-level adversary (controls a large fracTon of network)
APNet 2017
Directory authoriBes
47
Out-of-scope : network-level adversary who can controls a large fracBon of Tor network
APNet 2017
Tor client DesTnaTon Anonymity Broken!
…
number of relays
Directory authoriBes
48
– AuthoriTes cannot fully verify the behaviors of them
– Access internal informaTon (circuit idenTfier, cell header, …)
– Modify the behavior of relays (DDoS, packet tampering, …)
[Security09, CCS11]
[LEET11]
descriptors [S&P13]
[Security15]
CCS12, S&P13]
S&P13]
49
APNet 2017
Entry Middle Exit Tor clients DesTnaTon
Plain-text TLS channel TLS channel TLS channel
50
Intel SGX Improved trust model OperaBonal privacy PracBcality Tor network
Middle
Improved trust model OperaBonal privacy PracBcality
trust in pracTce
privacy
and Tor operaTons
more hardware resources donated
deployable
APNet 2017
51
scale traffic analysis
à MiTgated by recent SGX research: Moat [CCS16], SGX-Shield [NDSS17], T-SGX [NDSS17]
OS (untrusted) ApplicaTon (untrusted) Enclave CPU
Powerful network-level adversary : out-of-scope TCB : Enclave + CPU package
<SGX Threat model> <Tor Threat model>
52
– AutomaTcally admits “unmodified” and “SGX-enabled” relays – Improved trust model: current implicit trust model turns into the explicit trust model
Directory authority Tor relays Expected hash Admit (match success) A_estaTon fail (not SGX-enabled) A_estaTon fail (bad hash)
Enclave Enclave
Remote A_estaTon
Enclave
Nickname: OR1 Nickname: OR2 Nickname: OR3 Consensus document (modified)
name: OR1 BW: 20MB/s fingerprint: ….
NOTE: Tor uses the same binary for directory authoriTes, Tor relays, and client proxies
APNet 2017
53
– Allows admission of non-SGX relays without remote a_estaTon – SGX-enabled clients can get the list of SGX-Tor relays from SGX-enabled authoriTes
Entry Middle Exit
Tor client DesTnaTon
Enclave Enclave Enclave Enclave … Enclave Enclave
Directory authoriTes Remote A_estaTon
Enclave Enclave
APNet 2017
54
APNet 2017
55
1) What kind of sensiBve data of Tor is protected by SGX-Tor? 2) What is the performance overhead of running SGX-Tor? 3) How compaBble and incrementally deployable is SGX-Tor with the current Tor network?
– SGX CPUs: Intel Core i7-6700 (3.4GHz) and Intel Xeon CPU E3-1240 (3.5GHz) – ConfiguraTon: 128MB Enclave Page Cache (EPC) – Running Tor in Windows, Firefox as a Tor browser (in the client proxy) – Establish a private Tor network using chutney
APNet 2017
56
Current Tor Network-level adversary SGX-Tor
TCP/IP header Visible Visible Visible TLS-encrypted bytestream Visible Visible Visible Cell Visible Not visible Not visible Circuit ID Visible Not visible Not visible VoTng result Visible Not visible Not visible Consensus document Visible Not visible Not visible Hidden service descriptor Visible Not visible Not visible List of relays Visible Not visible Not visible Private keys Visible Not visible Not visible
APNet 2017
0.2 0.4 0.6 0.8 1 1 2 3
CummulaTve Prob. Hidden Service Throughput
57
– Web latency: VisiTng Alexa Top 50 websites – Hidden service: HTTP file server (downloading 10MB) 0.2 0.4 0.6 0.8 1 50 100 150
CummulaTve Prob. Webpage Loading Time (s)
: SGX-Tor : Original Tor
3.3% degradaTon 7.4% addiTonal latency
SGX-Tor : 13.2s Original : 12.2s SGX-Tor : 1.30Mbps Original : 1.35Mbps
APNet 2017
58
– Collected results for two weeks
AdverBsed bandwidth * Middle selecBon Probability Network I/O bandwidth per second
: SGX-Tor : Original Tor
Fast Stable
* From h_ps://collector.torproject.org/
Serves Tor traffic well Actually selected by mulTple Tor users Listed in the consensus document
APNet 2017
59
and demonstrate its viability
– Gives moderate performance overhead – Shows its compaTbility and possibility of incremental deployment
– Defending against exisTng a_acks on Tor – Bringing changes to the trust model of Tor – Providing new properTes : automaTc admission
APNet 2017
60 APNet 2017