Search This Blog

Holy redirect_uri Batman!

If you bought the book I have been writing with Justin Richer namely OAuth 2 in Actionyou might have noticed that we will never got tired to stress out how much important the redirect_uri is in the OAuth 2 universe.

Failing to understand this (rather simple) concept might lead to disasters. The redirect_uri is really central in the two most common OAuth flows (authorization code and implicit grant). I have blogged about redirect_uri related vulnerability severaltimes and both in OAuth client and OAuth server context.

Developing an OAuth client is notoriously easier to develop compare to the server counter part.

Said that the OAuth client implementer should still take care and master some concepts.

If I would be limited to give a single warning for OAuth client implementer this would be

If you are building an OAuth client,

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

or simply less formally "The registered redirect_uri must be as specific as it can be".

If you wonder yourself why and you do not want to buy our book :p give a read at this blog post I wrote some time ago. This blog post describes a vulnerability I found in an integration between Google+ and Microsoft Live.

In another blog post I described a quasi-vulnerability found in an integration between Google and Github. In that case Google was good enough to prevent the leakage of the authorization code since they cleaned the code part of the URI (namely the authorization code) before redirecting.

It turned out that Google changed the domain name (from console.developers.google.com to console.cloud.google.com)while offering the same service that leaded to them registering a new OAuth client in Github and consequently a new redirect_uri. And guess what? Well they did the same mistake again as for the registered redirected_uri was not specific enough and this time this might have led to an authorization code leakage. Here the details (I will spare the same details about Github loose redirect_uri validation, for a refresh here, but in a nutshell Github doesn't use exact matching for redirect_uri):

Google registered in Github a new OAuth client (namely 70087bd6f8a55ecca2a1) with a registered redirect_uri that is too open: https://console.cloud.google.com/

An attacker might forge a URI like https://github.com/login/oauth/authorize?client_id=70087bd6f8a55ecca2a1&amp;redirect_uri=https%3A%2F%2Fconsole.cloud.google.com%2Fstart%2Fappengine%3Fproject%3Dantoniosanso&amp;response_type=code&amp;scope=repo+user:email&amp;state=AFE_nuMqEhmFe6MswLJdRX785yLQSyscMQ

The victim, clicking on the link, ends up to https://console.cloud.google.com/start/appengine?code=09a8363e37f1197dc5ad&amp;project=antoniosanso&amp;state=AFE_nuMqEhmFe6MswLJdRX785yLQSyscMQ&amp;authuser=0 that contained the authorization code. N.B. Github adopts the TOFU (Trust On First Use) approach for OAuth application.

This page contains a link to a page controller by the attacker namely antoniosanso.appspot.com

What Google did in order to not leak the Referrer (that would contain the code parameter with the authorization code: 09a8363e37f1197dc5ad ) is to add &lt;a rel="noreferrer target="_blank" &gt; that works well but is not supported by Internet Explorer (IE). In IE if the victim clicks that link it will leak the authorization code via the Referrer.

What I suggested to Google via the Vulnerability Reward Program (VRP) is to register a more specific redirect_uri a lâ https://console.cloud.google.com/project/. This will kill the attack also for the IE users.

One last note, thanks to the fact the authorization code grant flow is safer than the implicit grant flow (not even supported by Github) this attack fails to gain a valid access token (even if the authorization code might leak), this due to:

without the knowledge of the client_secret the attacker can trade the stolen authorization code for an access token.

...ensure that the "redirect_uri" parameter is present if the
"redirect_uri" parameter was included in the initial authorization
request as described in Section 4.1.1, and if included ensure that their values are identical.

I would also take the chance to thank once more the Goolge Security team. Kudos.

Popular posts from this blog

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…

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 IIIntroduction
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…