new ropecker( ageneric(and(prac/cal(approach( … · 2019. 1. 22. · •...

20
ROPecker A Generic and Prac/cal Approach For Defending Against ROP A:acks Yueqiang Cheng $ , Zongwei Zhou * , Miao Yu * , Xuhua Ding $ and Robert H. Deng $ $ School of Informa/on Systems, Singapore Management University * ECE Department and CyLab, Carnegie Mellon University

Upload: others

Post on 12-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

ROPecker  A  Generic  and  Prac/cal  Approach  For  Defending  Against  ROP  A:acks

Yueqiang  Cheng$,  Zongwei  Zhou*,  Miao  Yu*,  Xuhua  Ding$  and  Robert  H.  Deng$  

$  School  of  Informa/on  Systems,  Singapore  Management  University  *  ECE  Department  and  CyLab,  Carnegie  Mellon  University  

Page 2: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

•  ROP  aFack  is  a  code-­‐reuse  aFack  – No  injected  malicious  code  

•  To  launch  an  ROP  aFack  –  IdenNfy  intended  gadgets  

•  End  with  indirect  branches,  e.g.,  ret,  jmp,  call  •  Small  size  •  Sparsely  distributed  -­‐>  (imply)  needing  large  code  base  

– Chain  idenNfied  gadgets  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   2  

Return-­‐Oriented  Programming  

Page 3: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Exis/ng  Approaches  Pe

rforman

ce  Overhead  

 Low                                                                  High

 

Program  Binary                                                                    Source  Code  Requirements  

3  

Code  Instr.  No  Code  Instr.  

Return-­‐less,  EuroSys’10  

G-­‐Free,  ACSAC’10  CFLocking,  ACSAC’11  

ROPdefender,  AsiaCCS’11    DROP,  ICISS’10  

HyperCrop,  ICISS’11  

ILR  and  IPR,  S&P’12  Binary  SNrring,  

CCS’12  CCFIR,  S&P’13  

KBouncer,  USENIX’13  

ROPecker  Is    HERE!  

None  1.  Generic 2.  Transparent 3.  Efficient

Page 4: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Assump/ons    

•  DEP  mechanism  is  enabled  – NO  aFempt  to  protect  self-­‐modified  applicaNons  

•  ROP  gadgets  are  sparsely  distributed  – Need  large  code  base  for  collecNng  intended  gadgets  

•  NOT  rely  on  ASLR  mechanism  •  NOT  rely  on  side  informaNon  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   4  

Page 5: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Design  Ra/onale  

•  Evidence  of  ROP  AFack  – Reliable  -­‐  adversary  can  not  modify  them  to  evade  detecNon  

– Sound  –  solid  evidence  

•  Timing  of  detecNon  – Event  driven  (NOT  busy  monitoring)  – Non-­‐bypassable  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   5  

Page 6: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Design  Overview    

•  Reliable  and  Solid  evidence  -­‐  ROP  gadget  chain  – Last  Branch  Record  (LBR)    – RunNme  execuNon  flow  

•  Timing  of  checking  – When  the  execuNon  flow  jumps  out  of  the  sliding  window  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   6  

Page 7: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

ROPecker  Architecture  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   7  

Offline  Phase  

App  X    Binary    

Pre-­‐processor  

ROPecker  Kernel  Module  

Run-­‐Nme  Phase    

Kernel    

lib1  

libn  

…  

InstrucNon  &  Gadget    Database  

Apps  App  X  

CPU  ExecuNon    Trace  

Monitor  Window  

IPd   IPs   Code  …   …  

RunNme  Info  

Stack  

…  

Page 8: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Offline  Pre-­‐processing  

•  InstrucNon  Disassembling  – Reliable    

•  Only  disassemble  6  instrucNons  in  a  Nme  (not  the  whole  applicaNon)  

– Efficient  •  Only  do  once  for  each  applicaNon/library  

•  Extracted  instrucNon  informaNon  is  saved  in  database  – Save  runNme  cost  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   8  

Page 9: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Sliding  Window  

•  Refers  to  a  small  porNon  of  code  pages  – Only  code  pages  within  the  window  are  executable  

•  Non-­‐bypassable  – No  enough  gadgets  within  the  window  for  ROP  aFackers  

•  Efficient  – Temporal  and  spaNal  locality  feature    -­‐  sliding  window  could  be  non-­‐con%guous  code  pages  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   9  

Page 10: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Sliding  Window  Update  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   10  

1:    int  helper(int  cmd,char*  in){  2:  log(cmd,  in);  3:  switch(cmd){  4:          case  CMD_START:  5:      start(inputs);  6:      break;  

         .  .  .          }  

start:  …  

helper  …  

log:  …  

Code    

page_a   page_b   page_c  

Sliding  window  has  2  code  pages  

Page 11: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Detec/on  Algorithm  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   11  

ROP  AFack  

Checking  Point  Triggered  

Past  Chain  DetecNon  

Yes  

No  

No  ROP  

ConNnue  The  Original  ExecuNon  Flow  

Future  Chain  DetecNon  

Yes  

No  32

CondiNon  Filtering  

1

Yes  

No  

Page 12: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Condi/on  Filtering  

•  ROPecker  is  able  to  disNnguish  the  excepNons  triggered  by  the  sliding  window  from  others  – PID  – Error  code  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   12  

Present  bit  Read/write  bit  

User/supervisor  bit  Reserved  bit  

NX  bit    

 

Error  code  triggered  by  sliding  window  is  0x15  

   All  other  error  codes  

are  not  0x15  in  the  normal  executions    

Page 13: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Past  and  Future  Chain  Detec/on  

•  Past  execuNon  traces  in  LBR  – LBR  number  is  limited,  e.g.,  16  records  – Filter  out  noise  records  

•  Future  gadget  chain  – Directly  calculate  using  (offline)  generated  database  

•  Reduce  emulaNon  Nmes  

– Seldom  triggered  RunNme  emulaNon  •  Low  performance  overhead  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   13  

Page 14: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Discussions    •  Gadget  chain  threshold  

– The  threshold  is  small,  e.g.,  5  for  Apache      –   Performance  degradaNon  is  limited  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   14  

•  Stack  pivoNng  – ROPecker  (kernel)  is  able  to  know  the  posiNon  of  stack  

Page 15: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Implementa/on  and  Evalua/on  

•  Implemented  on  Linux  (Ubuntu  12.04  with  kernel  3.2.0-­‐29-­‐general-­‐pae)  

•  New  tools  for  offline  processor  – diStorm  +  Perl  +  objdump  +  readelf    

•  Kernel  module  consists  of  7K  SLOC  – RunNme  emulator  (from  Xen)  is  4.4K  SLOC  – Use  NX  mechanism  for  sliding  window  creaNon  – Modify  IDT  for  page  fault  intercepNon  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   15  

Page 16: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Space  Evalua/on  

•  The  databases  for  all  2393  shared  libraries  under  /lib  and  /usr/lib  of  the  Ubuntu  Linux  12.04  distribuNon  is  about  210MB  –   On  average,  the  database  of  each  lib  is  90KB  – Compressed  to  about  19MB  using  bzip2  

•  Each  database  only  has  one  copy  in  memory  – e.g.,  all  protected  processes  share  one  libc  database  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   16  

Page 17: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Performance  Evalua/on  

•  Micro-­‐benchmark  – Past  gadget  chain  detecNon  –  0.07µs  – Future  gadget  chain  detecNon  –  0.91µs  (w/o  emulaNon),    2.61µs  (with  emulaNon)  

•  Macro-­‐benchmark  – SPEC  INT2006  -­‐  2.60%  overhead  on  average    – Bonnie++  -­‐  1.56%  overhead  – Apache  -­‐  0.08%  overhead  on  typical  (4KB)  HTTP  communicaNons  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   17  

Page 18: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Limita/ons    

•  Short  gadget  chain  – e.g.,  one-­‐gadget  ROP  aFack  

•  Long  gadgets  – e.g.,  a  gadget  with  20  instrucNons  

•  Gadget  Gluing  A:ack  – ConstrucNng  a  special  gadget  which  consists  of  two  short  code  sequences  glued  together  by  a  direct  branch  instrucNon  

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   18  

Page 19: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Conclusions    

•  ROPecker  – Efficiently,  transparently  and  effecNvely  defend  against  ROP  aFacks    

– Without  relying  on  any  other  side  informaNon  or  binary  instrumentaNon.  

– Small  space  and  performance  cost  

•  Code  is  available,  please  contact  with          [email protected]    

NDSS  2014   ROPecker:  A  Generic  and  PracNcal  Approach  for  Defending  Against  ROP  AFacks   19  

Page 20: New ROPecker( AGeneric(and(Prac/cal(Approach( … · 2019. 1. 22. · • ROP(aack(is(acodeIreuse(aack(– No(injected(malicious(code(• To(launch(an(ROP(aack(– IdenNfy(intended(gadgets(•

Thanks    Ques/ons?

[email protected]  Yueqiang  Cheng