Skip to main content

Open redirect in rfc6749 aka 'The OAuth 2.0 Authorization Framework'

Image result for meme all the things
tl;dr The Internet Bug Bounty rewarded me with a bounty for an Open Redirect in  rfc6749 aka 'The OAuth 2.0 Authorization Framework' .









Here the long version.

The Introduction 

 

Several months ago I did realize that if you want to implement an OAuth Authorization Server and  follow verbatim the OAuth core spec you might end up having an Open Redirect.
Now there is still some debate about this class of vulnerability since often they are relatively benign but not always (as we can see later).
Despite all at that point I notified the OAuth working group. There was some longish discussion but eventually (almost) all in the list agreed that this was somehow an issue (no where near the end of the world :)).

The Issue

 

Section 4.1.2.1 of the OAuth specification says:

   If the request fails due to a missing, invalid, or mismatching
   redirection URI, or if the client identifier is missing or invalid,
   the authorization server SHOULD inform the resource owner of the
   error and MUST NOT automatically redirect the user-agent to the
   invalid redirection URI. 
   If the resource owner denies the access request or if the request
   fails for reasons other than a missing or invalid redirection URI,
   the authorization server informs the client by adding the following
   parameters to the query component of the redirection URI using the...

Now let's assume an attacker:
  • Registers a new client to the victim.com provider.
  • Registers a redirect uri like attacker.com.
Then the attacker can craft a special URI of the form

http://victim.com/authorize?response_type=code&client_id=bc88FitX1298KPj2WS259BBMa9_KCfL3&scope=WRONG_SCOPE&redirect_uri=http://attacker.com

according to Section 4.1.2.1 this should redirect back to attacker.com (without any user interaction, ever...)!!! Here we use the a wrong scope parameter but any reasons other than a missing or invalid redirection URI would had make the trick....
Now according to my dictionary this is an open redirect :p

Some live example of real providers that exhibit this behavior:

A real cool special case is Moves (just click and enjoy :p)

Update: it seems that Facebook doesn't allow anymore redirect to data:text/html (hence the link below is broken now), more to come on this topic... ;)

https://api.moves-app.com/oauth/v1/authorize?response_type=code&client_id=bc88FitX1298KPj2WS259BBMa9_KCfL3&redirect_uri=data%3Atext%2Fhtml%2Ca&state=<script>alert('hi')</script>

As  (almost) usual Google did it right. Namely Google return 400 with the cause of the error..

400. That’s an error.

Error: invalid_scope

Some requested scopes were invalid. {invalid=[l]}


As we will see this is only one of the possible mitigation.

The Vulnerability

 

Now you might argue that this is ONLY an open redirect and there is not much you can do with it right? :)
Well well well ...

All I need is....an open redirect

Sometimes in order to accomplish some sort of attack you need to have an open redirect. This is only one small part of the chain but an essential one. And what can it be better (from the attacker perspective) if an OAuth provider gives you one :D ? If you do not believe me look like Andris Atteka used this very own issue as part of his attack to steal an access token.


Lassie come home (again)

In some of my previous post I have highlighted the importance for an Authorization Server to
use exact matching against registered redirect uri to validate the redirect_uri parameter. 
Indeed John Bradley realized how some attacker can chain the relaxed redirect uri validation with the open redirect described here to steal an access token.
He pointed out a possible attack scenario in the OAuth mailing list thread
You can find more details about this specific attack in the security addendum draft.


The Mitigation

 

John BradleyHannes Tschofenig and me came up with a draft for an OAuth security addendum that should provide better advice to implementers.
The mitigations are described in section 2.3 and they are rather simple, either :


  • Respond with an HTTP 400 (Bad Request) status code. 
  • Perform a redirect to an intermediate URI under the control of the Authorization Server to clear referer information 
As usual comments are welcome....

Comments

Yatika Dhingra said…
This comment has been removed by a blog administrator.

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…

Cross-origin brute-forcing of Github SAML and 2FA recovery codes

Yesterday while reading my Twitter stream I found this interesting article about  downloading GitHub SSO bypass codes. Same as Yasin Soliman I was invited to a Github pre-release of the organisation SAML single sign-on (SSO) private program. And same as him I found an issue in the same endpoint. So I thought to write a quick blog post about it. Github already published a tl;dr about this,



 I will try to fill the blanks here.

As mentioned by Yasin, Github offers an endpoint where privileged users can recover bypass codes. These recovery codes were accessible for download as plaintext and had the content-type as text/plain, something like:



What immediately caught my attention was that the format of the code forms (with some exceptions) a valid JavaScript file with lines in the format of XXXXX-XXXXX, ten hex digits separated by a hyphen. This is interpreted in JavaScript as the subtraction of two variables! This remember an old blog post of mine where I could possibly exfiltrate informa…