Anil Kurmus kur@zurich.ibm.com IBM Research - Zurich Outline 1. - - PowerPoint PPT Presentation

anil kurmus kur zurich ibm com ibm research zurich
SMART_READER_LITE
LIVE PREVIEW

Anil Kurmus kur@zurich.ibm.com IBM Research - Zurich Outline 1. - - PowerPoint PPT Presentation

September 2016 BalCCon 2k16 Kernel Exploitation and Hardening Why we could have nice things! (using Split Kernel) Anil Kurmus kur@zurich.ibm.com IBM Research - Zurich Outline 1. Background Hardening Kernel Vulnerabilities Kernel


slide-1
SLIDE 1

Kernel Exploitation and Hardening Why we could have nice things! (using Split Kernel)

September 2016 – BalCCon 2k16

Anil Kurmus

kur@zurich.ibm.com IBM Research - Zurich

slide-2
SLIDE 2

2

Outline

  • 1. Background

Hardening Kernel Vulnerabilities Kernel Hardening

  • 2. Split Kernel

Overview Design Implementation Evaluation

slide-3
SLIDE 3

3

A Program

F(A,B): C A+B ← C C*C ← RET C

slide-4
SLIDE 4

4

A Hardened Program

F(A,B): C A+B ← Are we doing OK? C C*C ← Are we doing OK? RET C

slide-5
SLIDE 5

5

What Makes A Good Hardening Feature?

Asking the right “are we doing OK” question:

  • Mitigates many likely vulnerabilities (security)
  • Taking few resources to answer (performance)
  • Retrofitting and configuration is easy (usability)
  • Not breaking the program (correctness)
slide-6
SLIDE 6

6

Hardening Feature Examples

  • SSP, Heap hardening, Format hardening, ...
  • CFI, CPI, SafeStack, Softbound+CETS, ...
  • All mitigate some vulnerabilities
  • All have some performance overhead

Is hardening worth it?

slide-7
SLIDE 7

7

Is Hardening worth it?

slide-8
SLIDE 8

8

Is Hardening worth it?

Easy-to-answer cases first?

slide-9
SLIDE 9

9

A wall clock

slide-10
SLIDE 10

10

Although...

The Great Seal Bug

slide-11
SLIDE 11

11

An IoT Wall Clock

slide-12
SLIDE 12

12

Let's recap

Cases that require hardening, cases that don't

  • Hard to tell at the development phase
  • Better if configurable during deployment

Often a security vs. performance trade-off

slide-13
SLIDE 13

13

Kernel Vulnerabilities

  • A long standing issue...
  • USAF Study [Anderson 1972]
  • … relevant to this day in practice
  • Windows kernel TrueType Font parsing (Duqu)
  • iOS jailbreaks (e.g., PEGASUS recently)
  • Linux SCTP remote exploit (sgrakkyu)
  • And many more!
slide-14
SLIDE 14

14

Stack infoleak

slide-15
SLIDE 15

15

Kernel stack clearance

  • Zeroing the kernel stack at each syscall

(PAX STACKLEAK)

  • Can be expensive, does not prevent all

vulnerabilities

  • Zeroing after each stack allocation
  • Even more expensive, but mitigates all stack

missing initialization vulnerabilities

  • Do we always have to pay this cost?
slide-16
SLIDE 16

16

Example: OpenSSH

  • The OpenSSH daemon is privilege separated

[Provos et al., Sec'03]

  • The main daemon runs as root
  • A sandboxed process handles session establishment
  • An attacker gaining code execution in the sandboxed

process can escape via a kernel exploit

→ kernel hardening is beneficial

  • An attacker gaining code execution in the main process

has full access

→ kernel hardening causes unnecessary overhead

slide-17
SLIDE 17

17

The best of both worlds What if one could select kernel hardening at runtime, at no cost, in a granular way?

slide-18
SLIDE 18

18

Split Kernel

Kurmus & Zippel, ACM CCS'14 http://static.securegoose.org/papers/ccs14.pdf

slide-19
SLIDE 19

19

Overview

  • Build kernel with and

without hardening

  • Chose at run-time

whether to run in hardened mode

  • Shared data enables

switching safely between the two sets

  • f kernel functions
slide-20
SLIDE 20

20

Two modes, One kernel

  • If compromised in any
  • f the two modes,

compromised in both

  • But: the kernel is less

likely to be compromised in split- hardened mode

slide-21
SLIDE 21

21

Design goals

  • No split-base overhead

→ minimal changes to split-base code

  • No control flow from split-hardened to split-base

→ need to instrument the code

  • Run-time configurability

→ binding processes, users, interrupts, ...

  • Maintainability

→ limit changes to the Linux kernel

slide-22
SLIDE 22

22

Example: OpenSSH + Split Kernel

Goal: no overhead

slide-23
SLIDE 23

23

Low overhead split-base

sys_read: … call do_read read() do_read: … %rax = @vfs_read call *%rax

Low split-base overhead by design

compare branch

slide-24
SLIDE 24

24

Split-hardened mode

slide-25
SLIDE 25

25

Binding sandboxed sshd to split-hardened mode

  • Execute during boot scripts:

id -u sshd >> /sys/kernel/split/hdn_uid_list

  • No application source changes
  • Similar: binding individual processes, interrupts
slide-26
SLIDE 26

26

Split-hardened mode

Goal: remain in hardened mode

slide-27
SLIDE 27

27

Remaining in hardened mode

  • Idea: instrument every base function
  • Problem: creates overhead in split-base mode
  • Better to instrument at the call source
  • Split kernel modifies or instruments split-

hardened function calls

  • Direct calls: modified at build-time
  • Indirect calls: statically instrumented to use

alternative function address

slide-28
SLIDE 28

28

Example: OpenSSH

sys_read__hdn: … call do_read__hdn read() do_read__hdn: … %rax = @vfs_read %rax = *(%rax-8) call *%rax @vfs_read__hdn vfs_read: …

Efficient indirect call instrumentation

slide-29
SLIDE 29

29

Split Builds

slide-30
SLIDE 30

30

Implementation highlights

  • Split builds use ELF symbol weakening to ensure data

sharing

  • Kernel hardening mechanisms implemented:
  • Kernel stack exhaustion prevention
  • Kernel stack clearance
  • Kernel function pointer protection
  • Code segregation to prevent split-base performance

regressions from spatial locality

  • x86-64 and MIPS32 (OpenWrt) port
  • Full loadable kernel module support
slide-31
SLIDE 31

31

Implementation

slide-32
SLIDE 32

32

Demo

slide-33
SLIDE 33

33

Evaluation

slide-34
SLIDE 34

34

Micro benchmarks

slide-35
SLIDE 35

35

Macro benchmarks: OpenSSH

  • Kernel performance insensitive workloads
  • “Opportunistic hardening” possible
  • Split-hardened binding 1 is much faster
  • Reason: 1K syscalls vs. 100K syscalls, network polling thread
  • Choosing between binding 1 and 2 (w/ interrupt binding)
  • Depending on perceived attack surface and performance gain
slide-36
SLIDE 36

36

Conclusion

slide-37
SLIDE 37

37

Split Kernel may be used...

  • By sysadmins, developers, packagers:
  • to tailor the kernel to security and performance

needs.

  • By kernel maintainers:
  • to cut down on “performance vs. security” debates.
  • By researchers and kernel developers:
  • to argue that a powerful, yet slow, kernel hardening

mechanism is practical

slide-38
SLIDE 38

38

We could have nice things!

Contact: kur@zurich.ibm.com

slide-39
SLIDE 39

39

IBM Research - Zurich