Improving Application Software Security in Linux Sebastian Neubauer - - PowerPoint PPT Presentation

improving application software security in linux
SMART_READER_LITE
LIVE PREVIEW

Improving Application Software Security in Linux Sebastian Neubauer - - PowerPoint PPT Presentation

Improving Application Software Security in Linux Sebastian Neubauer Technische Universitt Mnchen Computer Science Department July 19, 2017 1 Improve C/C++ applications contain bugs Security Existing security mechanisms Still


slide-1
SLIDE 1

Improving Application Software Security in Linux

Sebastian Neubauer

Technische Universität München

Computer Science Department

July 19, 2017

1

slide-2
SLIDE 2

Improve Security

  • n Linux

◮ C/C++ applications contain bugs ◮ Existing security mechanisms ◮ Still many ways for exploitation ◮ Close them!

2

slide-3
SLIDE 3

Improve Security

  • n Linux

◮ C/C++ applications contain bugs ◮ Existing security mechanisms ◮ Still many ways for exploitation ◮ Close them! ◮ Problem: Performance loss ◮ We need to be fast!

2

slide-4
SLIDE 4

Contributions

◮ mmap randomization: Add random gaps

between mmap allocations

◮ Canaries: Clear after use and random

values

◮ Stack pinning: Check the address of the

stack pointer

slide-5
SLIDE 5

Exploit: Stack pivoting

slide-6
SLIDE 6

Exploit

Stack pivoting

Stack

buf frame pointer return addr . . . known address

Heap

  • ther

buf buffer overflow

5

slide-7
SLIDE 7

Exploit

Stack pivoting

Stack

buf frame pointer return addr . . . known address

Heap

  • ther

buf buffer overflow

5

slide-8
SLIDE 8

Exploit

Stack pivoting

Stack

buf frame pointer return addr . . . known address

Heap

ROP chain buffer overflow

5

slide-9
SLIDE 9

Idea

Stack pinning

◮ Check if the stack pointer points to the stack

region

6

slide-10
SLIDE 10

Idea

Stack pinning

◮ Check if the stack pointer points to the stack

region

◮ Almost every exploit arrives at a syscall ◮ Check the stack pointer in every sytem call ◮ Save stack bounds in the kernel task_struct

(for each process/thread)

6

slide-11
SLIDE 11

Pitfalls

Stack pinning

◮ Forks, new threads ◮ Alternate signal stack ◮ Main stack can grow

7

slide-12
SLIDE 12

Pitfalls

Stack pinning Wine and Go

◮ Stack pivoting as a Feature

8

slide-13
SLIDE 13

Pitfalls

Stack pinning Wine and Go

◮ Stack pivoting as a Feature

⇒ Only opt-in possible

◮ Save the current memory area as stack area

prctl(PR_PIN_STACK, ...)

8

slide-14
SLIDE 14

Performance

slide-15
SLIDE 15

Performance

Stack pinning

Seconds, Less Is Better

patched-active patched-inactive unpatched 5 10 15 20

SE +/- 0.27 SE +/- 0.17 SE +/- 0.12

18.47 18.72 18.65

◮ Microbenchmark: (1 ± 2) % difference

10

slide-16
SLIDE 16

Performance

Stack pinning

PHOR Requests Per Second, More Is Better

patched-active patched-inactive unpatched 6000 12000 18000 24000 3000

SE +/- 22.57 SE +/- 437.44 SE +/- 344.93

27845.61 26944.31 25087.44

◮ Microbenchmark: (1 ± 2) % difference ◮ ApacheBench: (11 ± 2) % more requests per

second

10

slide-17
SLIDE 17

Demo

slide-18
SLIDE 18

Problem: mmap is deterministic

slide-19
SLIDE 19

Problem

Deterministic mmap

. . .

allocated pages allocated pages

. . . free space

13

slide-20
SLIDE 20

Problem

Deterministic mmap

. . .

allocated pages allocated pages

. . . new free space new allocation

13

slide-21
SLIDE 21

Problem

Deterministic mmap

. . .

allocated pages allocated pages

. . . new free space new allocation

13

slide-22
SLIDE 22

Idea

Random mmap

. . .

allocated pages allocated pages

. . . free space

14

slide-23
SLIDE 23

Idea

Random mmap

. . .

allocated pages allocated pages

. . . free space new new allocation

14

slide-24
SLIDE 24

Problem: Canaries are static

slide-25
SLIDE 25

Problem

Static canaries

buf

0x178a96b 9db46f00

buf

0x178a96b 9db46f00

. . .

global ssp

foo main

16

slide-26
SLIDE 26

Idea

Random canaries

Safe stack Unsafe stack

local ssp

ret . . .

global ssp

buf ssp . . .

17

slide-27
SLIDE 27

Idea

Random canaries

buf

0x178a96b 9db46f00

buf

0x163ce511 85630100

. . .

local ssp

ret

local ssp

ret . . . foo main

global ssp

18

slide-28
SLIDE 28

Summary

◮ 3 fast additions, which make exploiting harder ◮ Goal: Make attacking harder with low

  • verhead

19

slide-29
SLIDE 29

Summary

◮ 3 fast additions, which make exploiting harder ◮ Goal: Make attacking harder with low

  • verhead

◮ Propose the patches mainline

19

slide-30
SLIDE 30
slide-31
SLIDE 31

Performance

mmap

Seconds, Less Is Better

Default mmap-patch 2 4 6 8

SE +/- 0.02 SE +/- 0.02

8.59 8.84

◮ Microbenchmark: (2.8 ± 0.5) % slower

21

slide-32
SLIDE 32

Performance

mmap

Seconds, Less Is Better

Default mmap-patch 30 60 90 120

SE +/- 1.14 SE +/- 2.37

125.51 124.20

◮ Microbenchmark: (2.8 ± 0.5) % slower ◮ Linux compilation: (1 ± 3) % faster

21