SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
A critical analysis of Dropbox
software security

Nicolas	
  RUFF	
  
Florian	
  LEDOUX	
  
EADS	
  InnovaPon	
  Works	
  

                                        Applica'on	
  Security	
  Forum	
  -­‐	
  2012	
  
                                                                  Western	
  Switzerland	
  
                                 	
  
                                 7-­‐8	
  novembre	
  2012	
  -­‐	
  Y-­‐Parc	
  /	
  Yverdon-­‐les-­‐Bains	
  
                                 h?ps://www.appsec-­‐forum.ch	
  
2	
  




Agenda	
  
§  Dropbox	
  overview	
  
§  Source	
  quest	
  
§  ConfiguraPon	
  database	
  
§  Network	
  protocols	
  
§  LAN	
  sync	
  protocol	
  
§  Conclusion	
  
3	
  




Bio	
  
§  Nicolas	
  RUFF	
  
    –  Security	
  researcher,	
  hacker,	
  blogger,	
  serial	
  speaker,	
  
       troll	
  herder,	
  happy	
  father	
  &	
  more	
  


§  Florian	
  LEDOUX	
  
    –  Intern	
  @	
  EADS	
  IW	
  
4	
  




Dropbox	
  overview	
  
§  Dropbox:	
  a	
  leader	
  in	
  Cloud	
  backup	
  
    –  Over	
  50	
  million	
  users	
  
    –  EsPmated	
  company	
  value:	
  over	
  $1	
  billion	
  
    –  (Year:	
  2011	
  /	
  Source:	
  Wikipedia)	
  

§  Client	
  so`ware	
  available	
  for	
  
    –  Windows,	
  OS	
  X,	
  Linux,	
  Android,	
  iOS	
  and	
  web	
  browser	
  

§  Lot	
  of	
  compePtors	
  
    –  Google	
  Drive,	
  SkyDrive,	
  iCloud,	
  box.com	
  ...	
  
5	
  




Dropbox	
  overview	
  
§  Dropbox	
  security	
  record	
  (parPal)	
  

    –  March	
  2011	
  
          •  Dropbox	
  client	
  for	
  Smartphones	
  do	
  not	
  make	
  use	
  of	
  SSL/TLS	
  encrypPon	
  
    –  April	
  2011	
  
          •  Derek	
  Newton	
  realized	
  that	
  login/password	
  is	
  useless	
  (if	
  you	
  happen	
  to	
  
             know	
  host_id	
  secret)	
  
    –  June	
  2011	
  
          •  So`ware	
  upgrade	
  issue	
  provided	
  password-­‐free	
  access	
  to	
  all	
  user	
  accounts	
  
             for	
  one	
  day	
  
    –  USENIX	
  2011	
  
          •  "Dark	
  Clouds	
  on	
  the	
  Horizon“	
  
    –  August	
  2012	
  
          •  Stolen	
  password	
  from	
  Dropbox	
  employee	
  lead	
  to	
  massive	
  spam	
  
6	
  




Dropbox	
  overview	
  
§  Why	
  studying	
  Dropbox	
  ?	
  

    –  Dropbox	
  is	
  a	
  leader	
  

    –  No	
  previous	
  work	
  on	
  the	
  effecPve	
  implementaPon	
  

    –  "LAN	
  Sync"	
  protocol	
  rouPnely	
  observed	
  during	
  
       penetraPon	
  tesPng	
  assignments	
  

    –  We	
  are	
  happy	
  Dropbox	
  users	
  too	
  
7	
  




Dropbox	
  overview	
  
§  Further	
  analysis	
  holds	
  true	
  for	
  client	
  versions	
  1.1.x	
  to	
  
    1.5.x	
  

    –  Windows,	
  Linux	
  and	
  OS	
  X	
  clients	
  are	
  mostly	
  wri?en	
  in	
  
       Python	
  
         •  "How	
  Dropbox	
  Did	
  It	
  and	
  How	
  Python	
  Helped"	
  (PyCon	
  2011)	
  


    –  Windows	
  client	
  
         •  Generated	
  using	
  PY2EXE	
  
         •  A	
  ZIP	
  with	
  all	
  PYC	
  files	
  to	
  be	
  found	
  within	
  PE	
  resources	
  
         •  Python	
  2.5	
  interpreter	
  has	
  been	
  slightly	
  customized	
  
Source	
  


             8	
  
9	
  




Source	
  quest	
  
§  Standard	
  PYC	
  (redux)	
  
     –  PYC	
  is	
  Python	
  bytecode	
  
     –  PYO	
  is	
  Python	
  opPmized	
  bytecode	
  
 Bytecode	
  version	
     Timestamp	
               Marshalled	
  bytecode	
  




§  Dropbox	
  PYC	
  
10	
  




Source	
  quest	
  
§  Diffing	
  PYTHON25.DLL	
  with	
  original	
  

     –  53	
  modified	
  funcPons	
  (out	
  of	
  ~4500)	
  
     –  Opcodes	
  have	
  been	
  swapped	
  in	
  PyEval_EvalFrame()	
  
     –  DecrypPon	
  funcPon	
  added	
  in	
  ReadObjectFromString()	
  

§  Which	
  encrypPon	
  algorithm	
  is	
  used	
  ?	
  	
  

     –  0x9e3779b9	
  constant	
  is	
  linked	
  to	
  TEA	
  symmetric	
  encrypPon	
  family	
  
          •  Namely:	
  XXTEA	
  
     –  MT_getnext()	
  /	
  MT_decrypt()	
  funcPons	
  are	
  involved	
  in	
  decrypPon	
  
11	
  




Source	
  quest	
  
§  XXTEA	
  implementaPon	
  
       –  void	
  btea(char	
  *data,	
  uint32	
  len,	
  uint32	
  const	
  key[4])	
  
                                                                                Key	
  seed	
     Block	
  len	
  




§  ReadObjectFromString()	
  
       –  Read	
  1st	
  byte	
  (e.g.	
  0x63	
  =	
  code)	
  
       –  1st	
  DWORD	
  (e.g.	
  0x0479F970)	
  used	
  for	
  key	
  generaPon	
  
       –  2nd	
  DWORD	
  (e.g.	
  0x208e)	
  gives	
  block	
  size	
  

§  Not	
  as	
  easy	
  as	
  it	
  may	
  sounds	
  
       –  Spurious	
  NULL	
  bytes	
  all	
  over	
  the	
  place	
  
12	
  




Source	
  quest	
  
§  Bytecode	
  decompilaPon	
  
    –  PyrePc	
  /	
  unpyc	
  
           •  Targets	
  Python	
  2.5	
  (fails	
  in	
  real	
  life)	
  
    –  Uncompyle2	
  
           •  Targets	
  Python	
  2.7	
  only	
  (works	
  in	
  real	
  life)	
  


§  Our	
  soluPon	
  
    –    Uncompyle2	
  fork	
  
    –    Bytecode	
  translator	
  2.5	
  &	
  2.6	
  ►	
  2.7	
  
    –    Single	
  decompilaPon	
  engine	
  
    –    Kudos	
  to	
  Eloi	
  Vanderbeken	
  

§  h?ps://github.com/Mysterie/uncompyle2	
  
13	
  




Python	
  statements	
  injecPon	
  
§  PYTHON25.DLL	
  is	
  not	
  easy	
  to	
  reach	
  
     –  Anonymously	
  mapped	
  in	
  memory	
  
           •  WinDbg	
  SynthePc	
  Modules	
  FTW	
  J	
  
     –  Not	
  easy	
  to	
  locate	
  import	
  /	
  export	
  tables	
  
     –  Some	
  funcPons	
  like	
  PyRun_File()	
  are	
  nop'ed	
  

§  Yet	
  …	
  
     –  PyRunString()	
  is	
  not	
  patched	
  
     –  Arbitrary	
  Python	
  statements	
  can	
  be	
  run	
  in	
  Dropbox	
  
        context	
  
14	
  




Debug	
  mode(s)	
  
§  Debugging	
  is	
  hard	
  
§  DBDEV	
  environment	
  variable	
  to	
  the	
  rescue	
  

§  Dropbox	
  <=	
  1.1	
  
def is_valid_time_limited_cookie(cookie):
  t_when = int(cookie[:8], 16) ^ 1686035233
  if abs(time.time() - t_when) < 172800:
    if md5.new(cookie[:8] + 'traceme').hexdigest()[:6] == cookie[8:]:
      return True
15	
  




Debug	
  mode(s)	
  


§  Dropbox	
  ≥	
  1.2	
  

IS_DEV_MAGIC = DBDEV and
hashlib.md5(DBDEV).hexdigest().startswith('c3da6009e4')
16	
  




Debug	
  mode(s)	
  
§  DBTRACE	
  can	
  help,	
  too	
  




10.224 | MainThread: Dropbox-win-1.1.45 (2796) starting
10.865 | MainThread: u'host_id' = u'ab75c...
13.509 | MainThread: Opened Dropbox key
32.356 | RTRACE: Sending trace 1327936014 (C:...Dropboxl4f26b5fc)
33.058 | STATUS: Creating named pipe
59.318 | UPLOAD_HASH: Next needed hash:
AUCwQ6iYIfVxGs1f6HjkWZgqcbmWZiTCs6HU8HRykzU
17	
  




Debug	
  mode(s)	
  
§  …	
  and	
  many	
  others	
  
    –  DBMEMPROF,	
  DBCPUPROFILE,	
  DBPROFILE	
  
    –  FAKE_BLOCK	
  
    –  DROPBOX_HOST	
  


§  Who's	
  in	
  charge	
  here?	
  
    –  host	
  =	
  'tarak.corp.dropbox.com‘	
  
    –  Not	
  exposed	
  on	
  the	
  Internet	
  J	
  
18	
  
19	
  




ConfiguraPon	
  database	
  
§  SQLite	
  3	
  database:	
  config.dbx	
  
    –  Dropbox	
  <	
  1.2:	
  easy	
  to	
  dump	
  
    –  Dropbox	
  ≥	
  1.2:	
  "encrypted"	
  SQLite	
  

§  EncrypPon	
  
    –  Not:	
  
         •  h?p://sqlcipher.net/	
  
    –  But	
  rather:	
  
         •  h?p://www.hwaci.com/sw/sqlite/see.html	
  
    –  AcPvaPon	
  password	
  ==	
  license	
  key	
  ==	
  default	
  value	
  J	
  
         •  Namely:	
  7bb07b8d471d642e	
  
20	
  




ConfiguraPon	
  database	
  
§  EncrypPon	
  key	
  is	
  machine-­‐protected	
  

    –  Windows	
  
          •  Seed	
  stored	
  in	
  HKCUSoftwareDropboxksClient
          •  DPAPI	
  encrypPon	
  
    –  Linux	
  
          •  Seed	
  stored	
  in	
  ~/.dropbox/hostkeys
          •  Custom	
  "obfuscator"	
  (reversible	
  encrypPon)	
  
    –  Mac	
  OS	
  X	
  
          •  Seed	
  stored	
  in	
  ~/.dropbox/hostkeys
          •  Custom	
  "obfuscator"	
  based	
  on	
  IOPlatformSerialNumber,	
  
             DAVolumeUUID	
  and	
  more	
  
          •  Kudos	
  to	
  the	
  Mac	
  OS	
  X	
  developer	
  for	
  full	
  API	
  re-­‐implementaPon!	
  
21	
  




ConfiguraPon	
  database	
  
§  EffecPve	
  encrypPon	
  key	
  is	
  PBKDF2(seed)
§  Please	
  use	
  this	
  informaPon	
  for	
  forensics	
  purpose	
  
    only	
  J	
  

§  h?ps://github.com/newso`	
  
USER_HMAC_KEY = 'xd1x14xa5Rx12e_txbdw.7xe6Jxeex9b'
APP_KEY = 'rcx8ct.x8bx82xfcE(x83xf9_5[x8e'
APP_IV = 'xd8x9bCx1fxb6x1dxdex1axfdxa4xb7xf9xf4xb8rx05'
APP_ITER = 1066
USER_KEYLEN = 16
DB_KEYLEN = 16
22	
  




Autoupdate	
  
§  Signed	
  updates	
  




MAGIC = 14401537
VERSION = 3
DIGESTTYPE = 'SHA256'

PUBLICKEY = 'n-----BEGIN RSA PUBLIC KEY-----
nMIIBCAKCAQEAs24msupO4460ViJDTX4qbdqcosjkDKyjW8ZseZ8fm54hXUPwZz7V
nLinFS3M6mjjKnAH81dNb3u3KnKadQ/8eHQXIjvmVPGSGHhCc7PRon30wQZYH/azQna
+ld27xKdzxiB1zK9f2/uzV5sgs7QUhJdcqIpMXMWAyH7MbsU8g+YEXu/
Mz0yZv6nrAHkupNWoddd7+AjEAeKvlKjOM805+pwedjN3FKnAWSWIIzJJZk76loXoboub/RB
nPmN83HNJdmFmDda0AY8qWtgS+DX/xEaipbCvda33ZHt/pIhfwl0Wq8RPN7cdS6DEnW4qbB0qxBdOF/
Wt5JJmGEIXiKHH/udTuIwIBBQ==n-----END RSA PUBLIC KEY-----n'
23	
  




URL	
  generaPon	
  
§  Public	
  link	
  
     –  Generated	
  from	
  "uid"	
  
          •  Ex.	
  h?ps://dl.dropbox.com/u/12345678/toto.pdf	
  


def generate_public_link(self, path):
        path = unicode(path)
        public_root = '%s:/public/' % (self.root_ns,)
        if path.lower().startswith(public_root):
            return self.construct_full_url('/u/%s/%s' % (self.uid,
urllib.quote(path[len(public_root):].encode('utf-8'))),
host_prefix=self._public_host_prefix(), with_locale=False)
        else:
            raise Exception('no public link')
24	
  




URL	
  generaPon	
  
§  Gallery	
  link	
  
    –  Hash	
  generated	
  from	
  user_key	
  +	
  path	
  +	
  uid	
  +	
  depth	
  
         •  Ex.	
  h?ps://www.dropbox.com/gallery/12345678/1/toto?
            h=123456	
  
def generate_gallery_link(self, path, user_key):
  photos_root = '%s:/photos/' % (self.root_ns,)
  if path.lower().startswith(photos_root):
      ns_id, rel_path = path.split(':/', 1)
      tk_path_components = rel_path.split('/')[1:]
      depth = len(tk_path_components)
      hash = md5.new(('%s%s%s%s' % (user_key,
        '/'.join(tk_path_components),
        self.uid,
        depth)).encode('utf-8')).hexdigest()[3:9]
      urlpath = '/gallery/%s/%s/%s' % (self.uid, depth,
urllib.quote(path[len(photos_root):].encode('utf-8')))
      return self.construct_full_url(urlpath, ['h=%s' % (hash,)], with_locale=False)
  else:
      raise Exception("Can't find photos root; (make sure it's converted to our root
namespace first)")
25	
  




URL	
  generaPon	
  
§  Web	
  link	
  
    –  Generated	
  from	
  host_id	
  +	
  hardcoded	
  secret	
  +	
  
       Pmestamp	
  
def launch_dropbox_url(self, url):
  if self._host_id is not None and self.host_int is not None and self._server_time is
not None:
      delta = (get_monotonic_time() - self._monotonic_time) /
get_monotonic_frequency()
      t = self._server_time + int(delta)
      TRACE('Delta monotonic time is %r, computer server time is %r, %r', delta, t,
time.ctime(t))
      query_pieces = ['i=%d' % (self.host_int,),
        't=%d' % (t,),
        'v=%s' % (hashlib.sha1('%ssKeevie4jeeVie9bEen5baRFin9%d' % (self._host_id,
t)).hexdigest(),),
        'url=%s' % (urllib.quote(url, safe=''),)]
      full_url = self.construct_full_url('/tray_login', query_pieces)
  else:
      full_url = self.construct_full_url(path=urllib.quote(url, safe=''))
  self.launch_full_url(full_url)
Network	
  protocols	
  




Source:	
  h?p://www.techeblog.com/index.php/tech-­‐gadget/spaghe€-­‐cabling-­‐cable-­‐management-­‐gone-­‐wrong	
     26	
  
27	
  




Network	
  protocols	
  
§  Network	
  traffic	
  
   –  Fully	
  transported	
  over	
  HTTPS	
  
   –  OpenSSL	
  +	
  nCrypt	
  wrapper	
  
   –  Proper	
  cerPficate	
  checking	
  
       •  Hardcoded	
  CA	
  list	
  
root_certs = '#         Subject: C=ZA, ST=Western Cape, L=Cape
Town, O=Thawte Consulting cc, (…)
-----BEGIN CERTIFICATE-----n
MIIDEzCCAnygAwIBAgIBATA
(…)
L7tdEy8W9ViH0Pdn
-----END CERTIFICATE-----nn'
28	
  




Network	
  protocols	
  
§  Issues	
  

    –  OpenSSL	
  …	
  0.9.8e?	
  	
  
        •  As	
  of	
  DropBox	
  1.4.17	
  
        •  Hello	
  CVE-­‐2011-­‐4109,	
  CVE-­‐2012-­‐2110,	
  and	
  others	
  


    –  nCrypt	
  …	
  completely	
  buggy	
  and	
  unsupported	
  
       so`ware?	
  
        •  h?p://bugs.debian.org/cgi-­‐bin/bugreport.cgi?bug=614051	
  
        •  No	
  patch	
  since	
  2007	
  
29	
  




Network	
  protocols	
  
§  File	
  synchronisaPon:	
  RSYNC	
  protocol	
  

§  File	
  storage:	
  Amazon	
  Cloud	
  S3	
  

§  ImplementaPon	
  details	
  
    –  Blocks	
  of	
  4	
  MB	
  in	
  size	
  
    –  SHA-­‐256	
  of	
  each	
  block	
  
    –  EncrypPon	
  is	
  provided	
  by	
  SSL/TLS	
  only	
  
30	
  




Network	
  protocols	
  
§  Servers	
  of	
  interest	
  
     –    Blockserver:	
  manages	
  4MB	
  blocks	
  
     –    Authserver:	
  user	
  authenPcaPon,	
  so`ware	
  setup	
  
     –    Metaserver:	
  handles	
  informaPon	
  requests	
  about	
  files	
  and	
  directories	
  
     –    Metaexcserver	
  /	
  blockexcserver:	
  handle	
  excepPons	
  
     –    Statserver	
  /	
  no'fyserver:	
  staPsPcs	
  (HTTP)	
  
set_server(ret,       'blockserver', secure=True, timeout=60, **non_exc_kwargs)
set_server(ret,       'metaserver', secure=True, timeout=90, **non_exc_kwargs)
set_server(ret,       'metaexcserver', secure=True, timeout=90, **exc_kwargs)
set_server(ret,       'blockexcserver', secure=True, timeout=90, **exc_kwargs)
set_server(ret,       'statserver', secure=True, timeout=90, **exc_kwargs)
set_server(ret,       'notifyserver', secure=False, timeout=90, **non_exc_kwargs)
31	
  




Network	
  protocols	
  
§  HOST_ID	
  
    –    Unique	
  and	
  forever	
  user	
  idenPfier	
  
    –    128-­‐bit	
  length	
  
    –    Server-­‐side	
  generated	
  on	
  1st	
  installaPon	
  
    –    Not	
  affected	
  by	
  password	
  change	
  
    –    Stored	
  in	
  local	
  configuraPon	
  database	
  

§  HOST_INT	
  
    –  Unique	
  idenPfier	
  per	
  device	
  

§  NS_MAP	
  
    –  User	
  namespace	
  idenPfier	
  
32	
  




Network	
  protocols	
  
33	
  




 Network	
  protocols	
  (Dropship)	
  




h?ps://github.com/driverdan/dropship	
  
34	
  




 Network	
  protocols	
  (Usenix	
  2011)	
  




h?p://www.sba-­‐research.org/2011/06/22/usenix-­‐security-­‐11-­‐dark-­‐clouds-­‐on-­‐the-­‐horizon/	
  
35	
  




LAN	
  sync	
  protocol	
  
§  Local	
  sync	
  between	
  two	
  Dropbox	
  clients	
  
   –  Discovery:	
  UDP/17500	
  broadcasts	
  
   –  Data	
  exchange:	
  TCP/17500	
  


§  Data	
  exchange	
  protocol	
  
   –  Each	
  Dropbox	
  instance	
  can	
  act	
  as	
  a	
  Client	
  or	
  a	
  Server	
  
   –  Client	
  SSL/TLS	
  authenPcaPon	
  
   –  Key	
  pair	
  stored	
  in	
  configuraPon	
  database	
  
36	
  




LAN	
  sync	
  protocol	
  
§  A?acking	
  a	
  client	
  in	
  server	
  mode	
  
    –  Requires	
  a	
  server-­‐known	
  key	
  pair	
  L	
  
37	
  




LAN	
  sync	
  protocol	
  
§  A?acking	
  the	
  client	
  mode	
  
    –  Server	
  cerPficate	
  is	
  not	
  checked	
  J	
  


§  LAN	
  Sync	
  protocol	
  (redux)	
  
    –  HELLO	
  /	
  HOWDY	
  
    –  PING	
  /	
  PONG	
  
    –  HAS	
  /	
  HASREPLY	
  /	
  HASFAIL	
  (+	
  hash)	
  
    –  GET	
  /	
  GETREPLY	
  /	
  GETFAIL	
  (+	
  hash	
  &	
  file	
  content)	
  
ShowPme!	
  




               38	
  
39	
  




Conclusion	
  
§  There	
  used	
  to	
  be	
  criPcal	
  issues	
  in	
  Dropbox	
  design	
  
     –  Most	
  of	
  them	
  are	
  now	
  fixed	
  
     –  So`ware	
  is	
  even	
  pre?y	
  robust	
  

§  Our	
  contribuPon	
  to	
  the	
  "state	
  of	
  the	
  art"	
  
     –  Full	
  Python	
  2.5/2.6/2.7	
  decompilaPon	
  
          •  96%	
  of	
  Python	
  standard	
  library	
  decompiled	
  in	
  original	
  form	
  
     –  DBX	
  decrypPon	
  
          •  Useful	
  for	
  forensics	
  
     –  LAN	
  sync	
  a?acks	
  
          •  DoS	
  against	
  a	
  remote	
  client	
  
          •  Remote	
  monitoring	
  of	
  SHA-­‐256	
  hashes	
  
QuesPons?	
  




                40	
  
41	
  




Merci/Thank	
  you!	
  
§  Contact:	
  
    –  nicolas.ruff(à)eads.net	
  
    –  @newso`	
  

    –  florian.ledoux(à)eads.net	
  
    –  @myst3rie	
  

§  Slides:	
  
    –  h?p://slideshare.net/ASF-­‐WS/presentaPons	
  

Contenu connexe

Plus de Cyber Security Alliance

Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
Cyber Security Alliance
 

Plus de Cyber Security Alliance (20)

Bug Bounty @ Swisscom
Bug Bounty @ SwisscomBug Bounty @ Swisscom
Bug Bounty @ Swisscom
 
Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce it
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacks
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomware
 
Blockchain for Beginners
Blockchain for Beginners Blockchain for Beginners
Blockchain for Beginners
 
Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging apps
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacks
 
Rump : iOS patch diffing
Rump : iOS patch diffingRump : iOS patch diffing
Rump : iOS patch diffing
 
An easy way into your sap systems v3.0
An easy way into your sap systems v3.0An easy way into your sap systems v3.0
An easy way into your sap systems v3.0
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 f
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setup
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Rump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceRump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabrice
 
Operation emmental appsec
Operation emmental appsecOperation emmental appsec
Operation emmental appsec
 

Dernier

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

ASFWS 2012 Analyse de la sécurité Dropbox par Nicolas Ruff / Florian Ledoux

  • 1. A critical analysis of Dropbox software security Nicolas  RUFF   Florian  LEDOUX   EADS  InnovaPon  Works   Applica'on  Security  Forum  -­‐  2012   Western  Switzerland     7-­‐8  novembre  2012  -­‐  Y-­‐Parc  /  Yverdon-­‐les-­‐Bains   h?ps://www.appsec-­‐forum.ch  
  • 2. 2   Agenda   §  Dropbox  overview   §  Source  quest   §  ConfiguraPon  database   §  Network  protocols   §  LAN  sync  protocol   §  Conclusion  
  • 3. 3   Bio   §  Nicolas  RUFF   –  Security  researcher,  hacker,  blogger,  serial  speaker,   troll  herder,  happy  father  &  more   §  Florian  LEDOUX   –  Intern  @  EADS  IW  
  • 4. 4   Dropbox  overview   §  Dropbox:  a  leader  in  Cloud  backup   –  Over  50  million  users   –  EsPmated  company  value:  over  $1  billion   –  (Year:  2011  /  Source:  Wikipedia)   §  Client  so`ware  available  for   –  Windows,  OS  X,  Linux,  Android,  iOS  and  web  browser   §  Lot  of  compePtors   –  Google  Drive,  SkyDrive,  iCloud,  box.com  ...  
  • 5. 5   Dropbox  overview   §  Dropbox  security  record  (parPal)   –  March  2011   •  Dropbox  client  for  Smartphones  do  not  make  use  of  SSL/TLS  encrypPon   –  April  2011   •  Derek  Newton  realized  that  login/password  is  useless  (if  you  happen  to   know  host_id  secret)   –  June  2011   •  So`ware  upgrade  issue  provided  password-­‐free  access  to  all  user  accounts   for  one  day   –  USENIX  2011   •  "Dark  Clouds  on  the  Horizon“   –  August  2012   •  Stolen  password  from  Dropbox  employee  lead  to  massive  spam  
  • 6. 6   Dropbox  overview   §  Why  studying  Dropbox  ?   –  Dropbox  is  a  leader   –  No  previous  work  on  the  effecPve  implementaPon   –  "LAN  Sync"  protocol  rouPnely  observed  during   penetraPon  tesPng  assignments   –  We  are  happy  Dropbox  users  too  
  • 7. 7   Dropbox  overview   §  Further  analysis  holds  true  for  client  versions  1.1.x  to   1.5.x   –  Windows,  Linux  and  OS  X  clients  are  mostly  wri?en  in   Python   •  "How  Dropbox  Did  It  and  How  Python  Helped"  (PyCon  2011)   –  Windows  client   •  Generated  using  PY2EXE   •  A  ZIP  with  all  PYC  files  to  be  found  within  PE  resources   •  Python  2.5  interpreter  has  been  slightly  customized  
  • 8. Source   8  
  • 9. 9   Source  quest   §  Standard  PYC  (redux)   –  PYC  is  Python  bytecode   –  PYO  is  Python  opPmized  bytecode   Bytecode  version   Timestamp   Marshalled  bytecode   §  Dropbox  PYC  
  • 10. 10   Source  quest   §  Diffing  PYTHON25.DLL  with  original   –  53  modified  funcPons  (out  of  ~4500)   –  Opcodes  have  been  swapped  in  PyEval_EvalFrame()   –  DecrypPon  funcPon  added  in  ReadObjectFromString()   §  Which  encrypPon  algorithm  is  used  ?     –  0x9e3779b9  constant  is  linked  to  TEA  symmetric  encrypPon  family   •  Namely:  XXTEA   –  MT_getnext()  /  MT_decrypt()  funcPons  are  involved  in  decrypPon  
  • 11. 11   Source  quest   §  XXTEA  implementaPon   –  void  btea(char  *data,  uint32  len,  uint32  const  key[4])   Key  seed   Block  len   §  ReadObjectFromString()   –  Read  1st  byte  (e.g.  0x63  =  code)   –  1st  DWORD  (e.g.  0x0479F970)  used  for  key  generaPon   –  2nd  DWORD  (e.g.  0x208e)  gives  block  size   §  Not  as  easy  as  it  may  sounds   –  Spurious  NULL  bytes  all  over  the  place  
  • 12. 12   Source  quest   §  Bytecode  decompilaPon   –  PyrePc  /  unpyc   •  Targets  Python  2.5  (fails  in  real  life)   –  Uncompyle2   •  Targets  Python  2.7  only  (works  in  real  life)   §  Our  soluPon   –  Uncompyle2  fork   –  Bytecode  translator  2.5  &  2.6  ►  2.7   –  Single  decompilaPon  engine   –  Kudos  to  Eloi  Vanderbeken   §  h?ps://github.com/Mysterie/uncompyle2  
  • 13. 13   Python  statements  injecPon   §  PYTHON25.DLL  is  not  easy  to  reach   –  Anonymously  mapped  in  memory   •  WinDbg  SynthePc  Modules  FTW  J   –  Not  easy  to  locate  import  /  export  tables   –  Some  funcPons  like  PyRun_File()  are  nop'ed   §  Yet  …   –  PyRunString()  is  not  patched   –  Arbitrary  Python  statements  can  be  run  in  Dropbox   context  
  • 14. 14   Debug  mode(s)   §  Debugging  is  hard   §  DBDEV  environment  variable  to  the  rescue   §  Dropbox  <=  1.1   def is_valid_time_limited_cookie(cookie): t_when = int(cookie[:8], 16) ^ 1686035233 if abs(time.time() - t_when) < 172800: if md5.new(cookie[:8] + 'traceme').hexdigest()[:6] == cookie[8:]: return True
  • 15. 15   Debug  mode(s)   §  Dropbox  ≥  1.2   IS_DEV_MAGIC = DBDEV and hashlib.md5(DBDEV).hexdigest().startswith('c3da6009e4')
  • 16. 16   Debug  mode(s)   §  DBTRACE  can  help,  too   10.224 | MainThread: Dropbox-win-1.1.45 (2796) starting 10.865 | MainThread: u'host_id' = u'ab75c... 13.509 | MainThread: Opened Dropbox key 32.356 | RTRACE: Sending trace 1327936014 (C:...Dropboxl4f26b5fc) 33.058 | STATUS: Creating named pipe 59.318 | UPLOAD_HASH: Next needed hash: AUCwQ6iYIfVxGs1f6HjkWZgqcbmWZiTCs6HU8HRykzU
  • 17. 17   Debug  mode(s)   §  …  and  many  others   –  DBMEMPROF,  DBCPUPROFILE,  DBPROFILE   –  FAKE_BLOCK   –  DROPBOX_HOST   §  Who's  in  charge  here?   –  host  =  'tarak.corp.dropbox.com‘   –  Not  exposed  on  the  Internet  J  
  • 18. 18  
  • 19. 19   ConfiguraPon  database   §  SQLite  3  database:  config.dbx   –  Dropbox  <  1.2:  easy  to  dump   –  Dropbox  ≥  1.2:  "encrypted"  SQLite   §  EncrypPon   –  Not:   •  h?p://sqlcipher.net/   –  But  rather:   •  h?p://www.hwaci.com/sw/sqlite/see.html   –  AcPvaPon  password  ==  license  key  ==  default  value  J   •  Namely:  7bb07b8d471d642e  
  • 20. 20   ConfiguraPon  database   §  EncrypPon  key  is  machine-­‐protected   –  Windows   •  Seed  stored  in  HKCUSoftwareDropboxksClient •  DPAPI  encrypPon   –  Linux   •  Seed  stored  in  ~/.dropbox/hostkeys •  Custom  "obfuscator"  (reversible  encrypPon)   –  Mac  OS  X   •  Seed  stored  in  ~/.dropbox/hostkeys •  Custom  "obfuscator"  based  on  IOPlatformSerialNumber,   DAVolumeUUID  and  more   •  Kudos  to  the  Mac  OS  X  developer  for  full  API  re-­‐implementaPon!  
  • 21. 21   ConfiguraPon  database   §  EffecPve  encrypPon  key  is  PBKDF2(seed) §  Please  use  this  informaPon  for  forensics  purpose   only  J   §  h?ps://github.com/newso`   USER_HMAC_KEY = 'xd1x14xa5Rx12e_txbdw.7xe6Jxeex9b' APP_KEY = 'rcx8ct.x8bx82xfcE(x83xf9_5[x8e' APP_IV = 'xd8x9bCx1fxb6x1dxdex1axfdxa4xb7xf9xf4xb8rx05' APP_ITER = 1066 USER_KEYLEN = 16 DB_KEYLEN = 16
  • 22. 22   Autoupdate   §  Signed  updates   MAGIC = 14401537 VERSION = 3 DIGESTTYPE = 'SHA256' PUBLICKEY = 'n-----BEGIN RSA PUBLIC KEY----- nMIIBCAKCAQEAs24msupO4460ViJDTX4qbdqcosjkDKyjW8ZseZ8fm54hXUPwZz7V nLinFS3M6mjjKnAH81dNb3u3KnKadQ/8eHQXIjvmVPGSGHhCc7PRon30wQZYH/azQna +ld27xKdzxiB1zK9f2/uzV5sgs7QUhJdcqIpMXMWAyH7MbsU8g+YEXu/ Mz0yZv6nrAHkupNWoddd7+AjEAeKvlKjOM805+pwedjN3FKnAWSWIIzJJZk76loXoboub/RB nPmN83HNJdmFmDda0AY8qWtgS+DX/xEaipbCvda33ZHt/pIhfwl0Wq8RPN7cdS6DEnW4qbB0qxBdOF/ Wt5JJmGEIXiKHH/udTuIwIBBQ==n-----END RSA PUBLIC KEY-----n'
  • 23. 23   URL  generaPon   §  Public  link   –  Generated  from  "uid"   •  Ex.  h?ps://dl.dropbox.com/u/12345678/toto.pdf   def generate_public_link(self, path): path = unicode(path) public_root = '%s:/public/' % (self.root_ns,) if path.lower().startswith(public_root): return self.construct_full_url('/u/%s/%s' % (self.uid, urllib.quote(path[len(public_root):].encode('utf-8'))), host_prefix=self._public_host_prefix(), with_locale=False) else: raise Exception('no public link')
  • 24. 24   URL  generaPon   §  Gallery  link   –  Hash  generated  from  user_key  +  path  +  uid  +  depth   •  Ex.  h?ps://www.dropbox.com/gallery/12345678/1/toto? h=123456   def generate_gallery_link(self, path, user_key): photos_root = '%s:/photos/' % (self.root_ns,) if path.lower().startswith(photos_root): ns_id, rel_path = path.split(':/', 1) tk_path_components = rel_path.split('/')[1:] depth = len(tk_path_components) hash = md5.new(('%s%s%s%s' % (user_key, '/'.join(tk_path_components), self.uid, depth)).encode('utf-8')).hexdigest()[3:9] urlpath = '/gallery/%s/%s/%s' % (self.uid, depth, urllib.quote(path[len(photos_root):].encode('utf-8'))) return self.construct_full_url(urlpath, ['h=%s' % (hash,)], with_locale=False) else: raise Exception("Can't find photos root; (make sure it's converted to our root namespace first)")
  • 25. 25   URL  generaPon   §  Web  link   –  Generated  from  host_id  +  hardcoded  secret  +   Pmestamp   def launch_dropbox_url(self, url): if self._host_id is not None and self.host_int is not None and self._server_time is not None: delta = (get_monotonic_time() - self._monotonic_time) / get_monotonic_frequency() t = self._server_time + int(delta) TRACE('Delta monotonic time is %r, computer server time is %r, %r', delta, t, time.ctime(t)) query_pieces = ['i=%d' % (self.host_int,), 't=%d' % (t,), 'v=%s' % (hashlib.sha1('%ssKeevie4jeeVie9bEen5baRFin9%d' % (self._host_id, t)).hexdigest(),), 'url=%s' % (urllib.quote(url, safe=''),)] full_url = self.construct_full_url('/tray_login', query_pieces) else: full_url = self.construct_full_url(path=urllib.quote(url, safe='')) self.launch_full_url(full_url)
  • 26. Network  protocols   Source:  h?p://www.techeblog.com/index.php/tech-­‐gadget/spaghe€-­‐cabling-­‐cable-­‐management-­‐gone-­‐wrong   26  
  • 27. 27   Network  protocols   §  Network  traffic   –  Fully  transported  over  HTTPS   –  OpenSSL  +  nCrypt  wrapper   –  Proper  cerPficate  checking   •  Hardcoded  CA  list   root_certs = '# Subject: C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting cc, (…) -----BEGIN CERTIFICATE-----n MIIDEzCCAnygAwIBAgIBATA (…) L7tdEy8W9ViH0Pdn -----END CERTIFICATE-----nn'
  • 28. 28   Network  protocols   §  Issues   –  OpenSSL  …  0.9.8e?     •  As  of  DropBox  1.4.17   •  Hello  CVE-­‐2011-­‐4109,  CVE-­‐2012-­‐2110,  and  others   –  nCrypt  …  completely  buggy  and  unsupported   so`ware?   •  h?p://bugs.debian.org/cgi-­‐bin/bugreport.cgi?bug=614051   •  No  patch  since  2007  
  • 29. 29   Network  protocols   §  File  synchronisaPon:  RSYNC  protocol   §  File  storage:  Amazon  Cloud  S3   §  ImplementaPon  details   –  Blocks  of  4  MB  in  size   –  SHA-­‐256  of  each  block   –  EncrypPon  is  provided  by  SSL/TLS  only  
  • 30. 30   Network  protocols   §  Servers  of  interest   –  Blockserver:  manages  4MB  blocks   –  Authserver:  user  authenPcaPon,  so`ware  setup   –  Metaserver:  handles  informaPon  requests  about  files  and  directories   –  Metaexcserver  /  blockexcserver:  handle  excepPons   –  Statserver  /  no'fyserver:  staPsPcs  (HTTP)   set_server(ret, 'blockserver', secure=True, timeout=60, **non_exc_kwargs) set_server(ret, 'metaserver', secure=True, timeout=90, **non_exc_kwargs) set_server(ret, 'metaexcserver', secure=True, timeout=90, **exc_kwargs) set_server(ret, 'blockexcserver', secure=True, timeout=90, **exc_kwargs) set_server(ret, 'statserver', secure=True, timeout=90, **exc_kwargs) set_server(ret, 'notifyserver', secure=False, timeout=90, **non_exc_kwargs)
  • 31. 31   Network  protocols   §  HOST_ID   –  Unique  and  forever  user  idenPfier   –  128-­‐bit  length   –  Server-­‐side  generated  on  1st  installaPon   –  Not  affected  by  password  change   –  Stored  in  local  configuraPon  database   §  HOST_INT   –  Unique  idenPfier  per  device   §  NS_MAP   –  User  namespace  idenPfier  
  • 33. 33   Network  protocols  (Dropship)   h?ps://github.com/driverdan/dropship  
  • 34. 34   Network  protocols  (Usenix  2011)   h?p://www.sba-­‐research.org/2011/06/22/usenix-­‐security-­‐11-­‐dark-­‐clouds-­‐on-­‐the-­‐horizon/  
  • 35. 35   LAN  sync  protocol   §  Local  sync  between  two  Dropbox  clients   –  Discovery:  UDP/17500  broadcasts   –  Data  exchange:  TCP/17500   §  Data  exchange  protocol   –  Each  Dropbox  instance  can  act  as  a  Client  or  a  Server   –  Client  SSL/TLS  authenPcaPon   –  Key  pair  stored  in  configuraPon  database  
  • 36. 36   LAN  sync  protocol   §  A?acking  a  client  in  server  mode   –  Requires  a  server-­‐known  key  pair  L  
  • 37. 37   LAN  sync  protocol   §  A?acking  the  client  mode   –  Server  cerPficate  is  not  checked  J   §  LAN  Sync  protocol  (redux)   –  HELLO  /  HOWDY   –  PING  /  PONG   –  HAS  /  HASREPLY  /  HASFAIL  (+  hash)   –  GET  /  GETREPLY  /  GETFAIL  (+  hash  &  file  content)  
  • 38. ShowPme!   38  
  • 39. 39   Conclusion   §  There  used  to  be  criPcal  issues  in  Dropbox  design   –  Most  of  them  are  now  fixed   –  So`ware  is  even  pre?y  robust   §  Our  contribuPon  to  the  "state  of  the  art"   –  Full  Python  2.5/2.6/2.7  decompilaPon   •  96%  of  Python  standard  library  decompiled  in  original  form   –  DBX  decrypPon   •  Useful  for  forensics   –  LAN  sync  a?acks   •  DoS  against  a  remote  client   •  Remote  monitoring  of  SHA-­‐256  hashes  
  • 40. QuesPons?   40  
  • 41. 41   Merci/Thank  you!   §  Contact:   –  nicolas.ruff(à)eads.net   –  @newso`   –  florian.ledoux(à)eads.net   –  @myst3rie   §  Slides:   –  h?p://slideshare.net/ASF-­‐WS/presentaPons