Prac%cal Control Flow Integrity & Randomiza%on for Binary - - PowerPoint PPT Presentation

prac l control flow integrity randomiza on for binary
SMART_READER_LITE
LIVE PREVIEW

Prac%cal Control Flow Integrity & Randomiza%on for Binary - - PowerPoint PPT Presentation

Title Prac%cal Control Flow Integrity & Randomiza%on for Binary Executables Lei Duan Chao Zhang Tao Wei Zhaofeng Chen Peking University Peking University Peking University Peking University UC


slide-1
SLIDE 1

Title ¡

Prac%cal ¡Control ¡Flow ¡Integrity ¡& ¡ Randomiza%on ¡for ¡Binary ¡Executables

Chao Zhang

Peking University ¡

László Szekeres

Stony Brook University

Tao Wei

Peking University UC Berkeley

Stephen McCamant

University of Minnesota

Zhaofeng Chen

Peking University

Dawn Song

UC Berkeley

Lei Duan

Peking University

Wei Zou

Peking University

slide-2
SLIDE 2

Title ¡

Eternal ¡War ¡in ¡Memory ¡(Oakland’13)

A ¡ t ¡ t ¡ a ¡ c ¡ k ¡ e ¡ r D ¡ e ¡ f ¡ e ¡ n ¡ d ¡ e ¡ r

code ¡injec%on code ¡re-­‑use Info ¡Leakage buffer ¡overflow ¡... ret2libc, ¡ ¡ROP W ¡⊗ X ? ASLR

2 chao.100871.net

...

slide-3
SLIDE 3

Title ¡

Reac%ve ¡Defense ¡is ¡not ¡adequate

§ > ¡5,000 ¡CVE ¡vulnerabili%es ¡each ¡year. ¡

  • Many ¡more ¡are ¡under ¡the ¡iceberg. ¡

§ Vulnerabili%es ¡are ¡exploited ¡millions ¡of ¡%mes.

0 ¡ 1,000 ¡ 2,000 ¡ 3,000 ¡ 4,000 ¡ 5,000 ¡ 6,000 ¡ 7,000 ¡ 2006 ¡ 2007 ¡ 2008 ¡ 2009 ¡ 2010 ¡ 2011 ¡ 2012 ¡

#cve ¡

3 chao.100871.net

Symantec ¡Internet ¡Security ¡Threat ¡Report

slide-4
SLIDE 4

Title ¡

Proac%ve ¡Defense: ¡Control ¡Flow ¡Integrity

§ Control ¡Flow ¡Integrity, ¡CFI ¡[CCS’05] ¡ § Security ¡policy ¡

  • Each ¡run-­‑%me ¡control ¡transfer ¡must ¡comply ¡with ¡programmer’s ¡

compile-­‑%me ¡intent, ¡i.e., ¡the ¡control-­‑flow ¡graph ¡ ¡ § A ¡strong ¡guarantee ¡that ¡can ¡be ¡reasoned ¡about ¡formally ¡

  • ROP, ¡JOP, ¡UAF ¡

§ A ¡founda%on ¡for ¡other ¡low-­‑level ¡code ¡defenses ¡

  • SFI, ¡sandboxing ¡untrusted ¡code ¡

§ Determinis%c, ¡not ¡probabilis%c ¡defense ¡

4 chao.100871.net

slide-5
SLIDE 5

Title ¡ chao.100871.net

Control-­‑Flow ¡Graph ¡

§ condi%onal ¡jump ¡(jz ¡…): ¡target ¡rela%ve ¡address ¡ § direct ¡jump/call: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡target ¡rela%ve ¡or ¡absolute ¡address ¡ § indirect ¡jump/call: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡target? ¡(read ¡or ¡computed ¡from ¡memory) ¡ § return: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡target ¡return ¡address ¡on ¡the ¡stack ¡

5

slide-6
SLIDE 6

Title ¡ chao.100871.net

Scope ¡of ¡Control-­‑Flow ¡Integrity ¡Protec%on

Control ¡Transfer ¡Method Transfer ¡Targets Integrity ¡ Protec8on Excep%ons Excep%on ¡handlers SafeSEH, ¡ ¡SEHOP Direct ¡CALL/JMP, ¡ Condi%onal ¡jump ¡(JZ...) Hard-­‑coded ¡func%on ¡pointers ¡ (embedded ¡in ¡the ¡code) W⊗X Indirect ¡CALL/JMP In-­‑memory ¡func%on ¡pointers CFI RET ¡instruc%ons On-­‑stack ¡return ¡addresses /GS, ¡shadow ¡stack, ¡ CFI

6

slide-7
SLIDE 7

Title ¡ chao.100871.net

Control ¡Flow ¡Integrity ¡(CCS’05)

§ build ¡Control ¡Flow ¡Graph ¡

  • source ¡code/debug ¡info ¡
  • all ¡modules

7

¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret

slide-8
SLIDE 8

Title ¡ chao.100871.net

Control ¡Flow ¡Integrity ¡(CCS’05)

§ build ¡Control ¡Flow ¡Graph ¡ § binary ¡rewri%ng ¡

  • instrument ¡IDs ¡before ¡

transfer ¡targets ¡

  • validate ¡IDs ¡before ¡control ¡

transferring ¡

8

¡call ¡eax ID_1 foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret check ¡ID_1

slide-9
SLIDE 9

Title ¡ chao.100871.net

Control ¡Flow ¡Integrity ¡(CCS’05)

9

§ build ¡Control ¡Flow ¡Graph ¡ § binary ¡rewri%ng ¡ § diversity ¡of ¡IDs ¡

¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret check ¡ID_1 ID_1 ID_1 ID_1 check ¡ID_1

slide-10
SLIDE 10

Title ¡ chao.100871.net

Control ¡Flow ¡Integrity ¡(CCS’05)

10

¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret check ¡ID_1 ID_1 ID_1 ID_1 check ¡ID_1 ID_2 check ¡ID_2 ID_2 check ¡ID_2 check ¡ID_2

§ build ¡Control ¡Flow ¡Graph ¡ § binary ¡rewri%ng ¡ § diversity ¡of ¡IDs ¡ § all ¡indirect ¡transfers ¡

  • indirect ¡call ¡
  • indirect ¡jmp ¡
  • ret ¡
slide-11
SLIDE 11

Title ¡ chao.100871.net

Challenges ¡faced ¡by ¡CFI

§ performance ¡overhead: ¡average ¡15%, ¡max ¡46% ¡ ¡

11

Ø ID ¡is ¡embedded ¡in ¡a ¡slow ¡

prefetchnta ¡instruc%on ¡

Ø executed ¡each ¡%me ¡the ¡transfer ¡

target ¡is ¡reached ¡

Ø introduce ¡overhead ¡even ¡if ¡foo ¡

is ¡called/jumped ¡to ¡directly ¡

ü most ¡calls/jumps ¡are ¡direct ¡

¡call ¡eax foo: ¡... ¡... next_1: ¡ret check ¡ID_1 ID_1 ¡call ¡foo ¡...

slide-12
SLIDE 12

Title ¡ chao.100871.net

Challenges ¡faced ¡by ¡CFI

§ performance ¡overhead ¡ § modularity ¡support ¡

  • A ¡single ¡module ¡cannot ¡be ¡hardened ¡independently

12

libc module_A

¡call ¡printf ¡... ID_A

module_B

¡call ¡printf ¡... ID_B printf: ¡... ¡ret check ¡which ¡ID?

slide-13
SLIDE 13

Title ¡ chao.100871.net

Challenges ¡faced ¡by ¡CFI

§ performance ¡overhead ¡ § modularity ¡support ¡ § backward ¡compa%bility ¡

13

unhardened module hardened module ¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret check ¡ID_1 ID_1 ID_1

test: ¡... ¡ret

slide-14
SLIDE 14

Title ¡ chao.100871.net

Challenges ¡faced ¡by ¡CFI

§ performance ¡overhead ¡ § modularity ¡support ¡ § backward ¡compa%bility ¡ § source ¡code/debug ¡info ¡dependency ¡

  • to ¡build ¡Control ¡Flow ¡Graph ¡

14

slide-15
SLIDE 15

Title ¡

Mo%va%on

§ A ¡light-­‑weight ¡CFI ¡solu%on ¡with ¡a ¡strong ¡protec%on ¡

15 chao.100871.net

·√ ¡performance ¡overhead ·√ ¡modularity ¡support ·√ ¡backward ¡compatibility ·√ ¡source ¡code ¡independent

slide-16
SLIDE 16

Title ¡

Assump%on

§ ASLR ¡and ¡W⊗X (e.g. DEP) are deployed § NO self-modifying code or dynamically generated

code.

§ Limited ¡informa%on ¡disclosure ¡vulnerabili%es ¡

  • e.g., ¡cannot ¡read ¡en%re ¡memory ¡regions ¡

16 chao.100871.net

slide-17
SLIDE 17

Title ¡

Outline

§ Mo%va%on ¡ § Intui%on ¡& ¡Design ¡ § Implementa%on ¡ § Security ¡Enhancement ¡ § Evalua%on ¡ § Conclusion

17 chao.100871.net

slide-18
SLIDE 18

Title ¡ chao.100871.net

Intui%on

18

§ Checking ¡transfer ¡targets’ ¡kind, ¡rather ¡than ¡IDs ¡

  • indirect ¡call/jmp ¡can ¡only ¡transfer ¡to ¡func%on-­‑pointer ¡stubs ¡
  • returns ¡can ¡only ¡transfer ¡to ¡return-­‑address ¡stubs
slide-19
SLIDE 19

Title ¡ chao.100871.net

Intui%on: ¡efficient ¡check

§ memory ¡alignment ¡

  • func%on ¡pointer ¡stubs ¡are ¡8-­‑bytes ¡aligned ¡
  • return ¡address ¡stubs ¡are ¡16-­‑bytes ¡aligned ¡

19

¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret test ¡eax,7 test ¡ecx,7 test ¡[esp],0x0f test ¡[esp],0x0f test ¡[esp],0x0f

·√ ¡performance ¡overhead

§ fast ¡bit ¡tes%ng ¡ § No ¡IDs ¡ § only ¡check ¡type ¡

·√ ¡modularity ¡support ·√ ¡performance ¡overhead

slide-20
SLIDE 20

Title ¡ chao.100871.net

Intui%on: ¡security

§ Transfer ¡targets ¡must ¡be ¡within ¡memory ¡region ¡Springboard ¡

  • 27th ¡bit ¡is ¡0 ¡

¡ ¡

§ Policy: ¡all ¡indirect ¡transfer ¡targets ¡must ¡be ¡aligned ¡stubs ¡in ¡Springboard.

20

¡call ¡eax foo: ¡... ¡... next_1: ¡ret bar: ¡... ¡ret fun: ¡... ¡call ¡ecx ¡... next_2: ¡ret test ¡eax,M_F test ¡ecx,M_F test ¡[esp],M_R ¡ test ¡[esp],M_R test ¡[esp],M_R

M_R ¡= ¡0x 800000f M_F ¡= ¡0x 8000007

slide-21
SLIDE 21

Title ¡

Design: ¡Memory ¡layout ¡with ¡Springboard

21

§ Springboard ¡vs. ¡normal ¡code ¡sec%on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(27th ¡bit) ¡ § Entries ¡in ¡the ¡Springboard ¡are ¡all ¡aligned. ¡(0-­‑2 ¡bits) ¡ § Three ¡kinds ¡of ¡stubs ¡in ¡Springboard ¡

  • fp-­‑stub ¡entries ¡vs. ¡ret-­‑stub ¡entries ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(3rd ¡bit) ¡
  • sensi%ve ¡vs. ¡normal ¡ret-­‑stub ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(26th ¡bit) ¡

§ normal ¡ret-­‑stubs ¡cannot ¡return ¡into ¡the ¡middle ¡of ¡sensi%ve ¡func%ons ¡

§ One ¡or ¡two ¡fast ¡bit ¡tes%ng ¡instruc%ons ¡are ¡sufficient

Executable ? Bits Meaning 27 26 3 2-­‑0

No * * * *** Non-­‑executable ¡sec%on Yes 1 * * *** Normal ¡code ¡sec%on Yes * * !000 Invalid ¡entry ¡in ¡Springboard Yes * 1 000 fp-­‑stub ¡entry ¡in ¡Springboard Yes 1 000 Sensi%ve ¡ret-­‑stub ¡entry ¡in ¡Springboard Yes 000 Normal ¡ret-­‑stub ¡entry ¡in ¡Springboard

chao.100871.net

slide-22
SLIDE 22

Title ¡

Architecture ¡of ¡our ¡solu%on: ¡CCFIR

22 chao.100871.net

§ Find ¡out ¡all ¡indirect ¡transfer ¡instruc%ons ¡and ¡their ¡targets ¡

  • BitCover: ¡disassemble ¡target ¡binary ¡

§ Redirect ¡transfer ¡targets ¡to ¡aligned ¡stubs ¡in ¡Springboard ¡ § Validate ¡transfer ¡targets ¡

  • BitRewrite: ¡binary ¡rewri%ng ¡

§ Verify ¡the ¡hardened ¡binary ¡

  • BitVerify ¡
slide-23
SLIDE 23

Title ¡

Outline

§ Mo%va%on ¡ § Intui%on ¡& ¡Design ¡ § Implementa%on ¡ § Security ¡Enhancement ¡ § Evalua%on ¡ § Conclusion

23 chao.100871.net

slide-24
SLIDE 24

Title ¡

BitCover: ¡disassembling ¡

§ Target: ¡normal ¡binaries ¡generated ¡by ¡modern ¡compilers ¡

  • Support ¡ASLR ¡

§ On ¡Windows, ¡it ¡implies ¡the ¡executable ¡contains ¡reloca%on ¡informa%on ¡ § We ¡can ¡iden%fy ¡all ¡legal ¡func%on ¡pointers ¡(indirect ¡call/jmps’ ¡targets) ¡

§ Automa%cally ¡disassemble ¡most ¡of ¡normal ¡binaries ¡

  • Based ¡on ¡well-­‑defined ¡rules ¡
  • More ¡accurate ¡than ¡IDA ¡Pro, ¡especially ¡designed ¡for ¡binary ¡rewri%ng

chao.100871.net 24

·√ ¡performance ¡overhead ·√ ¡modularity ¡support ·√ ¡backward ¡compatibility ·√ ¡source ¡code ¡independent

slide-25
SLIDE 25

Title ¡ chao.100871.net

BitRewrite: ¡binary ¡rewri%ng

25

§ Policy: ¡all ¡indirect ¡transfers ¡are ¡enforced ¡to ¡aligned ¡stubs ¡in ¡Springboard.

§ Validate ¡ret’s ¡target. ¡

  • ret-­‑stub ¡in ¡Springboard ¡

Protected ¡code ¡section Springboard ¡section Original ¡code ¡section

1 2 5 6 3 4

call ¡eax ret

1 2 3 4 5 6 3'

Direct ¡control ¡transfer Indirect ¡control ¡transfer ret

validate

mov ¡eax, ¡5 call ¡eax mov ¡eax, ¡5

slide-26
SLIDE 26

Title ¡

BitRewrite: ¡binary ¡rewri%ng

26

§ Policy: ¡all ¡indirect ¡transfers ¡are ¡enforced ¡to ¡aligned ¡stubs ¡in ¡Springboard.

§ Validate ¡ret’s ¡target. ¡

  • ret-­‑stub ¡in ¡Springboard ¡

§ Redirect ¡ret’s ¡target. ¡

  • move ¡call ¡to ¡Springboard ¡

chao.100871.net

Protected ¡code ¡section Springboard ¡section Original ¡code ¡section

1 2 5 6 3 4

ret

1 2' 3 4 2'' 5 6 3'

Direct ¡control ¡transfer Indirect ¡control ¡transfer call ¡eax ret

validate

call ¡eax mov ¡eax, ¡5 mov ¡eax, ¡5

slide-27
SLIDE 27

Title ¡

BitRewrite: ¡binary ¡rewri%ng

27

§ Policy: ¡all ¡indirect ¡transfers ¡are ¡enforced ¡to ¡aligned ¡stubs ¡in ¡Springboard.

§ Validate ¡ret’s ¡target. ¡

  • ret-­‑stub ¡in ¡Springboard ¡

§ Redirect ¡ret’s ¡target. ¡

  • move ¡call ¡to ¡Springboard ¡

§ Validate ¡call’s ¡target. ¡

  • fp-­‑stub ¡in ¡Springboard ¡

chao.100871.net

Protected ¡code ¡section Springboard ¡section Original ¡code ¡section

1 2 5 6 3 4

ret

1 2' 3 4 2'' 5' 5 6 3'

Direct ¡control ¡transfer Indirect ¡control ¡transfer ret

validate

call ¡eax mov ¡eax, ¡5 mov ¡eax, ¡5 call ¡eax

validate

slide-28
SLIDE 28

Title ¡

BitRewrite: ¡binary ¡rewri%ng

28

§ Policy: ¡all ¡indirect ¡transfers ¡are ¡enforced ¡to ¡aligned ¡stubs ¡in ¡Springboard.

§ Validate ¡ret’s ¡target. ¡

  • ret-­‑stub ¡in ¡Springboard ¡

§ Redirect ¡ret’s ¡target. ¡

  • move ¡call ¡to ¡Springboard ¡

§ Validate ¡call’s ¡target. ¡

  • fp-­‑stub ¡in ¡Springboard ¡

§ Redirect ¡call’s ¡target. ¡

  • rewrite ¡func%on ¡pointers

chao.100871.net

Protected ¡code ¡section Springboard ¡section Original ¡code ¡section

1 2 5 6 3 4

ret

1 2' 3 4 2'' 5' 5 6 3'

Direct ¡control ¡transfer Indirect ¡control ¡transfer call ¡eax ret

validate validate

call ¡eax mov ¡eax, ¡5 mov ¡eax, ¡5'

slide-29
SLIDE 29

Title ¡

BitRewrite: ¡In ¡a ¡nutshell

§ redirect ¡func%on ¡pointers ¡and ¡return ¡addresses ¡

  • rewrite ¡func%on ¡pointers ¡in ¡memory ¡
  • move ¡call ¡instruc%ons ¡to ¡springboard ¡

§ validate ¡transfer ¡targets ¡with ¡bit ¡tes%ng ¡instruc%ons

29 chao.100871.net

¡call ¡eax ¡call ¡eax ¡ret ¡ret next: next: ¡mov ¡eax,foo ¡mov ¡eax,foo foo: foo: ¡... ¡... ¡... ¡...

¡ret ¡ret foo: foo: ¡jmp ¡next_sb-­‑2 ¡jmp ¡next_sb-­‑2 next: next: foo_sb: foo_sb: ¡jmp ¡foo ¡jmp ¡foo ¡jmp ¡back ¡jmp ¡back ¡call ¡eax ¡call ¡eax next_sb: next_sb: ¡mov ¡eax,foo_sb ¡mov ¡eax,foo_sb ¡... ¡... ¡jnz ¡error ¡jnz ¡error ¡test ¡[esp],M_R ¡test ¡[esp],M_R ¡jnz ¡error ¡jnz ¡error ¡test ¡eax,M_F ¡test ¡eax,M_F ¡... ¡... ¡... ¡... ¡test ¡eax,8 ¡test ¡eax,8 ¡jz ¡error ¡jz ¡error Direct ¡control ¡transfer Indirect ¡control ¡transfer M_F ¡= ¡0x8000007 M_R ¡= ¡0x800000f ¡ ¡ ¡ ¡ ¡ ¡or M_R ¡= ¡0xC00000f M_F ¡= ¡0x8000007 M_R ¡= ¡0x800000f ¡ ¡ ¡ ¡ ¡ ¡or M_R ¡= ¡0xC00000f

slide-30
SLIDE 30

Title ¡ chao.100871.net

BitRewrite: ¡Op%miza%ons

§ With ¡the ¡support ¡of ¡W⊗X, we can skip redirecting or

validating ¡

  • directly ¡used ¡func%on ¡pointers ¡

§ call ¡foo ¡

  • directly ¡used ¡imported ¡func%ons ¡

§ call ¡[imp_foo] ¡

  • switch ¡statements ¡and ¡jump ¡table ¡

§ jmp ¡jump_table[eax*4] ¡

30

·√ ¡performance ¡overhead ·√ ¡modularity ¡support ·√ ¡backward ¡compatibility ·√ ¡source ¡code ¡independent

slide-31
SLIDE 31

Title ¡

BitRewrite: ¡ ¡ backward ¡compa%bility

§ With ¡a ¡full ¡deployment ¡(i.e., ¡all ¡modules ¡hardened), ¡ ¡

  • backward ¡compa%bility ¡issues ¡no ¡longer ¡existed.

§ With ¡incremental ¡deployment, ¡such ¡issues ¡occur ¡when ¡

  • CALL/JMP ¡to ¡func%ons ¡in ¡unhardened ¡modules ¡
  • RET ¡to ¡return ¡addresses ¡in ¡unhardened ¡modules ¡

31 chao.100871.net

·√ ¡performance ¡overhead ·√ ¡modularity ¡support ·√ ¡backward ¡compatibility ·√ ¡source ¡code ¡independent

slide-32
SLIDE 32

Title ¡

case ¡1: ¡Imported ¡func%ons

§ Challenge ¡

  • Import ¡Address ¡Table ¡(IAT) ¡
  • load-­‑%me ¡resolving ¡

§ the ¡loader ¡will ¡update ¡IAT ¡ § we ¡cannot ¡sta%cally ¡rewrite ¡IAT ¡entries ¡

(func%on ¡pointers) ¡

§ Solu%on ¡

  • Replace ¡IAT ¡with ¡a ¡wrapper ¡table ¡

32 chao.100871.net mov ¡ecx,[foo_slot] .iat: ¡... foo_slot: ¡ ¡ ¡foo call ¡ecx points ¡to Springboard ¡ ¡ ¡jmp ¡[foo_slot] foo_sb:

IAT_wrapper

mov ¡ecx, ¡[foo_slot_wrap] .iat: ¡... foo_slot: ¡ ¡ ¡foo ¡ foo_slot_wrap: ¡ ¡ ¡foo_sb points ¡to call ¡ecx

slide-33
SLIDE 33

Title ¡

case ¡2: ¡Func%ons ¡resolved ¡by ¡GetProcAddress

§ Challenge ¡

  • GetProcAddress() ¡returns ¡a ¡

non-­‑redirected ¡func%on ¡

  • pointer. ¡
  • The ¡instrumented ¡security ¡

check ¡will ¡fail ¡

§ Solu%on ¡

  • wrapper ¡for ¡GetProcAddress ¡
  • redirect ¡return ¡value ¡at ¡run%me

33 chao.100871.net

Springboard ¡ ¡ ¡jmp ¡gpa_wrapper gpa_sb:

IAT_wrapper

mov ¡ecx, ¡[gpa_slot_wrap] .iat: ¡... gpa_slot: ¡GetProcAddress gpa_slot_wrap: ¡ ¡ ¡gpa_sb points ¡to call ¡ecx gpa_wrap: #fill ¡new ¡stub call ¡[gpa_slot] #ret ¡stub ¡ptr ¡... ¡... call ¡eax ¡;GPA’s ¡ret ¡value mov ¡ecx,[gpa_slot] .iat: ¡... gpa_slot: ¡GetProcAddress call ¡ecx points ¡to call ¡eax ¡;GPA’s ¡ret ¡value

slide-34
SLIDE 34

Title ¡

BitVerify: ¡Offline ¡Verifica%on

§ whether ¡a ¡given ¡binary ¡conforms ¡to ¡security ¡rules? ¡

  • 27th ¡bit ¡of ¡executable ¡sec%on ¡except ¡Springboard ¡should ¡be ¡1 ¡
  • Code ¡stubs ¡in ¡Springboard ¡are ¡all ¡aligned ¡
  • Func%on ¡pointers ¡are ¡redirected ¡
  • Call ¡instruc%on ¡has ¡been ¡redirected ¡
  • Check ¡code ¡has ¡been ¡correctly ¡inserted ¡
  • ...

34 chao.100871.net

slide-35
SLIDE 35

Title ¡

Outline

§ Mo%va%on ¡ § Intui%on ¡& ¡Design ¡ § Implementa%on ¡ § Security ¡Enhancement ¡ § Evalua%on ¡ § Conclusion

35 chao.100871.net

slide-36
SLIDE 36

Title ¡

Policy ¡1: ¡Restrain ¡sensi%ve ¡func%ons

§ Sensi%ve ¡func%ons ¡

  • system(), ¡execv(), ¡VirtualProtect(), ¡VirtualAlloc(), ¡... ¡

§ Policy: ¡

  • Sensi%ve ¡func%ons ¡should ¡be ¡used ¡via ¡direct ¡calls. ¡

§ i.e., ¡their ¡addresses ¡are ¡never ¡taken ¡except ¡hard-coded ¡in ¡instruc%ons ¡

§ Benefit: ¡

  • NO ¡fp-­‑stubs ¡for ¡sensi%ve ¡func%ons ¡in ¡the ¡Springboard ¡
  • Avackers ¡cannot ¡indirectly ¡call/jump ¡to ¡these ¡func%ons. ¡

36 chao.100871.net

slide-37
SLIDE 37

Title ¡

Policy ¡2: ¡Load-­‑%me ¡Randomiza%on

§ Policy: ¡

  • The ¡order ¡of ¡all ¡stubs ¡in ¡the ¡Springboard ¡are ¡randomized ¡at ¡

load-­‑%me. ¡ § Benefit: ¡

  • cannot ¡guess ¡one ¡stub’s ¡address ¡even ¡if ¡another ¡address ¡is ¡

leaked ¡in ¡the ¡Springboard. ¡

  • A ¡stronger ¡randomiza%on ¡than ¡ASLR. ¡

§ It ¡provides ¡an ¡extra ¡layer ¡of ¡protec%on ¡from ¡the ¡

previous ¡CFI-­‑style ¡checking.

37 chao.100871.net

slide-38
SLIDE 38

Title ¡

Brief ¡Security ¡Analysis

§ return-­‑to-­‑libc ¡ § jump-­‑to-­‑libc ¡

  • similar ¡to ¡return-­‑to-­‑libc ¡
  • gadgets ¡must ¡start ¡from ¡fp-­‑stubs ¡in ¡the ¡Springboard ¡

§ ROP ¡

  • Valid ¡gadgets ¡must ¡start ¡from ¡ret-­‑stubs ¡in ¡the ¡Springboard ¡
  • Few ¡valid ¡ROP ¡gadgets ¡

§ much ¡longer, ¡hard ¡to ¡chain. ¡

38 chao.100871.net

libc

system(): system(): ¡... ¡... printf(): printf(): ¡... ¡...

¡ret ¡ret foo(): foo(): ¡... ¡... test ¡[esp], test ¡[esp], NO ¡ret-­‑stub ¡for ¡ system() ret-­‑stub ¡for ¡printf() ¡is ¡ randomized

(info ¡leakage ¡is ¡needed) ¡

slide-39
SLIDE 39

Title ¡

Outline

§ Mo%va%on ¡ § Intui%on ¡& ¡Design ¡ § Implementa%on ¡ § Security ¡Enhancement ¡ § Evalua%on ¡ § Conclusion

39 chao.100871.net

slide-40
SLIDE 40

Title ¡

Run%me ¡Overhead

§ SPECint2000, ¡average ¡3.6%, ¡max ¡8.6% ¡ § SPECfp2000, ¡average ¡0.59%, ¡max ¡3.98%

40 chao.100871.net

slide-41
SLIDE 41

Title ¡

Sta%c ¡Analysis ¡Time

§ SPECint2000 ¡& ¡SPECfp2000, ¡ ¡ ¡10s ¡seconds

41 chao.100871.net

slide-42
SLIDE 42

Title ¡

ROP ¡Elimina%on

§ Mona ¡is ¡used ¡to ¡count ¡ROP ¡gadgets ¡ § Valid ¡gadgets ¡must ¡start ¡from ¡ret-­‑stubs ¡in ¡Springboard ¡

42

SPECfp2000 ¡ ¡ App

  • riginal ¡

#gadgets new ¡ #gadgets valid ¡ #gadgets

wupwise 255 swim 116 134 mgrid 161 166 applu 182 172 mesa 21696 galgel 1515 952 art 1874 equake 1710 facerec 826 775 ROP ¡gadgets ¡count ¡(part)

slide-43
SLIDE 43

Title ¡

Real ¡World ¡Exploits ¡Protec%on

43 chao.100871.net

slide-44
SLIDE 44

Title ¡

Outline

§ Mo%va%on ¡ § Intui%on ¡& ¡Design ¡ § Implementa%on ¡ § Security ¡Enhancement ¡ § Evalua%on ¡ § Conclusion

44 chao.100871.net

slide-45
SLIDE 45

Title ¡

Conclusion

§ Performance ¡and ¡compa%bility ¡issues ¡limit ¡the ¡adop%on ¡of ¡

Control ¡Flow ¡Integrity. ¡

§ CCFIR ¡is ¡a ¡lightweight ¡CFI ¡solu%on ¡providing ¡a ¡strong ¡

guarantee, ¡can ¡block ¡control-­‑flow ¡hijacks ¡like ¡ROP ¡and ¡ret2libc. ¡

§ CCFIR ¡overcomes ¡the ¡performance ¡and ¡compa%bility ¡issues, ¡

and ¡make ¡it ¡a ¡prac%cal ¡solu%on. ¡

45 chao.100871.net

slide-46
SLIDE 46

Title ¡

Thanks!

46