News for hackers. Stuff that matters.
Re:OAuth 2.0 and OpenID Redirect Vulnerability by nailer on Friday May 02, 2014 @10:35AM (#7685904)
I'm relatively familiar with oAuth 2, but I don't quite grok this.

So, normally: I, a site that uses oauth to authorize someone Google / Twitter etc account register a redirect URI where people, after authorizing / denying, are sent with a access key.

The vuln is that my redirect URI can be exploited someone to send users onto a different site, with their access key?

How could an attacker manipulate a URL to redirect somewhere else? Content injection? Like some users whose name is a script that changes window.location? Doesn't nearly every templating language explicitly require special stuff like {{{ }}} for unsafe content?

If that's correct, it seems a little overblown. But maybe I'm wrong.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by kordless on Friday May 02, 2014 @11:10AM (#7686137)
> How could an attacker manipulate a URL to redirect somewhere else?

A site begins writing software to OAuth with Facebook. They start by filling out a form on Facebook with app name and the callback URL to their site. They then write a handler on their site for dealing with the callback URL they expect to receive from Facebook after the user approves the connection with their app. However, the week before the company did OAuth integration, there was a ticket opened for 'redirect user to correct page after login' which was implemented with a '?next=http://urlofyourchosing.com/' decorator handler written by the Swedish intern.

The redirect parameter isn't going to be compared by Facebook. Only the base URL is going to be checked to ensure it matches.

Once Oauth integration is complete and tested, the site launches. They get on the front page of HN, Reddit and Mashable and sign up about 100K users in a few weeks. In the meantime, a bad agent discovers the flaw in their login flow and tests the behavior and discovers the ?next redirect 'venerability'. They know the site uses Facebook, so they craft a URL to do OAuth with Facebook, then redirect the user to the attacking site by using the ?next parameter located in the third party's website code. They then use the current bad actor method of propagating their evil URLs and .... profit?

Impact: Any action by the user allowing access to data will, in theory, allow the attacker to view the information they gave the site access to and, possibly, more information than the user originally approved for the site if they accidently chose another security scope. It should be noted that all access by the user to both Facebook and the attacked website will be logged by their respective servers.

I implemented an OAuth2 workflow with Github to an AppEngine project last year, so I'm at least passingly familiar with what goes on under the hood with the flows. Still, I could be missing something here. I might try to hack up a working example to test my theory.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by EGreg on Friday May 02, 2014 @11:36AM (#7686312)
I read all the above and I still don't see how the attacker would "gain access" to the user's info on the platform. How do they get the bearer token?

?next=URL is usually implemented to redirect to the URL, and won't propagate the bearer token off the app to the attacker's site. What Am I missing?

Re:OAuth 2.0 and OpenID Redirect Vulnerability by kordless on Friday May 02, 2014 @08:20PM (#7688977)
Given you implemented it correctly, I would agree with you. A bad implementation would allow for preservation of the URL's parameters ala urllib.urlencode(self.request.params) or similar, which would contain the token.
Re:OAuth 2.0 and OpenID Redirect Vulnerability by gcb0 on Friday May 02, 2014 @11:33AM (#7686292)
This assumes the url that process the ?next request pass the info in a Crossdomain way... Ie get vars or post.

Everyone does cookies or backend storage.

unless you can compromise the target dns, this is impossible to exploit except for very lousy sites... But if they are bad to this point, you probably already have a local shell access

Re:OAuth 2.0 and OpenID Redirect Vulnerability by tomvangoethem on Friday May 02, 2014 @12:46PM (#7686739)
When you are redirected from Facebook - either after clicking "Accept" or in an implicit flow - to the page with the next parameter, and that page redirects to attacker.com, then attacker.com will have access to the referer header†, which contains the access token. Using this access token, an attacker could extract the sensitive information from the victim's Facebook account.

† there are a few exception when referer header isn't shown, e.g. HTTPS->HTTP redirect, but an attacker could make sure that the referer header would be sent for the majority of victims

Re:OAuth 2.0 and OpenID Redirect Vulnerability by gcb0 on Saturday May 03, 2014 @03:46AM (#7690007)
Always assumed the response was via post... It's silly to use get/url for that. Any ad or external library on the page can already see that then.. Everyone logs referer headers. Even using custom fonts directly from Google is already advertising your tokens...
Re:OAuth 2.0 and OpenID Redirect Vulnerability by melville_X on Friday May 02, 2014 @10:41AM (#7685948)
From the Q&A:

> Covert Redirect is based on vulnerability Open Redirect. An open redirect is an application that takes a parameter and redirects a user to the parameter value without any validation (OWASP). So Covert Redirect is an applicaiton that takes a paramter and redirects a user to the parameter value with improper validation. Usually this is the of result of overconfidence of its partnership.

Seems like a known flaw in OAuth2.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by davewhat on Friday May 02, 2014 @10:41AM (#7685942)
The flow does not originate at your site. Your site did not create the redirect URI that is being passed to Google / Twitter in your example.

The URL is generated by a malicious party. The URL constructed (1) sends the user to Google / Twitter for authentication, (2) includes a return URL of your open redirector, and (3) has your open redirect send you on to an evil site.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by nailer on Friday May 02, 2014 @10:53AM (#7686029)
> Your site did not create the redirect URI that is being passed to Google / Twitter in your example.

Sorry, I don't understand this sentence.

The redirect URI is not normally passed to Google / FB / Instagram dynamically, but normally registered with Google / FB / Instagram once, when you set up an app with them (and get a secret key etc).

If someone else registered their own app with their own redirector, they wouldn't have my secret key.

Edit: removed Twitter, they use oAuth 1 which is strange / different / weird.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by icebraining on Friday May 02, 2014 @11:03AM (#7686081)
No, you do pass the URI dynamically, it's a required part of the Access Token Request: http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4....

It's just that with a decent implementation, you should also be required to register it beforehand with the provider.

Re:OAuth 2.0 and OpenID Redirect Vulnerability by vertex-four on Friday May 02, 2014 @11:17AM (#7686181)
Not just a decent implementation; an implementation which meets the spec. This is not a problem with OAuth2, which explicitly requires registration of URIs where the implicit grant type is used, and covers other cases well in the Security Considerations section.
Re:OAuth 2.0 and OpenID Redirect Vulnerability by nailer on Friday May 02, 2014 @04:11PM (#7687849)
That makes a lot of sense: I've only really dealt with oAuth 2, as oAuth 1.0a is vastly more complicated and only Twitter seems to still use it.

Thanks icebraining & vertex-four.