May 022014

Headlines are flying around this morning that a “serious security flaw” (now dubbed “Covert Redirect”) has been discovered in OAuth and OpenID, which could be exploited by malicious sites to capture user’s personal data. Furthermore, the “reporting” includes comments from major auth providers (Google, Microsoft, Facebook) to the effect of “we can’t fix this”.


This is not a vulnerability of OAuth itself. The exploit requires the use of an open redirect on your client web site. If you have a URL on your web site that blindly redirects the browser to whatever URL is encoded in the parameters AND you forward URL query params to the redirected page as well, then you have a massive security hole in your web site that can be exploited to capture user personal data and control of the user’s account on your site.  This open redirect exploit is not specific to OAuth; an open redirect can be leveraged to exploit a wide variety of services. Open redirects have been well known as a Very Bad Idea for decades.


  1. Don’t expose an open redirect on your web server  (duh!)
  2. Or if you do expose a redirect endpoint, restrict the destination URL to your own domain(s).
  3. If you must redirect to arbitrary 3rd party domains (really? why?), at least strip away the query params.


 Passive federated authentication usually involves a web site ( making a login request to an authentication site (google,com,, etc). The auth site prompts the user to log in to the auth provider’s domain (, etc), and then issues an auth code or access token to the original web site ( This auth code is passed from the auth provider to the original web site by redirecting the browser to a url on the original web site. The auth code is usually passed as a parameter in the URL query of the redirect.

 Most auth providers will only redirect to a URL with a domain name that is preset in the client web site’s configuration data with that provider. This is to prevent the auth provider from being used as an open redirect.  Google, Microsoft, etc, do the right thing.

Note: Facebook supports redirect URL whitelisting in their app configuration, but Facebook does not require that it be set. If your client app uses the Facebook default settings, your users who use Facebook to login to your app are vulnerable to redirect attacks and information theft. Set the OAuth redirect URL in the Facebook settings to close this security hole.

 (for clarity, URLs in query params in the examples below are not URL encoded)

Not vulnerable:

  1. Your web site requests the user login from auth provider, and includes in the request a callback URL to receive auth code:
  2. Auth provider authenticates user
  3. Auth provider validates that the given callback URL ( matches the auth provider’s provisioning data for
  4. Auth provider redirects to and attaches the auth code as a query param:
  5. responds by capturing the auth code query param, converting the auth code into an access token in another request to the auth provider, and stores the access token in a browser session cookie so that it can be used across multiple web pages on


  1. User visits
  2. realizes user is not authenticated, redirects to auth provider login and includes the URL of the original page requested by the user in the receive auth code redirect:
  3. Auth provider does authentication, validates the domain of redirect against provisioned configuration, and redirects to the given redirect url
  4. further redirects to AND copies the query parameters to the redirected URL:
  5. sees the auth code on the URL and performs steps to convert it to an access token, fetch the user’s personal data, and display the profile page.


  1. discovers that implements a redirect endpoint (
  2. constructs a new url from scratch to request authentication from an auth provider (, replacing the portion of the authredirect url with  authredirect=
  3. manages to get the user to click on a link which navigates to the auth provider with that doctored redirect url
  4. User logs in seeing “” as the referring app.
  5. Auth provider does authentication, validates domain of redirect against provisioned configuration, and redirects to given redirect url, with auth code parameter attached:
  6. redirects the browser to AND copies the query parameters to the redirected URL:
  7. can now redeem that code for an access token and use that access token to access user data from the auth provider ( as well as potentially full access to user account on (if exposes an API secured by the same access token)


It’s not difficult to thwart this open redirect exploit:

  1. Make sure you specify an OAuth redirect URI in the app configuration settings with every OAuth provider your app uses.
  2. Don’t implement redirect URLs on your web site.
  3. If redirects are required for your web site workflow, restrict the redirect endpoint to only redirecting to URLs within your own site. Do not copy the query params to the redirected URL. Perform the processing of auth code to access token on the redirect endpoint and store the access token in a browser session cookie before redirecting to the page the user originally request.


There are legitimate reasons to implement a limited redirect endpoint on your web site. The most common use case: after the login process is complete, redirect the browser to the web page (on your site) that the user originally requested. This use of redirects should be constrained to only perform the redirect if the requested destination URL is in your site’s domain.

  7 Responses to “Tech Analysis of “Serious security flaw in OAuth, OpenID Discovered””

  1. […] shipped off the information to any URL in the parameters. Dell authorisation architect Danny Thorpe explained the attack in the example: […]

  2. […] Danny Thorpe who works as a XACML authorization management architecture and tools at Dell has said in a blog post: […]

  3. Updated to call out that while Facebook supports OAuth redirect URL validation, Facebook does not require it to be set. If you use the Facebook default settings with your client app, you are exposed to redirect exploits.

  4. […] Mashable also had a great write-up on why this isn’t as big an issue and the fact that it isn’t technically new. I would also recommend reading an excellent write-up of the technical details for OAuth/OpenId by Danny Thorpe. […]

  5. […] Thorpe hat zwei Beispiele für den sicheren und unsicheren Einsatz von OAuth beschrieben, an die sich die folgenden Beispiele stark […]

Sorry, the comment form is closed at this time.