High System-Code Security with Low Overhead Jonas Wagner, Volodymyr - - PowerPoint PPT Presentation

high system code security with low overhead
SMART_READER_LITE
LIVE PREVIEW

High System-Code Security with Low Overhead Jonas Wagner, Volodymyr - - PowerPoint PPT Presentation

High System-Code Security with Low Overhead Jonas Wagner, Volodymyr Kuznetsov, George Candea, and Johannes Kinder cole Polytechnique Fdrale Royal Holloway, de Lausanne University of London High System-Code Security? Todays so fu ware


slide-1
SLIDE 1

High System-Code Security with Low Overhead

Jonas Wagner, Volodymyr Kuznetsov, George Candea, and Johannes Kinder

École Polytechnique Fédérale de Lausanne Royal Holloway, University of London

slide-2
SLIDE 2

High System-Code Security?

Today’s sofuware is dangerous. Example: OpenSSL
 Overflow in ssl/t1_lib.c:3997 → OpenSSL contains 53,073 memory accesses.
 How to protect them all?

slide-3
SLIDE 3

Protect all dangerous operations using sanity checks ✓ Checks are automatically added at compile time ✓ No source code modification is needed

*p = 42; if (!isValidAddress(p)) { reportError(p); abort(); } *p = 42; AddressSanitizer

slide-4
SLIDE 4

Tool

  • Avg. Overhead

AddressSanitizer

(memory errors)

73% SoftBound/CETS

(full memory safety)

116% UndefinedBehaviorSanitizer

(integer overflows, type errors…)

71% Assertions, code contracts, … depends

Problem: Sanity checks cause high performance overhead

slide-5
SLIDE 5

Problem: Sanity checks cause high performance overhead

People use checks heavily for testing, but disable them in production

Goal: checks in production

slide-6
SLIDE 6

Insight: Checks are not all equal

Most of the overhead comes from a few expensive checks Most of the protection comes from many cheap checks Checks in hot code, each executed many times Checks in cold code

slide-7
SLIDE 7

Most of the overhead comes from a few expensive checks Most of the protection comes from many cheap checks

Our Approach

Lets users choose their overhead budget (e.g., 5%) Automatically identifies sanity checks in sofuware Analyzes the cost of every check Selects as many checks as fit in the user’s budget

: ASAP

As Safe As Possible

slide-8
SLIDE 8

ASAP Insight & Results

Sanity level

0% 20% 40% 60% 80% 100%

Overhead

0% 10% 20% 30% 40% 50% 60%

Fraction of critical operations protected by a check Most protection comes from cheap checks A few checks are very expensive A user on a 5% budget can get 87% of the protection

slide-9
SLIDE 9

Outline

Introduction: What is ASAP? Design Key Algorithms Results Conclusion

slide-10
SLIDE 10

Design

ASAP is built into the compiler

✓ Easy to use (set CC and CFLAGS) ✓ Compatible (parallel compilation, …) Compiler (LLVM)

Identify
 sanity checks Profiler:
 measure
 check costs Optimizer:
 select maximum set of checks

slide-11
SLIDE 11

Users use ASAP like a regular compiler that adds checks

.cc .h

ASAP

.exe .llvm

+ ASAP stores intermediate compiler output

slide-12
SLIDE 12

Users use ASAP like a regular compiler that adds checks

.cc .h

ASAP

.exe .llvm

+ ASAP generates a program variant with profiling instrumentation.

ASAP

.llvm

Profiler

.exe

Workload Costs Users run this to measure check costs.

slide-13
SLIDE 13

Users use ASAP like a regular compiler that adds checks

.cc .h

ASAP

.exe .llvm

+ ASAP generates a program variant with profiling instrumentation.

ASAP

.llvm

Profiler

.exe

Workload Costs Users run this to measure check costs. ASAP uses costs & budget to generate an optimized program

ASAP

.llvm

Optimizer

Costs

.exe

+ Budget +

slide-14
SLIDE 14

Outline

Introduction: What is ASAP? Design Key Algorithms Results Conclusion

slide-15
SLIDE 15

ASAP

.exe

Budget

slide-16
SLIDE 16

ASAP

.exe

Measure check cost Quantify protection

Budget

Identify check instructions (de)activate checks profiling workload compiler driver IDE integration

Can users trust ASAP to select checks that use the least CPU cycles? If ASAP says you’re 87% protected, what does this mean?

slide-17
SLIDE 17

...

Measure Check Cost

if (!isValidAddress(p)) { reportError(p); abort(); } *p = 42; ...

slide-18
SLIDE 18

...

Measure Check Cost

if (!isValidAddress(p)) { reportError(p); abort(); } *p = 42; ... prof1++; prof2++; prof3++;

  • 1. Add profiling counters
slide-19
SLIDE 19

... prof1++; if (!isValidAddress(p)) { prof2++; reportError(p); abort(); } prof3++; *p = 42; ...

  • 1. Add profiling counters
  • 2. Identify check instructions

Measure Check Cost

slide-20
SLIDE 20
  • 1. Add profiling counters
  • 2. Identify check instructions
  • 3. Use static model

  • f cycles per instruction

Measure Check Cost

... prof1++; if (!isValidAddress(p)) { prof2++; reportError(p); abort(); } prof3++; *p = 42; ...

slide-21
SLIDE 21
  • 1. Add profiling counters
  • 2. Identify check instructions
  • 3. Use static model

  • f cycles per instruction
  • 4. Compute cost for check


in CPU cycles: X

i∈check

prof(i) · cycles(i)

Measure Check Cost

Precise cost in CPU cycles

... prof1++; if (!isValidAddress(p)) { prof2++; reportError(p); abort(); } prof3++; *p = 42; ...

slide-22
SLIDE 22

ASAP

.exe

Measure check cost Quantify protection

Budget

Identify check instructions (de)activate checks profiling workload compiler driver IDE integration

If ASAP says you’re 87% protected, what does this mean?

slide-23
SLIDE 23

ASAP quantifies protection using the sanity level We would like to know the effective protection level Methodology: measure how many bugs/vulnerabilities are effectively prevented

slide-24
SLIDE 24

ASAP quantifies protection using the sanity level We would like to know the effective protection level Methodology: measure how many bugs/vulnerabilities are effectively prevented

Experiment 1

Source code of Python 2.7 Bug: line that has received a patch between version
 2.7.1 and 2.7.8

slide-25
SLIDE 25

20% 40% 60% 80% 100% 20% 40% 60% 80% 100%

Sanity level Buggy lines covered by checks

Sanity level 87% ≈ 91% protection Effective Protection ≥ sanity level

ASAP quantifies protection using the sanity level We would like to know the effective protection level Methodology: measure how many bugs/vulnerabilities are effectively prevented

slide-26
SLIDE 26

Experiment 2

Known bugs

Project Bugs Python 3.4 3 OpenSSL 1 RIPE Benchmarks 10

All of these are in cold code

slide-27
SLIDE 27

Experiment 2

Known bugs

Project Bugs Python 3.4 3 OpenSSL 1 RIPE Benchmarks 10

All of these are in cold code

Experiment 3

Vulnerabilities from CVE DB Analyze 145 vulnerabilities from 2014

  • Memory errors
  • Open source
  • Patch available
  • Error location known

83% of these are in cold code

Checks in cold code provide real value

slide-28
SLIDE 28

Outline

Introduction: What is ASAP? Design Key Algorithms Results Conclusion

slide-29
SLIDE 29

Results

20 40 60 80 100 120 libquantum lbm soplex mcf namd astar bzip2 milc sphinx3 hmmer gobmk sjeng gcc povray

Overhead in %

Overhead for: SPEC benchmarks AddressSanitizer

100%

sanity level

slide-30
SLIDE 30

Results

Overhead for: SPEC benchmarks AddressSanitizer

95%

sanity level

20 40 60 80 100 120 libquantum lbm soplex mcf namd astar bzip2 milc sphinx3 hmmer gobmk sjeng gcc povray

Overhead in %

CPU cycles saved

slide-31
SLIDE 31

Results

Overhead for: SPEC benchmarks AddressSanitizer

90%

sanity level

20 40 60 80 100 120 libquantum lbm soplex mcf namd astar bzip2 milc sphinx3 hmmer gobmk sjeng gcc povray

Overhead in %

slide-32
SLIDE 32

Results

Overhead for: SPEC benchmarks AddressSanitizer

80%

sanity level

20 40 60 80 100 120 libquantum lbm soplex mcf namd astar bzip2 milc sphinx3 hmmer gobmk sjeng gcc povray

Overhead in %

Residual overhead (not due to checks)

slide-33
SLIDE 33

Conclusion

Run-time checks deliver strong protection at high cost

ASAP

Identify
 sanity checks measure
 check costs select maximum set of checks

.exe

Budget

Most of the overhead comes from a few expensive checks Most of the protection comes from many cheap checks

Protect your sofuware! dslab.epfl.ch/proj/asap

slide-34
SLIDE 34

Backup slides

slide-35
SLIDE 35

Sanity Check in LLVM

; <label>:0 %1 = load i32* %fmap_i_ptr, align 4 %2 = zext i32 %1 to i64 %3 = getelementptr inbounds i32* %eclass, i64 %2 %4 = ptrtoint i32* %3 to i64 %5 = lshr i64 %4, 3 %6 = add i64 %5, 17592186044416 %7 = inttoptr i64 %6 to i8 %8 = load i8* %7, align 1 %9 = icmp eq i8 %8, 0 br i1 %9, label %18, label %10 ; <label>:10 %11 = ptrtoint i32* %3 to i64 %12 = and i64 %11, 7 %13 = add i64 %12, 3 %14 = trunc i64 %13 to i8 %15 = icmp slt i8 %14, %8 br i1 , label %18, label %16 ; <label>:16 %17 = ptrtoint i32* %3 to i64 call void @__asan_report_load4(i64 %17) #3 call void asm sideeffect "", ""() #3 unreachable ; <label>:18 %19 = load i32* %3, align 4 %15