43
Mactans: Injec,ng Malware into iOS Devices via Malicious Chargers Billy Lau Yeongjin Jang Chengyu Song 1

Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Mactans:  Injec,ng  Malware  into  iOS  Devices  via  Malicious  Chargers  

Billy  Lau  Yeongjin  Jang  

Chengyu  Song  

1  

Page 2: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Agenda  

•  iOS  Security  •  Mactans  

•  Discussion  

2  

Page 3: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

IOS  SECURITY  an  overview  of  

3  

Page 4: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Apple  App  Store  

•  The  walled  garden  model  – Acts  as  plaHorm  to  publish  apps  •  The  only  place  to  purchase/download  apps  

– Completely  controlled  by  Apple  •  All  apps  must  be  reviewed  by  Apple  before  release  •  A  released  app  can  be  removed  from  the  store  if  it  violates  policy  

4  

Page 5: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Code  Signing  in  iOS  

•  Enforces  the  integrity  of  the  boot  chain  and  walled  garden  model  – Only  correctly  signed  apps  can  be  installed  and  executed  

•  Signing  En,,es  – Apple  App  Store  –  iOS  developers  

5  

Page 6: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

App  Review  

•  APempts  to  determine  whether  the  submiPed  app  complies  with  the  rules  

•  What  are  the  rules?  – Largely  empirical  •  Apps  that  make  use  of  private  APIs  are  rejected  and  banned  

– Changing  regularly  •  What  happens  during  app  review?  – Sta,c  analysis  and  some  manual  tes,ng  (we  think)  

6  

Page 7: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

iOS  Sandbox  

•  Process  isola,on  –  A  sandboxed  process  cannot  read  other  processes’  memory  

–  Also  cannot  talk  to  other  processes  using  tradi,onal  IPC-­‐like  APIs  

•  Filesystem  isola,on  –  Sandboxed  app  can  only  read/write  to  its  own  filesystem  

•  Can  also  read  (but  not  write  to)  some  public  files  

•  En,tlement  check  –  For  some  opera,ons  (e.g.,  change  passcode),  iOS  enforces  app  En,tlements  

7  

Page 8: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Walled  Garden  Effec,veness  

•  The  walled  garden  model  is  assumed  to  be  secure  – All  apps  are  carefully  vePed  prior  to  release  and  thus  safe  •  Right?  

•  Compared  to  Android,  almost  no  in-­‐the-­‐wild  malware  instances  for  iOS  

8  

Page 9: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

MACTANS  a  step-­‐by-­‐step  introduc,on  to  

9  

Page 10: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Mactans  Concept  

•  Not  a  jailbreak  – Does  not  require  a  jailbroken  device  

•  Automa,c  – Simply  connec,ng  the  device  is  enough    

•  Stealthy  – There  are  no  visible  clues  

•  Powerful  – Does  malicious  things  other  apps  cannot  do  

10  

Page 11: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Anatomy  of  a  Mactans  Charger  

11  

Page 12: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Form  Factor  Alterna,ves  

•  Could  be  much  smaller…  

12  

Page 13: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Mactans  Overview  

1.  Obtain  device  UDID    2.  Pair  with  device  3.  Generate  and  install  provisioning  profile  4.  Install  malicious  app  

13  

Page 14: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Universal  Device  Iden,fier  (UDID)  •  A  40  digit  hexadecimal  iden,fier  unique  to  a  device  

•  Obtaining  device  UDID  is  trivial  via  USB  connec,on  

14  

Page 15: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Pair  With  Device  

•  Once  an  iOS  device  is  connected  via  USB,  Mactans  will  try  to  pair  with  it  

•  Mactans  leverages  a  conceptual  iOS  pairing  trust  assump,on  – Device  cannot  reject  pairing  request  – Device  can  be  paired  without  user’s  consent  while  it  is  passcode-­‐unlocked  •  Pairing  can  occur  if  device  is  unlocked  at  any  ,me  (even  briefly)  

– Once  paired,  exploita,on  is  possible  regardless  of  whether  or  not  device  is  locked  

15  

Page 16: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Pair  With  Device  Cont’d  

•  Many  opera,ons  can  be  performed  via  USB  – Obtain  device  informa,on  (e.g.,  UDID,  serial  number)  

–  Install  and  remove  apps  and  provisioning  profiles  

– Backup  and  restore,  firmware  reset  (ipsw)  – Debugging  

•  Mactans  can  be  used  to  perform  these  func,ons  

16  

Page 17: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Provisioning  Profile  Details  

•  Types  of  provisioning  profiles  –  Individual  – Enterprise  

•  Requirements  for  Individual  profile  – Ac,ve  developer’s  license  – Device  UDID  –  Internet  connec,on  

17  

Page 18: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Provisioning  Profile  Details  Cont’d  

•  Allows  devices  to  run  apps  signed  by  a  non-­‐Apple  en,ty  –  Provisioning  profile  must  be  signed  by  Apple  •  For  enterprises  to  distribute  in-­‐house  apps  

•  For  individual  developers  to  perform  beta  tes,ng  

–  Provisioning  profile  must  match  device  and  app  

18  

Page 19: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Provisioning  Profile  Details  

•  A  device  must  be  registered  to  run  a  developer’s  app  –  Individual  developer  license  allows  up  to  100  devices  •  Cannot  remove  devices  once  registered  

– UDID  registra,on  via  developer.apple.com

19  

Page 20: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Genera,ng  a  Provisioning  Profile  

•  A  Mactans  charger  must  add  a  UDID  to  a  provisioning  profile  over  the  Internet  – How?  

•  Use  available  Internet  connec,on  – A  Mactans  charger  has  a  built-­‐in  Wi-­‐Fi  antenna  –  Can  also  be  equipped  with  SIM  card  module  for  cellular  data  connec,on  

•  Crea,on  via  Apple’s  website  is  fully  automatable  –  Submit  UDID,  check  for  and  receive  generated  profile  

20  

Page 21: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Genera,ng  a  Provisioning  Profile  

•  Can  be  easily  automated  by  browser  automa,on  tools  –  No  CAPTCHA  

21  

Page 22: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Installing  an  App  

•  Once  obtained,  a  provisioning  profile  can  be  installed  without  user’s  consent  (or  knowledge)  – Apps  owned  by  provisioning  profile  owner  can  then  be  installed  via  USB  

•  Ajer  profile  installa,on,  arbitrary  apps  can  be  installed  and  executed  

•  Next  steps  – Hide  app  to  prevent  unwanted  dele,on  –  Circumvent  app  run,me  restric,ons  (i.e.,  via  misuse  of  private  APIs)  

22  

Page 23: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Hiding  an  App  

•  There  are  some  hidden  apps  on  the  stock  iPhone  –  /Applica,ons/DemoApp.app  –  /Applica,ons/FieldTest.app  

•  Info.plist  for  these  apps  reveals  a  common  field  

•  This  property  hides  the  app  on  the  main  screen  and  in  the  task  manager  

23  

Page 24: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Hidden  App  Capabili,es  

•  iOS  background  execu,on  – App  can  run  without  user’s  knowledge  –  iOS  limits  background  execu,on  to  10  minutes  – Limit  can  be  extended  by  several  methods  •  Terminate  and  restart  before  10  minute  deadline  

•  Register  as  VoIP  app  and  setKeepAliveTimeout:600  

– With  these  methods,  app  can  effec,vely  run  indefinitely  

24  

Page 25: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Hidden  App  Capabili,es  Cont’d  

•  Example:  Taking  screen  shots  – Using  a  Private  API  call,  a  background  app  can  take  a  screenshot  of  current  ‘foreground’  screen  

25  

Page 26: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Hidden  App  Capabili,es  Cont’d  

•  Example:  Simula,ng  screen/buPon  presses  – Xcode  instrumenta,on  •  App  tes,ng  can  be  automated  

– Simula,on  can  also  be  done  outside  Xcode  

– DeveloperDisk  •  Has  UIAutoma,on.framework  •  Try  dlopen(),  call  APIs  there  

26  

Page 27: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

iOS  Trojan  Horse  

•  Surrep,,ously  replace  exis,ng  app  with  Trojan  – Obtain  a  set  of  original  apps  (Facebook,  Skype)  –  Repackage  apps  with  Info.plist  that  has  SBAppTags/hidden  property  

–  Sign  app  and  Info.plist  with  aPacker-­‐owned  developer  key  and  load  onto  Mactans  charger  

– Ajer  pairing  •  Replace  original  app  with  repackaged,  hidden  version  •  Install  new,  malicious  app  with  icon  of  replaced  app  •  When  launched,  new  app  performs  malicious  ac,ons,  then  executes  repackaged  (hidden)  app  

27  

Page 28: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Trojan  Horse  Workflow  

Main  Screen  Shows  Trojan   User  Launches  Trojan   Trojan  Launches  Real,    Hidden  App  

28  

Page 29: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

APack  Scenarios  

•  General  – Use  enterprise  provisioning  profile  to  setup  public  charging  sta,ons  (e.g.,  at  airports,  libraries)  

•  Targeted  – Exchange  or  provide  charger  to  target  – Use  a  priori  knowledge  to  selec,vely  modify  environment  (e.g.,  specific  airplane  seat,  hotel  room)  

29  

Page 30: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

DISCUSSION  

30  

Page 31: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Problem  #1  

•  Incorrect  trust  model  for  pairing  

– Any  host  is  implicitly  trusted  if  the  phone  is  not  passcode  protected  

– Once  pairing  is  established,  it  is  permanent  

31  

Page 32: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Fix  for  Problem  #1  

32  

•  Use  explicit  authoriza,on  – Coming  to  iOS  7  

•  Trusted  host  management  – Synonymous  with  Wi-­‐Fi  management  

Page 33: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Problem  #2  

•  No  visual  cues  to  differen,ate  a  charger  versus  a  compu,ng  device  –  iOS  only  has  an  indicator  for  synchroniza,on,  and  only  shows  that  indicator  during  synchroniza,on  

33  

Page 34: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Fix  for  Problem  #2  

•  Visual  indicator  to  differen,ate  charge  mode  and  pair  mode  – Fix  for  Problem  #1  also  fixes  this  problem  – Android  generates  a  no,fica,on  when  the  phone  is  connected  to  a  host  and  always  shows  the  indicator  

34  

Page 35: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Problem  #3  

•  Provisioning  profile  abuse  – Apple  pays  lots  of  aPen,on  to  app  signing,  but  liPle  aPen,on  to  provisioning  profile  signing  

35  

Page 36: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Fix  for  Problem  #3  

•  Add  procedures  to  prevent  provisioning  profile  genera,on  – Use  CAPTCHA  –  Implement  mechanisms  to  detect  suspicious  developer  ac,vity  

36  

Page 37: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Problem  #4  

•  Over-­‐privileged  default  capabili,es  for  USB  – Obtain  device  informa,on  (e.g.,  UDID,  serial  number)  

–  Install  and  remove  apps  and  provisioning  profiles  

– Backup  and  restore,  firmware  reset  (ipsw)  – Debugging  

37  

Page 38: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Fix  for  Problem  #4  

•  Tighten  default  USB  connec,on  seqngs  – Reduce  default  connec,on  mode  privileges  

– Require  explicit  authoriza,on  for  provisioning  profile  installa,on  

38  

Page 39: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Problem  #5  

•  Third  party  hidden  apps  considered  harmful  – Few  or  no  legi,mate  uses  

– High  abuse  poten,al  

39  

Page 40: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Fix  for  Problem  #5  

•  Restrict  the  ability  to  set  hidden  property  – Only  allow  apps  developed  by  Apple  to  use  this  property  

40  

Page 41: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

One  more  thing  …  

•  You  do  not  need  a  malicious  charger  to  bypass  the  protec,ons  of  the  walled  garden  model  –  Jekyll  on  iOS:  When  Benign  Apps  Become  Evil.  Tielei  Wang,  Kangjie  Lu,  Long  Lu,  Simon  Chung,  and  Wenke  Lee,  Georgia  Ins,tute  of  Technology.  

– To  appear  in  proceedings  of  the  2013  USENIX  Security  Conference,  August  14-­‐16,  2013.  

41  

Page 42: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Please  fill  out  your    feedback  forms.  

42  

Page 43: Mactans: Injecting Malware into iOS Devices via …...CodeSigningin iOS(• Enforces(the(integrity(of(the(bootchain(and(walled(garden(model(– Only(correctly(signed(apps(can(be(installed(and(executedApp(Review

Ques,ons?  

43