AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn •...

27
AuthScan: Automa-c Extrac-on of Web Authen-ca-on Protocols from Implementa-ons 1 Na-onal University of Singapore 2 Singapore University of Technology and Design 3 Nanyang Technological University Jike Lei 1 Sai Sathyanarayan Venkatraman 1 Jun Sun 2 Jin Song Dong 1

Transcript of AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn •...

Page 1: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

AuthScan:  Automa-c  Extrac-on  of  Web  Authen-ca-on  Protocols  from  Implementa-ons �

1Na-onal  University  of  Singapore  2Singapore  University  of  Technology  and  Design  

3Nanyang  Technological  University�

Jike  Lei1  

Sai  Sathyanarayan  Venkatraman1  Jun  Sun2  

Jin  Song  Dong1  

Page 2: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Web  Authen-ca-on  Schemes  &  Single  Sign-­‐On�

•  Single  Sign-­‐On  (SSO)  –  BrowserID  (Mozilla)  –  Facebook  Connect    

•  250+  Million  users,    2,000,000  websites  

–  OpenID  •  one  billion  users,  50,000  websites  

–  …    

2�Alice�

Iden-ty  Provider  (IDP) �

Service  Provider  (SP) �

e.g.,  �

e.g.,  �Token=Sig(Uname) �

•  Web  Authen-ca-on  

Page 3: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Implementa-ons  Can  have  Bugs!!�

•  Web  Authen-ca-on    –  Password  Guessing    –  Session/Cookie  Stealing    –  …    

•  Harder  in  SSO  implementa-ons  –  Vulnerabili-es  [BlackHat’07,                                          Oakland’12,  CCS’12,USENIX  Security’12]  

3�

IDP�

SP�

Token=Sig(Uname) �User-­‐Agent�

✓✓

Page 4: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Is  Manual  Analysis  Possible? �

•  Manual  analysis  is  imprac-cal    – Closed  source    – Numerous  implementa-ons  

•  OAuth  1.0  &  2.0:  47  implementa-ons  

4�

OAuth    (RFC  5849  &  RFC  6749) �

Sina Weibo �

Page 5: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Can’t  We  Verify  the  Web  Authen-ca-on?  �

•  Previous    protocol  verifica-on:  design-­‐level  protocol  specifica0ons  

5�

It  is  the  IMPLEMENTATION  that  security  relies  on!!�

[CSNT’11]  [SOFSEM’11]   �

[Oakland’12]  [CCS’12]  �

Implementa-on �

Specifica-on �

Page 6: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Our  Solu-on  &  Contribu-ons �

•  Contribu-ons  –  Automa0c  extrac0on  techniques  to  extract  protocol  specifica-ons  –  AuthScan:  an  end-­‐to-­‐end  framework  

–  Find  7  security  flaws  in  the  real-­‐world  implementa-ons �

6�

Page 7: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Examples  #1:  Freshness  Problem  in  BrowserID  Imp �

7�

login �

Token(asser-on) �

token�

{USER,  pubKeyUSER,  IDP}                            ,  {SP}  prvK  IDP    prvKeyUSER  

{USER,  pubKeyUSER,  IDP,  nonce}                            ,  {SP}  prvK  IDP    prvKeyUSER  

•  Missing  Nonce  – May  lead  to  replay  aqacks  

Page 8: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Example  #2:  Logic  Flaw  in  Using  Windows  Live  ID�

•  Using  Publicly-­‐Known  Values  as  Tokens  –  Keep  constant  across  mul-ple  login  sessions  and  the  values  are  

publicly-­‐known  –  e.g.,  email,  publicly-­‐known  id,  hash(email),  etc.  �

8�

•  Flaw  found  in  creden-al  cookies  in  Sina  Weibo�

Uname/pw

d�

Token=msnid �

OAuth  toke

n �

OAuth  token �✓✗  

GET  hqp://www.weibo.com/msn/bind.php  HTTP/1.1  User-­‐Agent:  Mozilla/5.0  Host:  www.weibo.com  Cookie:  msn_cid=412ee98792885346  Connec-on:  Keep-­‐Alive �msn_id  can  be  retrieved  from  

profile  page  on  MSN  space  !!!�

Sina Weibo �

Page 9: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Many  More  Vulnerability  Examples �

•  Guessable  Token  •  Unchecked  Referrer  

–  Leading  to  CSRF  aqack      •  Secret  Token  Leakage  •  Short-­‐length  Token �

9�

Is  there  a  generalized  method  to  detect  all  these  vulnerabili-es?    

Page 10: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Our  Approach �

Page 11: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

AuthScan:  Overview�

11�

Protocol Extraction �

User-­‐Agent�

IDP�

SP�

SP_ID �

IDP  Client �

SP  Client �

SP  Server �

IDP  Server �

U_ID,  pwd�

Token �Token �

Token �

AuthScan�Security  Analyst�

Page 12: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Protocol  Extrac-on  &  Challenge�

•  Extrac-on:  to  infer  protocol  from  these  available  code  and  messages  exchanged    –  Protocol  steps    –  Seman-cs  of  data  element  exchanged  in  each  step    

•  Signature,  cipher  text,  nonce,  etc.    

•  Challenge:  Par-ally  available  implementa-on    –  Par-al  code  (client-­‐side  JavaScript  code)  –  HTTP  messages  exchanged  

•  Insight:  Hybrid  Inference  – Whitebox  Program  Analysis  –  Blackbox  Differen-al  Fuzzing   �

12�

Page 13: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Whitebox  Program  Execu-on  Analysis �

window.addEventListener('message',func-on(event)  {          var  id=extractUser(event.data);          var  idpSign=extractSign(event.data);          var  data=id;          var  idpPubKey=loadPubKey();          if(verify(data,  idpSign,  idpPubKey)){                    {…}});}          else          {…}},false);  

13�

Code  Example   �

Alice  &  ksad381s…nx89Ds �

u,  X�

u  X �

u �K�

X={u}                  �K-­‐1�

u  X � K�

Page 14: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Blackbox  Differen-al  Fuzzing�

•  To  iden-fy  the  rela-ons  between  HTTP  data  

14�

HTTP    GET    uname=  [email protected]  

HTTP    200    token=  2oOs5u2…9erIas  

[email protected]

7aAod5…as09uA�

assoc(uname,  token)�

•  To  iden-fy  the  rela-ons  between  HTTP  data  and  par-cipants  HTTP    200        c_user  =  10299987  

…… �

HTTP    200        c_user  =  10299987  

assoc(uid,  c_user) �

•  To  eliminate  the  redundant  messages  and  data  •  To  iden-ty  long-­‐lived  and  short-­‐length  token   �

Page 15: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

AuthScan:  Overview�

15�

Protocol Extraction �

User-­‐Agent�

IDP�

SP�

SP_ID �

IDP  Client �

SP  Client �

SP  Server �

IDP  Server �

U_ID,  pwd�

Token �Token �

Token �

Protocol Verification �

Back-end Verification Tool

Counter Example �

AuthScan�Security  Analyst�

Page 16: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Aqacker  Models,  Proper-es  &  Assump-ons �

•  Aqacker  models  considered  in  AuthScan  –  Network  Aqacker  – Web  Aqacker  

•  Same-­‐origin  policy,  Referrer,  postMessage    

•  Proper-es  –  Authen-ca-on  

•  Correspondence  [oakland’  93]  –  Secrecy  

•  Assump-ons  –  Correct  Cryptographic  Algorithms  –  Knowledge  of  Par-cipants  

•  Each  one  knows  the  others’  iden-fiers  

16�

Page 17: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

AuthScan:  Overview�

17�

Protocol Extraction �

User-­‐Agent�

IDP�

SP�

SP_ID �

IDP  Client �

SP  Client �

SP  Server �

IDP  Server �

U_ID,  pwd�

Token �Token �

Token �

Protocol Verification �

Back-end Verification Tool

Counterexample �

Attack Confirmation �

AuthScan�Security  Analyst�

Page 18: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Evalua-on �

Page 19: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

AuthScan  Evalua-on   �

•  Implementa-on    –  Implemented  as  a  Firefox  add-­‐

on    –  Uses  ProVerif  as  the  back-­‐end    

•  Setup  –  Test  harness  

•  pre-­‐registered  user  accounts  –  Protocol  principals  &  public  keys  –  Cryptographic  func-ons  

•  Mozilla  jwcrypto  used  in  BrowserID  

19�

•  Evalua-on  Subjects  –  BrowserID  (three  websites)  –  Facebook  Connect  (two  

websites)  –  Windows  Live  ID    

–  Standalone  websites    Millions  of  Users  are  Impacted!  

Page 20: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Vulnerabili-es  Found �

20�

Web  Sites� Deployed  SSO � #Flaws* � Flaw  Type �

myfavoritebeer.com  openphoto.me  developer.mozilla.org�

BrowserID �2(T1,  T2)  2(T1,  T2)  0�

T1  Missing  nonce  in  BrowserID  T2  Unchecked  Referrer  in  SPs                (leading  to  CSRF  aqack)�

ebayclassifieds.com  familybuilder.com�

Facebook  Connect �2(T3,  T4)  1(T3) �

T3  Secret  token  leak  in  FB  connect    T4  Secret  token  leak  in  SP�

Weibo.com� Windows  Live  ID � 1(T5) �T5  Using  Publicly-­‐Known  Values  as  Tokens  

iyermatrimony.com  mee-ngmillionaires.com�

-­‐-­‐-­‐  -­‐-­‐-­‐ �

1(T6)  1(T7) �

T6  Guessable  Token  T7  Short-­‐Length  Token �

*  With  Overlapping�

•  7  real-­‐world  vulnerabili-es    –  6  previously  unknown    

Page 21: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Example  #3:  Secret  Token  Leakage  in  FB  Connect�

21�

Uname/pw

d�

OAuth  token �

•  Flaw  found  in  secret  cookie  in  Facebook  Connect �

www.facebook.com/login.php �

www.facebook.com/dialog/permissions.request �

c_user/xs �

c_user/xs �

•  Secret  Token  Leakage  –  Secret  tokens  are  transmiqed  through  unencrypted  channels  

Page 22: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Example  #4:  Guessable  Token �

22�

•  Guessable  Token  

hqp://www.iyermatrimony.com/login/intermediatelogin.php?                                                              sds=QdR.j/ZJEX./A&                                  sdss=Tf/GpQpvtzuEs&                                  sde=U1ZsU01UZ3dOVE01  

Keep constant�

First 14 characters: keep constant � Incremented by one across accounts whose IDs are consecutive �

Page 23: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Example  #5:  Short-­‐Length  Token �

•  Short-­‐Length  Token �

23�

hqp://app.icontact.com/icp/mmail-­‐mprofile.pl?  r=36958596&l=2601&m=318326&c=752641&s=21DS  

Constant among different users’ sessions �

User ID � Alpha-­‐numeric  string�

(10  +  26)4    Possible  Values    Aqacker:  500  “probes”/  min

Page 24: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Scalability�

Web  Sites�Time(s)  (Excluding  Verifica0on  Time)�

Verifica0on  Time�Fuzzing  Round �

myfavoritebeer.com  openphoto.me  developer.mozilla.org�

113  72  96�

3.0  3.0  3.0�

20  22  28�

ebayclassifieds.com  familybuilder.com�

127  110�

58.7�58.7�

107  77�

Weibo.com� 30� 0.03� 78�

iyermatrimony.com  mee-ngmillionaires.com�

5.33  4.72�

0.04  0.04�

51  30�

24�

Page 25: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Conclusion �

•  AuthScan:  an  end-­‐to-­‐end  framework  to  extract  web  authen-ca-on  protocols  from    their  implementa-ons  –  Hybrid  inference  techniques  for  protocol  extrac-on    –  Found  7  vulnerabili-es  in  real-­‐world  web-­‐sites  

•  The  devil  is  in  the  details!    

25�

&  Take-­‐away�

Page 26: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Reference�•  [Oakland’12]  R.  Wang,  S.  Chen,  and  X.  Wang.    

             Signing  Me  onto  Your  Accounts  through  Facebook  and  Google:  a  Traffic-­‐Guided  Security  Study  of  Commercially  Deployed  Single-­‐Sign-­‐On  Web  Services.  

•  [CCS’  12]  S.T.  Sun,  K.  Beznosov.  

             The  Devil  is  in  the  (Implementa-on)  Details:  An  Empirical  Analysis  of  OAuth  SSO  Systems.    

•  [Usenix  Security’  12]  S.  Juraj,  M.  Andreas,  S.  Jorg,  K.  Marco,  and  J.  Meiko.    

             On  Breaking  SAML:  Be  Whoever  You  Want  to  Be.  

•  [BlackHat’  07]  E.  Tsyrklevich  and  V.  Tsyrklevich.  

 Single  Sign-­‐On  for  the  Internet:  A  Security  Story  

•  [CSNT’11]  S.  Pai,  Y.  Sharma,  S.  Kumar,  R.  M.  Pai,  and  S.  Singh.    

             Formal  verica-on  of  OAuth  2.0  using  Alloy  framework.    •  [SOFSEM’11]  M.  Miculan,  C.  Urban  

 Formal  analysis  of  Facebook  Connect  single  sign-­‐on  authen-ca-on  protocol.    

•  [Oakland’  93]  T.  Y.  C.  Woo  and  S.  S.  Lam.    

 A  Seman-c  Model  for  Authen-ca-on  Protocols.  

26�

Page 27: AuthScan:*Automac*Extrac-on*of*Web* Authen …€¦ · Web*Authen-caon*Schemes*&*Single*SignKOn • SingleSignOn(SSO) – BrowserID*(Mozilla)* – Facebook*Connect* • 250+Million*users,**2,000,000*websites*

Thank  you!�

We  are  hiring!!  Phd  &  Post-­‐doc  in  NUS,  NTU  and  SUTD!  

Contact:  [email protected]

27�