Securing Software Systems by Preventing Information Leaks Kangjie - - PowerPoint PPT Presentation

securing software systems by preventing information leaks
SMART_READER_LITE
LIVE PREVIEW

Securing Software Systems by Preventing Information Leaks Kangjie - - PowerPoint PPT Presentation

Securing Software Systems by Preventing Information Leaks Kangjie Lu Georgia Institute of Technology Computer devices are everywhere 2 Foundational software systems 3 Inherent insecurity: Vulnerabilities and insecure designs Implemented in


slide-1
SLIDE 1

Securing Software Systems by Preventing Information Leaks

Kangjie Lu Georgia Institute of Technology

slide-2
SLIDE 2

Computer devices are everywhere

2

slide-3
SLIDE 3

Foundational software systems

3

slide-4
SLIDE 4

Inherent insecurity: Vulnerabilities and insecure designs

Implemented in unsafe languages (e.g., C/C++)

– Increasing vulnerabilities

4

System designers prioritize performance over security

– Many insecure designs

Data source: U.S. National Vulnerability Database

50 100 150 200 250 300 350 400

Number of reported vulnerabilities in Linux

slide-5
SLIDE 5

Critical system attacks exploiting vulnerabilities and insecure designs

System attacks are evolving: More and more advanced, harder and harder to defend against

5

slide-6
SLIDE 6

Two typical goals of system attacks

To control victim systems To leak sensitive data

6

Control attacks Data leaks

slide-7
SLIDE 7

Defeating both data leaks and control attacks by preventing information leaks

7

slide-8
SLIDE 8

Malicious code pieces

A fundamental requirement of control attacks

Attackers have to replace a code pointer with a malicious one to gain control

Code pointer

Memory

Overwriting control data

Malicious pointer

Memory

8

slide-9
SLIDE 9

Malicious code pieces

A fundamental requirement of control attacks

Attackers have to replace a code pointer with a malicious one to gain control

Code pointer

Memory

Overwriting control data Have to know the addresses of both a code pointer and malicious code

Malicious pointer

Memory

Address of a code pointer Address of malicious code

9

slide-10
SLIDE 10

A widely deployed defense---ASLR

ASLR: Address Space Layout Randomization

– Preventing attackers from knowing addresses

Code/data Memory Code/data Memory Code/data Memory 1st run 2nd run 3rd run n run

240

possibilities

10

slide-11
SLIDE 11

In principle, ASLR is “perfect”

Randomized addresses

Memory ASLR is efficient, easy to deploy, and effective as long as there is no information leak

11

slide-12
SLIDE 12

In practice, ASLR is weak

500 1000 1500 2000 2500 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016

Number of reported information-leak vulnerabilities

Control attacks still work because of information leaks

12

Data source: U.S. National Vulnerability Database

slide-13
SLIDE 13

ASLR re-defines the prevention problem in modern systems

Preventing address leaks can defeat control attacks

13

Control attack prevention problem Address leak prevention problem ASLR

slide-14
SLIDE 14

Information leak is inevitable for both attacks

Exploiting information leaks Bypassing ASLR Data leaks Control attacks

14

slide-15
SLIDE 15

Research goal: Preventing information leaks

Exploiting information leaks Bypassing ASLR Data leaks Control attacks

15

slide-16
SLIDE 16

Root causes of known information leaks

16

Root causes Vulnerabilities Memory error Uninitialized read Logic error Missing check Hardware error Row hammer Design flaws Specification issue Uninitialized padding Organization issue Refork-on-crash Mechanism issue Deduplication + COW Side channels AnC on MMU

Type Example Category

slide-17
SLIDE 17

Three ways to prevent information leaks

17

Eliminating information-leak vulnerabilities

  • UniSan: Eliminating uninitialized data leaks [CCS’16]
  • PointSan: Eliminating uninitialized pointers [NDSS’17]

Securing system designs against information leaks

  • Runtime re-randomization for process forking

[NDSS'16] Protecting sensitive data from information leaks

  • ASLR-Guard: Preventing code pointer leaks [CCS’15]
  • Buddy: Detecting memory disclosures for COTS
slide-18
SLIDE 18

Motivation of UniSan

OS kernels are the trusted computing base

– Contain sensitive data like crypto keys – Deploy security mechanisms like ASLR

Hundreds of information-leak vulnerabilities

– Data leaks – ASLR bypass

18

slide-19
SLIDE 19

UniSan: To eliminate (the most common) information-leak vulnerabilities in OS kernels

à Mitigate data leaks, code-reuse and privilege-escalation attacks

19

slide-20
SLIDE 20

Main contributions of UniSan

  • Automatically secure the Linux and Android

kernels with negligible runtime overhead

  • Reported and patched 19 kernel vulnerabilities

– CVE-2016-5243, CVE-2016-5244, CVE- 2016-4569, CVE-2016-4578, CVE-2016-4569, CVE-2016-4485, CVE-2016-4486, CVE-2016-4482, ……

  • Found and fixed a critical security problem in

compilers

  • Porting UniSan to GCC for adoption

20

slide-21
SLIDE 21

The main cause of information leaks: Uninitialized data read

Data source: U.S. National Vulnerability Database (kernel information leaks reported between 2013 and 2016)

21

57% 29% 14%

Uninitialized data read Out-of-bound read & use- after-free Logic error (e.g., missing check)

UniSan

slide-22
SLIDE 22

How an uninitialized data read leads to an information leak

sensitive

User A allocates

  • bject A and

writes “sensitive” into it

Kernel space

Object A

User A deallocates

  • bject A;

“sensitive” is not cleared User B allocates

  • bject B without

Initialization; “sensitive” kept User B reads Object B; “sensitive” leaked! 1 2 3 4

sensitive sensitive Object B Object B sensitive

22

We call such information leaks “uninitialized data leaks”

User space Kernel space Kernel space

slide-23
SLIDE 23

Troublemaker: Developer

Missing field initialization: Blame the developers? Difficult to avoid

–Too complex

23

Data struct definition Object use/init

< / >

inconsistency

slide-24
SLIDE 24

Troublemaker: Compiler

Data structure padding: A fundamental feature for improving CPU efficiency

/* both fields (5 bytes) are initialized*/ struct test t = { .a = 0, .b = 0 /* 3 uninitialized padding bytes */ }; /* leaking uninitialized 3-byte padding*/ copy_to_user(dest, &t, sizeof(t)); struct test { unsigned int a; unsigned char b; /* 3-bytes padding */ };

24

A critical and prevalent security problem: Programs are built by compilers!

slide-25
SLIDE 25

The root cause: C specifications (C11) Chapter §6.2.6.1/6 “When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values.”

25

slide-26
SLIDE 26

UniSan: A compiler-based solution

Simply initialize all allocated objects? Too expensive!

26

Detecting unsafe allocations Initializing unsafe allocations

LLVM IR

The UniSan Approach

Hardened LLVM IR Kernel source code Secured kernel image

slide-27
SLIDE 27

Unsafe allocation detection

Byte-level and flow-, context-, and field-sensitive taint tracking Sources (i.e., allocations)

Sinks (e.g., copy_to_user)

Data flow

Initialization analysis

27

Reachability analysis

slide-28
SLIDE 28

Technical challenges in detection

  • Global call-graph construction

–Conservative type analysis for indirect calls

  • Byte-level tracking

–Maintaining offsets of fields

  • Eliminating false negatives

Be conservative! Assume it is unsafe for unhandled special cases!

28

slide-29
SLIDE 29

Zero-initializing all unsafe allocations

Zero initialization is semantic preserving

–Robust –Tolerant of false positives

29

Stack Heap

  • bj = 0

kmalloc(size, flags|__GFP_ZERO) memset(obj, 0, sizeof(obj))

slide-30
SLIDE 30

LLVM-based implementation

An analysis pass + an instrumentation pass How to use UniSan:

$ unisan @bitcode.list

30

slide-31
SLIDE 31

UniSan is performant and effective

31

Accuracy Performant Effective

UniSan

10% (2K) of allocations are detected as unsafe Negligible runtime overhead:

  • System operations: 1.36%
  • Web servers: <0.1%
  • User programs: 0.54%

Prevented known and new vulnerabilities

  • 19 have been confirmed and fixed by Google

and Linux

Applied to the latest Linux kernel and Android kernel

slide-32
SLIDE 32

Three ways to prevent information leaks

32

Eliminating information-leak vulnerabilities

  • UniSan: Eliminating uninitialized data leaks [CCS’16]
  • PointSan: Eliminating uninitialized pointers [NDSS’17]

Securing system designs against information leaks

  • Runtime re-randomization for process forking

[NDSS'16] Protecting sensitive data from information leaks

  • ASLR-Guard: Preventing code pointer leaks [CCS’15]
  • Buddy: Detecting memory disclosures for COTS
slide-33
SLIDE 33

Three ways to prevent information leaks

33

Eliminating information-leak vulnerabilities

  • UniSan: Eliminating uninitialized data leaks [CCS’16]
  • PointSan: Eliminating uninitialized pointers [NDSS’17]

Securing system designs against information leaks

  • Runtime re-randomization for process forking

[NDSS'16] Protecting sensitive data from information leaks

  • ASLR-Guard: Preventing code pointer leaks [CCS’15]
  • Buddy: Detecting memory disclosures for COTS
slide-34
SLIDE 34

The insecure process forking violates ASLR

A common design of web servers:

34

Code/data Code/data Code/data Code/data

fork() fork() fork()

HTTP(S) HTTP(S) HTTP(S)

Exactly same memory layout. Re-fork upon worker crashes

Master Worker Worker Worker

slide-35
SLIDE 35

The clone-probing attack

Attack goal: To guess sensitive data (say randomized return address) with a simple buffer overflow

35

… return address 12 34 56 78 9a bc ed f0

AAAAAAA

00 34 56 78 9a bc ed f0

AAAAAAA

01 34 56 78 9a bc ed f0

AAAAAAA

12 34 56 78 9a bc ed f0

Stack of a web server

Attack payload Crash, try another one Crash, try another one Bingo, continue to guess next byte …

… AAAAAAA

12 34 56 78 9a bc ed f0 …

… … AAAAAAA

12 34 56 78 9a bc ed f0 Finally, get all bytes

Brute-forcing complexity is reduced from 264 to 8*28 Usually can be done within two minutes.

Buffer

  • verflow
slide-36
SLIDE 36

Re-randomizing the memory layout of forked processes

Main contributions

– A new mechanism for automatic pointer tracking at runtime (using Intel’s Pin) – Successfully applied it to Nginx web server

36

Automatic pointer tracking Memory layout re-randomization Dangling pointer patching

slide-37
SLIDE 37

Three ways to prevent information leaks

37

Eliminating information-leak vulnerabilities

  • UniSan: Eliminating uninitialized data leaks [CCS’16]
  • PointSan: Eliminating uninitialized pointers [NDSS’17]

Securing system designs against information leaks

  • Runtime re-randomization for process forking

[NDSS'16] Protecting sensitive data from information leaks

  • ASLR-Guard: Preventing code pointer leaks [CCS’15]
  • Buddy: Detecting memory disclosures for COTS
slide-38
SLIDE 38

Motivation of ASLR-Guard

Code-reuse attacks are rampant and critical Leaking a code pointer to first bypass ASLR has become a prerequisite for code-reuse attacks

38

slide-39
SLIDE 39

ASLR-Guard: To prevent code-pointer leaks to defeat code-reuse attacks (a user-space security mechanism against remote attackers)

39

slide-40
SLIDE 40

Two main contributions

A systematic way of discovering code pointers Two techniques of preventing code pointer leaks

40

slide-41
SLIDE 41

Empirical code pointer discovery

41

By relocation By program counter (%RIP) By OS

How are code pointers created?

Lesson: Code pointer discovery is practical; programs built by modern compilers create code pointers regularly

slide-42
SLIDE 42

Isolating or encoding code pointers

Isolation Encoding

42

Return address Other code pointers

  • Function pointer
  • Entry pointer
  • Signal handler
slide-43
SLIDE 43

Isolating or encoding code pointers

Isolation Encoding

43

Return address Other code pointers

  • Function pointer
  • Entry pointer
  • Signal handler
slide-44
SLIDE 44

Encoding code pointers

When isolation is hard Three requirements for encoding

– Confidentiality: Cannot crack – Integrity: Cannot modify – Efficiency: Be performant

44

slide-45
SLIDE 45

Fast code pointer encoding

void hello(); void (*fn)() = hello; Assembly: lea 0x1234(%rip), %rax

45

slide-46
SLIDE 46

Fast code pointer encoding

Random Mapping Table (in safe region)

%gs

Mapping entries… void hello(); void (*fn)() = hello; Assembly: lea 0x1234(%rip), %rax

46

slide-47
SLIDE 47

New entry

Fast code pointer encoding

Random Mapping Table (in safe region)

%gs

void hello(); void (*fn)() = hello; Assembly: lea 0x1234(%rip), %rax

16-bytes Random

  • ffset

Step1: create an entry with a random offset

47

slide-48
SLIDE 48

Fast code pointer encoding

Random Mapping Table (in safe region)

%gs

void hello(); void (*fn)() = hello; Assembly: lea 0x1234(%rip), %rax

8-byte Random

  • ffset

Step1: create an entry with a random offset Step2: save fn in first 8-byte, then 4-byte 0 and 4-byte nonce

fn Nonce

4-byte 4-byte

48

slide-49
SLIDE 49

Fast code pointer encoding

Random Mapping Table (in safe region)

%gs

void hello(); void (*fn)() = hello; Assembly: lea 0x1234(%rip), %rax

8-byte Random

  • ffset

Step1: create an entry with a random offset Step2: save fn in first 8-byte, then 4-byte 0 and 4-byte nonce

fn Nonce

4-byte 4-byte

  • Rand. offset

Nonce

%rax Step3: save the 4-byte random offset and nonce into %rax

49

slide-50
SLIDE 50

Extremely fast decoding

Source: Assembly: fn(); call *%rax; xor %gs:8(%rax), %rax; call %gs:(%rax)

Compile time:

50

slide-51
SLIDE 51

Extremely fast decoding

Source: Assembly: fn(); call *%rax; random offset

(little-endian)

Runtime:

xor %gs:8(%rax), %rax; call %gs:(%rax)

Compile time:

Nonce

  • Rand. offset

Nonce

51

(Saved in %rax)

slide-52
SLIDE 52

Extremely fast decoding

Source: Assembly: fn(); call *%rax; random offset

(little-endian)

Runtime:

xor %gs:8(%rax), %rax; call %gs:(%rax)

Compile time:

Nonce

  • Rand. offset

Nonce

%gs:(%rax) points to ”fn” in random mapping table, so, call %gs:(%rax) à call fn

52

(Saved in %rax)

slide-53
SLIDE 53

Extremely fast decoding

Extremely efficient decoding: Only

  • ne XOR operation!

53

slide-54
SLIDE 54

ASLR-Guard: A toolchain and a runtime

54

Compiler (gcc, g++) Assembler (gas) Source code Secured execution Linker (ld) Dynamic

linker (ld.so)

Secured libs

GNU toolchain

(~3,000 LoC changes)

C/C++ Runtime

ELF

slide-55
SLIDE 55

ASLR-Guard is performant and effective

55

Performant Effective

ASLR-Guard

Negligible performance overhead:

  • Runtime overhead: <1%
  • Binary size increase: 6%
  • Memory overhead: 2MB

Attacks such as BlindROP are defeated! Applied to the SPEC Benchmarks and the Nginx web server

slide-56
SLIDE 56

Three ways to prevent information leaks

56

Eliminating information-leak vulnerabilities

  • UniSan: Eliminating uninitialized data leaks [CCS’16]
  • PointSan: Eliminating uninitialized pointers [NDSS’17]

Securing system designs against information leaks

  • Runtime re-randomization for process forking

[NDSS'16] Protecting sensitive data from information leaks

  • ASLR-Guard: Preventing code pointer leaks [CCS’15]
  • Buddy: Detecting memory disclosures for COTS
slide-57
SLIDE 57

Motivation of Buddy

  • Memory disclosures are critical

– Data leaks – Defense mechanism bypass

  • Memory disclosures are common

– Thousands of vulnerabilities each year, still increasing

  • Memory disclosures are diverse

– Various causes – Various memory data types

  • Memory disclosure prevention is expensive

– Much more expensive than preventing invalid write

57

How to stop memory disclosures in a general and practical manner?

slide-58
SLIDE 58

Buddy: An replicated execution-based approach

Seamlessly maintain two identical processes with diversified data/layout (same semantics)

58

Code/data Code’/data’

Compare outputs: disclosures will cause divergences

slide-59
SLIDE 59

A formal model for Buddy

59

  • Detecting points such as I/O write

– 0, 1,…i

  • States at detecting point i

– Original process: So,i, – Buddy instances: <Si, Si’>

  • Mapping buddy states to original state

– Mapping function: Map(Si) = Map(Si’) = So,i

  • Transition functions for all processes

– Take a state Si and an input I, and produce next state – T(Si, I) = Si+1; same for T’() and To()

slide-60
SLIDE 60

Two properties of Buddy

60

Equivalence property

– Buddy must preserve semantics for original process under normal execution

Divergence property

– Buddy must detect divergences when memory disclosures occur

(1). Map(S0) = Map(S0ʹ) = So,0 (2). ∀ 0 ≤ i ≤ N, ∀ I ∈ Normal inputs: Map(T(Si , I)) = Map(Tʹ (Siʹ , I)) = To (So,i , I) (3). ∀ 0 ≤ i ≤ N, ∀ I ∈ Inputs: T(Si , I)) or Tʹ(Siʹ , I)) ∈ Memory disclosures ⇒ Map(Si+1) ≠ Map(Si+1)

slide-61
SLIDE 61

Assumptions of Buddy

  • Memory disclosures go through pre-defined

detecting points

  • Programs do not intentionally use unspecified

memory

  • We have the list of non-determinism sources
  • We have a multi-core CPU

61

slide-62
SLIDE 62

Detecting memory disclosures with Buddy

A general replicated execution framework Two new schemes built upon Buddy

62

Spatial

Absolute addr- based read

Relative addr- based read

Partitioned ASLR Random padding

Temporal Use-after-free Uninitialized read

Diehard[16] Diehard[16]

slide-63
SLIDE 63

Data

Partitioned ASLR

  • Detect absolute address-based over-reads
  • Partition address space into two sub-spaces
  • Enable randomization for each sub-space

– Apply PIC and modify loader (ld.so)

63

Code

Instance1

Data Code

Instance2

Addr.1 Addr.2

slide-64
SLIDE 64

Properties of partitioned ASLR

Equivalence property – Yes

– PIC and ASLR are non-interference – No change to semantics

Divergence property – Yes

– Sub-spaces are non-overlapping: Addr1 ≠ Addr2 – Any absolute addr-based over-read will always result in one instance crashing

64

slide-65
SLIDE 65

8-byte rand. pad Local variables 8-byte rand. pad

Random padding

Detect relative address-based over-reads Paddings have different values and sizes

65

Return addr.

Instance1 Instance2

Over read

24-byte space Local variables 8-byte rand. pad’ Return addr. 8-byte space Heap object 24-byte space 8-byte rand. pad’ Heap object 8-byte space

Over read

Instance1 Instance2 Padding for stack frames Padding for heap objects

slide-66
SLIDE 66

Properties of random padding

Equivalence property – Yes

– Rearrange memory layout of object – No change to semantics (assuming semantics do not depend on object memory layout)

Divergence property

– Continuous reads – Yes

  • Paddings have different values

– Offset-based reads

  • If target data is random – (2^N-1)/2^N, where N = read bits
  • If target data has a layout pattern, e.g., repeating –

Probabilistic

66

slide-67
SLIDE 67

Efficient coordination of Buddy instances

Virtualizing points and interception

– Most system calls -- syscall table patching – All virtual system calls -- GOTPLT table patching – RDTSC and RDRAND instructions -- Binary rewriting

Ring buffer-based coordination

67

Leader Follower

Shared memory Save results Fetch results

slide-68
SLIDE 68

Single-point synchronization and detection

Detecting at only socket write and file write Crashing is directly treated as a divergence

68

Leader Follower

Strict synchronizing & deep comparing I/O write I/O write

Outgoing data Outgoing data’

=?

Divergence è Disclosure

slide-69
SLIDE 69

Extensive evaluation

  • Testing programs

– SPEC bench programs, Apache server, Nginx server, Lighttpd, PHP, and OpenSSL

  • Experimental setup

– Eight-core machine with 64-bit Linux

  • Evaluation scope

– Robustness – Security – Performance

69

slide-70
SLIDE 70

Evaluation of robustness and security

  • Robustness: Extensive empirical testing

– No error/crash observed – Outputs with and without Buddy are the same – One false positive---use of uninitialized memory

  • Security: Real attacks detected

– Data-oriented exploits[82] – BlindROP[20] – Loop timing-based leaks[156] (absolute-addr-based read) – Heartbleed attack[61]

70

slide-71
SLIDE 71

Evaluation of performance

  • SPEC Benchmarks

– Light-load CPU: 2.34% – Heavy-load (99% usage) CPU: 8.3%

  • Web Benchmarks

– Concurrency 1-256, Worker 1-8

  • 0%-10.8% with geo-mean 3.6%

– File size 1KB-16MB (with c=16 and p=4)

  • 1.4%-8.7% with geo-mean 4.6%
  • Partitioned ASLR: non-measurable
  • Random padding: additional 2.8%

71

slide-72
SLIDE 72

Thesis contributions

  • New, general defense concept

– Securing systems by preventing information leaks

  • Study of information leaks

– Providing insights into their causes and prevention

  • Discovery of new threats

– Compilers make mistakes! Uninitialized pointers can be reliably exploited

  • General ways to prevent information leaks

– Three ways to fix root causes and protect certain data

  • Novel defense mechanisms

– Automated and practical design, open sourced implementation

72

slide-73
SLIDE 73

Future work

  • Uncovering and fixing classes of logic errors

and design flaws

– No uniform pattern for logic errors or design flaws – Empirical analysis and fuzzing – Patch history

  • Detecting probing (side-channel) attacks

– Conservative detection + effective defense – Transparent detection with hardware features

73

slide-74
SLIDE 74

Conclusions

  • Vulnerabilities and insecure designs are common in

widely used systems; compilers make mistakes

  • This thesis aims to secure widely used systems in an

automated and practical manner

  • Preventing information leaks can be a general and

practical solution to defeating both data leaks and control attacks

74