































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

Now there is still some debate about this class of vulnerability since often they are

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...

Registers a new client to the victim.com provider.

provider. Registers a redirect uri like attacker.com.

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

400. That’s an error.



Error: invalid_scope



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

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

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 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 anone. And what can it be better (from the attacker perspective) if angives 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

relaxed redirect uri validation with the open redirect described here to steal an access token. John Bradley realized how some attacker can chain thewith 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

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

tl;drrelatively benign but not always (as we can see later).Now let's assume anThen the attacker can craft a special URI of the formaccording tothis 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 tothis is an open redirect :pSome live example of real providers that exhibit this behavior:A real cool special case is(just click and enjoy :p)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... ;)As (almost) usualdid it right. Namely Google return 400 with the cause of the error..As we will see this is only one of the possible mitigation.IndeedAs usual comments are welcome....