CopyCat: Controlled Instruction-Level Attacks on Enclaves
- Daniel Moghimi
- Jo Van Bulck
- Nadia Heninger
- Frank Piessens
- Berk Sunar
Intel Labs –
- Sept. 10 2020
CopyCat: Controlled Instruction-Level Attacks on Enclaves Daniel - - PowerPoint PPT Presentation
CopyCat: Controlled Instruction-Level Attacks on Enclaves Daniel Moghimi Jo Van Bulck Nadia Heninger Frank Piessens Berk Sunar Intel Labs Sept. 10 2020 OS/Hypervisor Security Model App App App OS Trusted Hypervisor
Intel Labs –
2
Traditional Security Model
Trusted
3
Traditional Security Model
Trusted
Traditional Security Model
4
Traditional Security Model
5
Traditional Security Model
blocked
blocked
6
SGX Attacks Intel’s Responsibility
Foreshadow [1] Plundervolt [2]
[1] Van Bulck et al. "Foreshadow: Extracting the keys to the intel SGX kingdom with transient out-of-order execution." USENIX Security 2018. [2] Murdock et al. "Plundervolt: Software-based fault injection attacks against Intel SGX." IEEE S&P 2020.
7
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Foreshadow [1] Plundervolt [2]
[1] Van Bulck et al. "Foreshadow: Extracting the keys to the intel SGX kingdom with transient out-of-order execution." USENIX Security 2018. [2] Murdock et al. "Plundervolt: Software-based fault injection attacks against Intel SGX." IEEE S&P 2020.
8
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Foreshadow [1] Plundervolt [2]
µarch Side Channel
Cache [3][4][5] Branch Predictors [6][7] Interrupt Latency [8]
[1] Van Bulck et al. "Foreshadow: Extracting the keys to the intel SGX kingdom with transient out-of-order execution." USENIX Security 2018. [2] Murdock et al. "Plundervolt: Software-based fault injection attacks against Intel SGX." IEEE S&P 2020. [3] Moghimi et al. "Cachezoom: How SGX amplifies the power of cache attacks." CHES 2017. [4] Brasser et al. "Software grand exposure:{SGX} cache attacks are practical." USENIX WOOT 2017. [5] Schwarz et al. "Malware guard extension: Using SGX to conceal cache attacks." DIMVA 2017. [6] Evtyushkin, Dmitry, et al. "Branchscope: A new side-channel attack on directional branch predictor." ACM SIGPLAN 2018. [7] Lee, Sangho, et al. "Inferring fine-grained control flow inside {SGX} enclaves with branch shadowing." USENIX Security 2017. [8] Van Bulck et al. "Nemesis: Studying microarchitectural timing leaks in rudimentary CPU interrupt logic." ACM CCS 2018.
9
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Foreshadow [1] Plundervolt [2]
Deterministic – Ctrl Channel
µarch Side Channel
Cache [3][4][5] Branch Predictors [6][7] Interrupt Latency [8] Page Fault [9] A/D Bit [10]
[1] Van Bulck et al. "Foreshadow: Extracting the keys to the intel SGX kingdom with transient out-of-order execution." USENIX Security 2018. [2] Murdock et al. "Plundervolt: Software-based fault injection attacks against Intel SGX." IEEE S&P 2020. [3] Moghimi et al. "Cachezoom: How SGX amplifies the power of cache attacks." CHES 2017. [4] Brasser et al. "Software grand exposure:{SGX} cache attacks are practical." USENIX WOOT 2017. [5] Schwarz et al. "Malware guard extension: Using SGX to conceal cache attacks." DIMVA 2017. [6] Evtyushkin, Dmitry, et al. "Branchscope: A new side-channel attack on directional branch predictor." ACM SIGPLAN 2018. [7] Lee, Sangho, et al. "Inferring fine-grained control flow inside {SGX} enclaves with branch shadowing." USENIX Security 2017. [8] Van Bulck et al. "Nemesis: Studying microarchitectural timing leaks in rudimentary CPU interrupt logic." ACM CCS 2018. [9] Xu et al. "Controlled-channel attacks: Deterministic side channels for untrusted operating systems." IEEE S&P 2015. [10] Wang, Wenhao, et al. "Leaky cauldron on the dark land: Understanding memory side-channel hazards in SGX." ACM CCS 2017.
10
11
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
Enclave Execution Thread Starts
12
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
13
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
3 4
14
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
1
15
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
16
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
17
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
1
18
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
1
19
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
1
20
NOP ADD XOR MUL DIV ADD MUL NOP NOP
Time
𝑢1 𝑢2
IRQ Range
1
21
I got 15 IRQs. How many zeros?
22
I got 15 IRQs. How many zeros?
DTLB
P
R W U S A …
Physical Page Number
… …
P
R W U S
A
…
Physical Page Number
… …
P
R W U S A …
Physical Page Number
… …
0x000401
Code Page Virtual Address PMH Page Walk
The A Bit is
an instruction is retired
23
24
CALL ADD XOR MUL PUSH ADD MUL MOV NOP
Time
Target Code Page
25
CALL ADD XOR MUL PUSH ADD MUL MOV NOP
Time
Target Code Page Stack Page
4 Steps
26
CALL ADD XOR MUL PUSH ADD MUL MOV NOP
Time
Target Code Page Stack Page Data Page
4 Steps 3 Steps
27 Page A Page B Page C Page D
Traditional Page-table Attacks
28 Page A Page B Page C Page D
Traditional Page-table Attacks
Page A Page B Page C Page D
CopyCat Attack Additional Data
4 8 6 4
29 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
test %eax, %eax je label mov %edx, %esi label: call add mov %eax, -0xc(%rbp)
Compile
Stack S Code P1 Code P2 Stack S Code P1 Code P2
30 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
31 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
test %eax, %eax je label mov %edx, %esi label: call add mov %eax, -0xc(%rbp)
Compile
Stack S Code P1 Code P2 Stack S Code P1 Code P2
32 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
test %eax, %eax je label mov %edx, %esi label: call add mov %eax, -0xc(%rbp)
Compile
Stack S Code P1 Code P2 Stack S Code P1 Code P2
33 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
test %eax, %eax je label mov %edx, %esi label: call add mov %eax, -0xc(%rbp)
Compile
Stack S Code P1 Code P2 Stack S Code P1 Code P2
Data Code Data Code Data Code
34 if(c == 0) { r = add(r, d); } else { r = add(r, s); }
C Code
test %eax, %eax je label mov %edx, %esi label: call add mov %eax, -0xc(%rbp)
Compile
Stack S Code P1 Code P2 Stack S Code P1 Code P2
switch (c){ case 0: r = 0xbeef; break; case 1: r = 0xcafe; break; default: r = 0; }
C Code
35
36
37
38
39
40
−1 ℎ − 𝑠
41
−1 ℎ − 𝑠
42
−1 ℎ − 𝑠
43 p = . . . X q = . . . X p = . . . 0 q = . . . 0 p = . . . 0 q = . . . 1 p = . . . 1 q = . . . 0 p = . . . 1 q = . . . 1
−1 ℎ − 𝑠
44 p = . . . X q = . . . X p = . . X 0 q = . . X 0 p = . . . 0 q = . . . 1 p = . . . 1 q = . . . 0 p = . . X 1 q = . . X 1 N = 1 1 1 0
−1 ℎ − 𝑠
45 p = . . . X q = . . . X p = . . X 0 q = . . X 0 p = . . . 0 q = . . . 1 p = . . . 1 q = . . . 0 p = . . X 1 q = . . X 1 N = 1 1 1 0 p = . . 0 0 q = . . 1 0 p = . . 1 0 q = . . 0 0 p = . . 0 0 q = . . 1 0 p = . . 1 1 q = . . 0 1
−1 ℎ − 𝑠
46 N = 1 1 1 0
p = . . . X q = . . . X p = . . X 0 q = . . X 0 p = . . X 1 q = . . X 1 p = . X 0 0 q = . X 1 0 p = . X 1 0 q = . X 0 0 p = . X 0 0 q = . X 1 0 p = . X 1 1 q = . X 0 1 p = . 0 1 1 q = . 1 0 1 p = . 1 1 1 q = . 0 0 1 p = . 0 0 0 q = . 1 1 0 p = . 1 0 0 q = . 0 1 0 p = . 0 1 0 q = . 1 0 0 p = . 1 1 0 q = . 0 0 0 p = . 0 0 0 q = . 1 1 0 p = . 1 0 0 q = . 0 1 0
−1 ℎ − 𝑠
47 N = 1 1 1 0
p = . . . X q = . . . X p = . . X 0 q = . . X 0 p = . . X 1 q = . . X 1 p = . X 0 0 q = . X 1 0 p = . X 1 0 q = . X 0 0 p = . 0 1 0 q = . 1 0 0 p = . 1 1 0 q = . 0 0 0
−1 ℎ − 𝑠
𝑞−1 𝑟−1 2𝑗
48
49
50
51
52
[11] Bernstein, Daniel J., and Bo-Yin Yang. "Fast constant-time gcd computation and modular inversion." CHES 2019.
53
54
55
56
57
58
59 https://en.wikichip.org/wiki/macro-operation_fusion
60
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Deterministic – Ctrl Channel
µarch Side Channel
This work
61
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Deterministic – Ctrl Channel
µarch Side Channel
This work
62
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Deterministic – Ctrl Channel
µarch Side Channel
This work
63
SGX Attacks Intel’s Responsibility Software Dev Responsibility
Deterministic – Ctrl Channel
µarch Side Channel
This work
64
65
66
67 https://github.com/j