Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cookie Tossing - Methodology

Avatar for szechuen szechuen
August 20, 2012
620

Cookie Tossing - Methodology

A walkthrough of how the Cookie Tossing technique work in bypassing the Double Submit Cookies method

Avatar for szechuen

szechuen

August 20, 2012
Tweet

Transcript

  1. What  can  we  do?   •  From  pr.bank.com,  we  can

     set  a  cookie  with     – name:  csrf_token   – value:  i_swear_this_is_a_nonce   – domain:  .bank.com   •  And  secure.bank.com  would  now  receive  the   cookie  
  2. How  is  this  a  problem?   •  secure.bank.com  can  surely

     differenHate   between  the  cookies  it  sets  and  the  ones  from   pr.bank.com,  no?  
  3. Back  to  our  example  transmission   •  Remember  that  pr.bank.com

     set  a  cookie   for  .bank.com   •  When  user  revisits  (legiHmately  or  otherwise)   secure.bank.com,     – Cookie:     csrf_token=wwssadadba;     csrf_token=  i_swear_this_is_a_nonce;  
  4. Now  do  we  have  a  problem?   •  Hold  on

     there,  cowboy!  Not  just  yet!   •  Web  Frameworks  take  the  first  cookie  value   when  it  needs  to  resolve  mulHple  cookies  with   the  same  name   •  Hence,   – Cookie:     csrf_token=wwssadadba;     csrf_token=  i_swear_this_is_a_nonce;  
  5. Ordering  of  duplicate  cookies  with   different  scope   MSIE

     6   MSIE  7   MSIE  8   FF  2   FF  3   Random   Random   Some  Dropped   Some  Dropped   Most  Specific   First   Safari   Opera   Chrome   Android   Random   Most  Specific   First   Most  Specific   First   By  Age   From  Google  Browser  Security  Handbook,  Part  2   hYp://code.google.com/p/browsersec/wiki/Part2  
  6. This  is  what  we  will  do   •  From  pr.bank.com,

     we  set  a  cookie  with     – name:  csrf_token   – value:  i_swear_this_is_a_nonce   – domain:  .bank.com   – path:  /transfer_payment   •  Hence,  for  secure.bank.com,     – Cookie:     csrf_token=  i_swear_this_is_a_nonce;     csrf_token=wwssadadba;    
  7. Let’s  replay  the  aYack  scenario   This  Hme  with  the

     aYacker   controlling  a  sub-­‐domain  of  the  site  
  8. Bypassing  Double  Submit  Cookies   Web  Server   secure.bank.com  

    Client   CSRF  Nonce   AYacker   pr.bank.com  
  9. Cookies   Client   CSRF  Nonce   Session  ID  

    Form   CSRF  Nonce   Email  Add.   Bypassing  Double  Submit  Cookies   Web  Server   secure.bank.com   AYacker   pr.bank.com  
  10. Cookies   Client   CSRF  Nonce   Session  ID  

    Bypassing  Double  Submit  Cookies   Web  Server   secure.bank.com   AYacker   pr.bank.com  
  11. Cookies   Client   CSRF  Nonce   Session  ID  

    Malicious  Form   Bad  Nonce   [email protected]   Bypassing  Double  Submit  Cookies   Web  Server   secure.bank.com   AYacker   pr.bank.com   Malicious   Cookies   Bad  Nonce  
  12. Cookies   Client   Bad  Nonce   Session  ID  

    Malicious  Form   Bad  Nonce   [email protected]   Bypassing  Double  Submit  Cookies   Web  Server   secure.bank.com   AYacker   pr.bank.com   CSRF  Nonce  
  13. Client   Bypassing  Double  Submit  Cookies   Web  Server  

    secure.bank.com   AYacker   pr.bank.com   Cookies   Bad  Nonce   Session  ID   Malicious  Form   Bad  Nonce   [email protected]   CSRF  Nonce  
  14. Client   Equal?  Yes:  Accept!   Bypassing  Double  Submit  Cookies

      Web  Server   secure.bank.com   AYacker   pr.bank.com   Cookies   Bad  Nonce   Session  ID   Malicious  Form   Bad  Nonce   [email protected]   CSRF  Nonce