March 19, 2013
IAGO ATTACKS: WHY THE SYSTEM CALL API IS A BAD UNTRUSTED RPC INTERFACE
Stephen Checkoway and Hovav Shacham
1
1 Monday, April 22, 13
A vulnerable program #include <stdlib.h> int main() { void - - PowerPoint PPT Presentation
I AGO A TTACKS : W HY THE S YSTEM C ALL API IS A B AD U NTRUSTED RPC I NTERFACE Stephen Checkoway and Hovav Shacham March 19, 2013 1 Monday, April 22, 13 1 A vulnerable program #include <stdlib.h> int main() { void *p = malloc(100);
March 19, 2013
1
1 Monday, April 22, 13
#include <stdlib.h> int main() { void *p = malloc(100); }
2
2 Monday, April 22, 13
✤ Trusted application: ✤ Untrusted operating system:
3
3 Monday, April 22, 13
4
4 Monday, April 22, 13
4
4 Monday, April 22, 13
4
4 Monday, April 22, 13
4
4 Monday, April 22, 13
✤ Reimplement in a secure environment (e.g., µkernel) ✤ Hardware-based solutions (e.g., XOM processor) ✤ Multiple virtual machines (e.g., Proxos) ✤ Hypervisor-assisted (e.g., Overshadow)
5
5 Monday, April 22, 13
✤ Reimplement in a secure environment (e.g., µkernel) ✤ Hardware-based solutions (e.g., XOM processor) ✤ Multiple virtual machines (e.g., Proxos) ✤ Hypervisor-assisted (e.g., Overshadow)
6
6 Monday, April 22, 13
7
Application Operating system
Chen et al. Overshadow: A Virtualization-Based Approach to Retrofitting Protection in Commodity Operating Systems. ASPLOS’08
7 Monday, April 22, 13
7
Application Operating system Hypervisor Shim
Chen et al. Overshadow: A Virtualization-Based Approach to Retrofitting Protection in Commodity Operating Systems. ASPLOS’08
7 Monday, April 22, 13
7
Application Operating system Hypervisor Shim
Chen et al. Overshadow: A Virtualization-Based Approach to Retrofitting Protection in Commodity Operating Systems. ASPLOS’08
7 Monday, April 22, 13
8
8 Monday, April 22, 13
9
A majority of system calls can be passed through to the OS with no special handling. These include calls with scalar arguments that have no interesting side effects, such as getpid, nice, and sync. — Chen et al. ASPLOS’08
✤ Marshals arguments and return values for system calls ✤ Communicates directly with the hypervisor
9 Monday, April 22, 13
10
Main Apache process Entropy pool
10 Monday, April 22, 13
10
Main Apache process Entropy pool Workers Workers’ entropy pools getpid() getpid()
10 Monday, April 22, 13
✤ Abstract away details of Overshadow ✤ Develop a malicious operating system kernel to attack protected
applications
✤ Cause the protected application to act against its interests
11
11 Monday, April 22, 13
✤ Trusted, legacy application ✤ Unmodified system libraries ✤ Kernel cannot read or modify application state ✤ Kernel responds to system calls normally except for return values
12
12 Monday, April 22, 13
13
asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count);
buf count
13 Monday, April 22, 13
14
asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count);
buf count
✤ Write arbitrary data, but only inside the supplied buffer ✤ Arbitrary return value
14 Monday, April 22, 13
✤ Malicious kernel (modified Linux) ✤ No reading/writing application memory ✤ Handle all “unsafe” system calls correctly ✤ Can handle “safe” system calls maliciously ✤ Unmodified user space
15
15 Monday, April 22, 13
16
#include <stdlib.h> int main() { void *p = malloc(100); }
16 Monday, April 22, 13
17
void *p; p = mmap(4096); read(0,p,4096);
17 Monday, April 22, 13
17
void *p; p = mmap(4096); read(0,p,4096);
mmap() p
17 Monday, April 22, 13
17
void *p; p = mmap(4096); read(0,p,4096);
mmap()
read() p p
17 Monday, April 22, 13
void *p; p = mmap(4096); read(0,p,4096);
18 Monday, April 22, 13
void *p; p = mmap(4096); read(0,p,4096); p
mmap()
18 Monday, April 22, 13
void *p; p = mmap(4096); read(0,p,4096); p p
mmap()
read()
18 Monday, April 22, 13
✤ fgetc() ✤ fgets() ✤ fread() ✤ fscanf() ✤ getc() ✤ getchar() ✤ getdelim() ✤ getline() ✤ gets() ✤ scanf() ✤ vfscanf() ✤ vscanf() ✤ …
19
mmap()
read()
19 Monday, April 22, 13
✤ fgetc() ✤ fgets() ✤ fread() ✤ fscanf() ✤ getc() ✤ getchar() ✤ getdelim() ✤ getline() ✤ gets() ✤ scanf() ✤ vfscanf() ✤ vscanf() ✤ …
20
mmap()
read()
20 Monday, April 22, 13
✤ Split into upper and lower halves ✤ Upper half: manages chunks, free lists, handles malloc() and
free()
✤ Lower half: requests memory from the OS ✤ Maintains a top region of unallocated memory from the OS ✤ Metadata (including size) inline
21
size+1 top
21 Monday, April 22, 13
First call to malloc(n) [creating the top chunk]:
(updates the start S of the heap)
22
22 Monday, April 22, 13
23
23 Monday, April 22, 13
24
S,E
❷
24 Monday, April 22, 13
25
S,E
❷
S E
❸
25 Monday, April 22, 13
26
S,E
❷
S E
❸
S E
?
❹
26 Monday, April 22, 13
27
S,E
❷
S E
❸
S E
?
❹
S E
❺
27 Monday, April 22, 13
28
S E
❸
S E
?
❹
S E
❺ ❻ ❷
S
nb
E
E - S - nb
28 Monday, April 22, 13
29
S E
❸
S E
?
❹
S E
❺ ❻ ❷ ❼
S
nb
E
E - S - nb
29 Monday, April 22, 13
30
S
nb
E
E - S - nb
30 Monday, April 22, 13
30
S
nb
E
E - S - nb
application code/data libc application stack E - S - nb + 1
30 Monday, April 22, 13
30
S
nb
E
E - S - nb
application code/data libc application stack E - S - nb + 1
gets()
30 Monday, April 22, 13
31
31 Monday, April 22, 13
✤ The system call interface is a bad RPC mechanism ✤ Malicious kernels can take control of protected applications ✤ Options:
32
32 Monday, April 22, 13
33
33 Monday, April 22, 13