Virtual Ghost: Protecting Applications from Hostile...

43
Virtual Ghost: Protecting Applications from Hostile Operating Systems John Criswell, Nathan Dautenhahn, and Vikram Adve 1

Transcript of Virtual Ghost: Protecting Applications from Hostile...

Page 1: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Virtual Ghost: Protecting Applications from Hostile Operating Systems

John Criswell, Nathan Dautenhahn, and Vikram Adve

1

Page 2: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

New Job

Page 3: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

New Job

Page 4: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Page 5: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Online Shopping!

Page 6: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Online Shopping!

Filing Taxes!

Page 7: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Online Shopping!

Filing Taxes!

Medical Data!

Page 8: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Voting Machines!

Online Shopping!

Filing Taxes!

Medical Data!

Page 9: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Do You Trust Your Operating System?

3

Voting Machines!

Online Shopping!

National Security!

Filing Taxes!

Medical Data!

Page 10: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Commodity Operating Systems Are Vulnerable!

Vulnerability Examples

Buffer Overflows BugTraq ID 12911, 13589, 13207, 13225, 12295

Integer Overflows BugTraq ID 10179, 63707

Information Leaks BugTraq ID 8831, 64677, 64746, 64742, 62405

Kernel-level Malware Adore rootkit

4

Page 11: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

If the operating system kernel is exploited, all security guarantees are null and void.

5

Page 12: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Virtual Ghost Contributions

• Protects application data confidentiality and integrity• Uses compiler techniques thanks to LLVM• Same privilege level as kernel• Faster than hypervisor-based approaches

6

Page 13: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Outline

• Motivation

• Design

• Results

• Future Work

7

Page 14: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Goal: Application That Protects Itself from OS

Required Features1. Private data and code2. Incorruptible control flow3. Reliable encryption key delivery

Private CodePrivate DataPublic Data

Operating System

8

Private Key

Page 15: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Challenges

9

Page 16: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Challenges

1. Processor lets privileged software access all memory

9

Page 17: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Challenges

1. Processor lets privileged software access all memory

2. Operating System must manipulate application state

• Process and thread creation

• Executing new programs (exec() family of system calls)

• Signal handler dispatch

9

Page 18: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Applications

• OS compiled to virtual instruction set

• Designed to be easy to analyze and instrument

• Low-level instructions (SVA-OS) replace assembly code

• Translate ahead-of-time, boot-time, or run-time

Virtual Ghost

10

ProcessorOS Kernel

Page 19: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Applications

Virtual Ghost VM

• OS compiled to virtual instruction set

• Designed to be easy to analyze and instrument

• Low-level instructions (SVA-OS) replace assembly code

• Translate ahead-of-time, boot-time, or run-time

Virtual Ghost

10

Processor

OS Kernel

Native Instruction Set

Virtual Instruction Set

Page 20: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Virtual Instruction Set

• SVA-Core: Compiler Instrumentation• Based on LLVM IR: Typed, Explicit SSA form• Sophisticated compiler analysis and instrumentation

• SVA-OS: Virtual Ghost Runtime• OS-neutral instructions to support a commodity OS• Encapsulates & controls hardware and state manipulation• Implemented as a run-time library linked into kernel

Virtual GhostCompiler Instrumentation VG Runtime

11

Page 21: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Ghost Memory

Virtual Ghost VM MemoryUser-Space Memory

Private Data and Code Ghost Memory

Kernel Memory

12

Page 22: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Ghost Memory

Virtual Ghost VM MemoryKernel cannot access

User-Space Memory

Private Data and Code Ghost Memory

Kernel Memory

12

Page 23: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Ghost Memory Instrumentation

• Software Fault Isolation

• Protects Ghost and VM Memory

• Avoids TLB flush

• Control-Flow Integrity

• Prevents instrumentation bypass

• Provides kernel protection

Virtual Ghost VM Memory

User-Space Memory

Ghost Memory

Kernel Memory

13

Page 24: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Software Fault Isolation Instrumentation

Ghost Memory

0xffffff0000000000 – 0xffffff8000000000

mask = (((p >> 32) == 0xffffff00 ? 0x8000000000 : 0);

p |= mask;

store v, *p;

Page 25: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Control-Flow Integrity Instrumentation1

• Insert NOP labels at target addresses• Function entry• Call sites

• Instrument all computed jumps• Bitmask to force pointer into

kernel code• Check label at target of

computed jump

1. Zeng, Tan, and Morrisett, Combining Control-flow Integrity and Static Analysis for Efficient and Validated Data Sandboxing, CCS 2011

pushq %raxadd %rax, %raxsub $1, %rbx

call fooNOP Label

popq

foo: NOP Label

Page 26: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Secure Application Control Flow

• Program state in VM Memory

• OS cannot modify directly

• SVA-OS vets/performs changes

• Signal handler dispatch

• Thread creation

• Exec() system callsVirtual Ghost

Saved Program State

Kernel

SVA-OS

16

Page 27: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Application Key Pair

Secure Application Encryption Keys

Application Code

Virtual Ghost

Executable Process

17

Code Segment

Memory

Page 28: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Kernel-Inserted Key Pair

Kernel Injects Wrong Key

Application Code

Virtual Ghost

Executable Process

18

Code SegmentGhost Memory

Page 29: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Application Key Pair

Kernel Replaces Code

Kernel-Inserted Code

Virtual Ghost

Executable Process

19

Code SegmentGhost Memory

Page 30: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Application Key PairEVG(Application Key Pair)

Secure Application Encryption Keys

EVG(Application Code)

EVG(Hash of Executable)

Virtual Ghost

Executable Process

20

Code SegmentGhost Memory

Page 31: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Application Key PairEVG(Application Key Pair)

Secure Application Encryption Keys

EVG(Application Code)

EVG(Hash of Executable)

Virtual Ghost

Executable Process

20

Code SegmentGhost Memory

Application Key Pair

Page 32: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Outline

• Introduction

• Design

• Results

• Future Work

21

Page 33: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Implementation

• Developed a x86_64 64-bit implementation of Virtual Ghost

• Ported FreeBSD 9.0 to Virtual Ghost

• FreeBSD compiles with LLVM out of the box

• Modified OpenSSH applications to use ghosting

• ssh client

• ssh-agent key-chain server

• ssh-add utility22

Page 34: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Kernel Malware Attack

Trick Application into Putting Data into the Clear

• Install signal handler to malicious code in application

• Malicious code copies data to traditional memory

Kernel

Malware Driver

ssh-agent Traditional Memory

ssh-agent Ghost Memory

23

memcpy (g, t); write(fd, t, 10);

Malicious Data Flow

Page 35: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Kernel Malware Attack

Trick Application into Putting Data into the Clear

• Install signal handler to malicious code in application

• Malicious code copies data to traditional memory

Kernel

Malware Driver

ssh-agent Traditional Memory

ssh-agent Ghost Memory

23

memcpy (g, t); write(fd, t, 10);

Malicious Data Flow X

Page 36: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

LMBench Execution Time Normalized to Native

[1] InkTag: Secure Applications on an Untrusted Operating System, ASPLOS 2013

Nor

mal

ized

Exec

utio

n to

N

ativ

e

02.5

57.510

12.515

lmbench Benchmark

null

open

/clos

emmap

page f

ault

fork

fork/e

xec

4.24.41.15

4.74.833.9 3.045.74

7.59.94

7.95

55.8InkTag[1] Virtual Ghost

24

Page 37: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Web Server Performance for thttpd

• ApacheBench: 100 clients, 100,00 requests• Performance overhead negligible

KB/s

1

10

100

1,000

10,000

100,000

File Size (KB)

1 2 4 8 16 32 64 128 256 512 1024

Native FreeBSD Virtual Ghost

25

Page 38: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Unmodified SSH Server Performance

• 23% reduction of bandwidth on average• 45% reduction in worst case

Band

wid

th (K

B/s)

0

22500

45000

67500

90000

File Size (KB)

1 4 16 64 256

1024

4096

1638

465

536

2621

44

1048

576

Native FreeBSD Virtual Ghost

26

Page 39: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Ghosting SSH Client Performance

• 5% reduction in worst case

Band

wid

th (K

B/s)

0

15000

30000

45000

60000

File Size (KB)

1 4 16 64 256

1024

4096

1638

465

536

2621

44

1048

576

Original ssh Ghosting ssh

27

Page 40: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Outline

• Introduction

• Design

• Results

• Future Work

28

Page 41: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Future Work

• Improved performance

• Advanced optimization (e.g., type safe check optimization)

• Cryptographic protocols for preventing OS attacks

• Prevent replay attacks

• Compiler transforms to use Virtual Ghost features

29

Page 42: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Started Open-Source Release

• LLVM Compiler Extensions

• Virtual Ghost Run-time Library

Page 43: Virtual Ghost: Protecting Applications from Hostile ...llvm.org/devmtg/2014-10/Slides/Criswell-VirtualGhost.pdf · Virtual Ghost: Protecting Applications from Hostile Operating Systems

Summary

• Virtual Ghost allows applications to protect themselves from an OS

• Uses compiler instrumentation

• Keeps higher processor privilege levels free

• Faster than hypervisor-based approaches

See what we do at http://sva.cs.illinois.edu!

31