Skip to main content

All your Paypal OAuth tokens belong to me - localhost for the win

tl;dr  I was able to hijack the OAuth tokens of EVERY Paypal OAuth application with a really simple trick.

Introduction

If you have been following this blog you might have got tired of how many times  I have stressed out the importance of the redirect_uri parameter in the OAuth flow.
This simple parameter might be source of many headaches for any maintainer of OAuth installations being it a client or a server.
Accepting the risk of repeating myself here is two simple suggestions that may help you stay away from troubles (you can always skip this part and going directly to the Paypal Vulnerability section):

If you are building an OAuth client,  

Thou shall register a redirect_uri as much as specific as you can


i.e. if your OAuth client callback is https://yourouauthclient.com/oauth/oauthprovider/callback then

  • DO register https://yourouauthclient.com/oauth/oauthprovider/callback 
  • NOT JUST https://yourouauthclient.com/ or https://yourouauthclient.com/oauth
If you are still not convinced here is how I hacked Google leveraging this mistake.

Second suggestion is

The ONLY safe validation
method for redirect_uri the
authorization server should
adopt is exact matching


Although other methods offer client developers desirable flexibility in managing their application’s deployment, they are exploitable.
From “OAuth 2 In Action” by Justin Richer and Antonio Sanso, Copyrights 2016
Again here you can find examples of providers that were vulnerable to this attack

Paypal Vulnerability

So after this long premise the legitimate question is what was wrong with Paypal ?
Basically like many online internet services Paypal offers the option to register your own Paypal application via a Dashboard. So far so good :). The better news (for Paypal) is that they actually employs an exact matching policy for redirect_uri  :)
So what was wrong ?
While testing my own OAuth client I have noticed something a bit fishy. The easier way to describe it is using an OAuth application from Paypal itself (remember the vulnerability I found is universal aka worked with every client!). Basically Paypal has setup a Demo Paypal application to showcases their OAuth functionalities. The initial OAuth request looked like:


https://www.paypal.com/signin/authorize?client_id=AdcKahCXxhLAuoIeOotpvizsVOX5k2A0VZGHxZnQHoo1Ap9ChOV0XqPdZXQt&response_type=code&scope=openid%20profile%20email%20address%20phone%20https://uri.paypal.com/services/paypalattributes%20https://uri.paypal.com/services/paypalattributes/business%20https://uri.paypal.com/services/expresscheckout&redirect_uri=https://demo.paypal.com/loginsuccessful&nonce=&newUI=Y
 
As you can see the registered redirect_uri for this application is https://demo.paypal.com/loginsuccessful

What I have found out is that the Paypal Authorization Server was also accepting localhost as redirect_uri. So

https://www.paypal.com/signin/authorize?client_id=AdcKahCXxhLAuoIeOotpvizsVOX5k2A0VZGHxZnQHoo1Ap9ChOV0XqPdZXQt&response_type=code&scope=openid%20profile%20email%20address%20phone%20https://uri.paypal.com/services/paypalattributes%20https://uri.paypal.com/services/paypalattributes/business%20https://uri.paypal.com/services/expresscheckout&redirect_uri=https://localhost&nonce=&newUI=Y

was still a valid request and the authorization code was then delivered back to localhost .
Cute right? But still not a vulnerability :(
Well the next natural step was to create a DNS entry for my website looking lke http://localhost.intothesymmetry.com/ and try:

https://www.paypal.com/signin/authorize?client_id=AdcKahCXxhLAuoIeOotpvizsVOX5k2A0VZGHxZnQHoo1Ap9ChOV0XqPdZXQt&response_type=code&scope=openid%20profile%20email%20address%20phone%20https://uri.paypal.com/services/paypalattributes%20https://uri.paypal.com/services/paypalattributes/business%20https://uri.paypal.com/services/expresscheckout&redirect_uri=http://localhost.intothesymmetry.com/&nonce=&newUI=Y

and you know what? BINGO :


So it really looks like that even if Paypal did actually performed exact matching validation, localhost was a magic word and it override the validation completely!!!
Worth repeating is this vulnerability worked for any Paypal OAuth client  hence was Universal making my initial claim

All your Paypal tokens belong to me - localhost for the win  

not so crazy anymore.
For more follow me on Twitter.

Disclosure timeline

08-09-2016 - Reported to Paypal security team.
26-09-2016 - Paypal replied this is not a vulnerability!!
26-09-2016 - I replied to Paypal saying ok no problem. Are you sure you do not want to give an extra look into it ?
28-09-2016 - Paypal replied the will give another try.
07-11-2016 - Paypal fixed the issue (bounty awarded)
28 -11-2016 - Public disclosure. 

Acknowledgement

I would like to thank the Paypal Security team for the constant and quick support.

Comments

Thuan said…
Hi Sanso,
Thank you for the blog post. For OAuth 2.0 newbie guys like me, could you please explain the vulnerability a little bit more details? For example, am I right that in order to steal a token of a user, you have to trick him to access Paypal using an authorize request whose redirect UI is set to your own localhost.xxx site? And it is the code flow which is used, so in order to steal a token, don't you need to know client secret to exchange the code for a token?
Thank you :)
Thuan.
And it's in the spec...

From RFC 6749 : The redirection endpoint URI MUST be an absolute URI as defined by
[RFC3986] Section 4.3.

It's a MUST, damn it!
Ron Aaron said…
Very interesting and informative, thank you! I'll have to think more about this for my 8th 'oauth' library.

Popular posts from this blog

Slack SAML authentication bypass

tl;dr  I found a severe issue in the Slack's SAML implementation that allowed me to bypass the authentication. This has now been solved by Slack.
Introduction IMHO the rule #1 of any bug hunter (note I do not consider myself one of them since I do this really sporadically) is to have a good RSS feed list.  In the course of the last years I built a pretty decent one and I try to follow other security experts trying to "steal" some useful tricks. There are many experts in different fields of the security panorama and too many to quote them here (maybe another post). But one of the leading expert (that I follow) on SAML is by far Ioannis Kakavas. Indeed he was able in the last years to find serious vulnerability in the SAML implementation of Microsoft and Github. Usually I am more an "OAuth guy" but since both, SAML and OAuth, are nothing else that grandchildren of Kerberos learning SAML has been in my todo list for long time. The Github incident gave me the final…

Bug bounty left over (and rant) Part III (Google and Twitter)

tl;dr in this blog post I am going to talk about some bug bounty left over with a little rant.

Here you can find bug bounty left over part I and II
Here you can find bug bounty rant part I and II
Introduction In one of my previous post I was saying that: 

"The rule #1 of any bug hunter... is to have a good RSS feed list."
Well well well allow me in this post to state rule #2 (IMHO)

"The rule #2 of any bug hunter is to DO NOT be to fussy with 'food' specifically with left over"

aka even if the most experience bug hunter was there (and it definitely was my case here, given the fact we are talking about no one less than filedescriptor) do not assume that all the vulnerabilities have been found! So if you want some examples here we go.
Part I - GoogleI have the privilege to receive from time to time Google Vulnerability Research Grant. One of the last I received had many target options to choose from, but one in particular caught my attention, namely Google Issue T…

OpenSSL Key Recovery Attack on DH small subgroups (CVE-2016-0701)

Usual Mandatory Disclaimer: IANAC (I am not a cryptographer) so I might likely end up writing a bunch of mistakes in this blog post...

tl;dr The OpenSSL 1.0.2 releases suffer from a Key Recovery Attack on DH small subgroups. This issue got assigned CVE-2016-0701 with a severity of High and OpenSSL 1.0.2 users should upgrade to 1.0.2f. If an application is using DH configured with parameters based on primes that are not "safe" or not Lim-Lee (as the one in RFC 5114) and either Static DH ciphersuites are used or DHE ciphersuites with the default OpenSSL configuration (in particular SSL_OP_SINGLE_DH_USE is not set) then is vulnerable to this attack.  It is believed that many popular applications (e.g. Apache mod_ssl) do set the  SSL_OP_SINGLE_DH_USE option and would therefore not be at risk (for DHE ciphersuites), they still might be for Static DH ciphersuites.
Introduction So if you are still here it means you wanna know more. And here is the thing. In my last blog post I was …