Subject: Re: [OAUTH-WG] Report an authentication issue

From: Antonio Sanso <[email-masked]>
Date: Sun, 1 Jul 2012 16:03:16 +0100

Hi *,
On Jun 30, 2012, at 7:46 PM, John Bradley wrote:

> There is one Core issue.
> Audience restriction of the grant for the client.   This is mostly important where the client is inferring from the grant what the identity of the presenter is.
>
> This surfaces in slightly different ways depending on the use case.
>
> 1, Native apps passing a access token over a back channel API to Authenticate the user of the App.  This is not a OAuth flow itself but is enabled by OAuth.
> 2, Web Applications using implicit flow.  (there are mitigations but they are not part of OAuth core)
> 3, Public clients using code flow.
>
> Bearer tokens & MAC with per token secrets are both vulnerable to this.
>
> One observation from the security concern text I proposed that Dick and others received was that 3 could be fixed relatively simply in the spec.

definitely +1 here.

Another possible flaw in the Authorization Code Grant flow that affects the Resource Owner this time (using confidential client) may be the follow:

Stealing John example (thanks :)) we will have only one confidential client

Site A is I love Puppies (this time a Good site)

One resource owner RO1 access Site A in a library/airport  (just as reminder Site A use the Authorization Code Grant) and this will imply a login to the Authorization Server (e.g. Facebook). As result of this the authorization code will stay in the browser history.
When RO1 finishes he will almost certainly log out from Site A and Facebook but arguably he will not clean the browser history.
At this stage an evil resource owner RO2 that also uses Site A will login in Facebook with his own credentials but will tamper the redirect to site A with the authorization code of RO1 that is stored on the browser history.
What will happen is that despite the fact RO2  is logged in in Facebook with his own credentials will have back the resource of RO1.

WDYT?

Regards

Antonio

>
> The first two are out of scope for OAuth core and can really only be dealt with by documenting them as a security concern so that people avoid doing those things without additional security like using token introspection etc.
>
> So they are all just different attacks exploiting the same flaw.
>
> The MS researchers may have a different opinion, but I have yet to hear it.
>
> John B.
> On 2012-06-30, at 4:11 AM, Phil Hunt wrote:
>
>> John,
>>
>> Thanks. I am not understanding yet. But if you believe there is a problem that is enough for me. I do not mean in any way dismiss it.
>>
>> Do you think the issue you described is different from the original message that started this thread? It seems so to me.
>>
>> Phil
>>
>> On 2012-06-29, at 20:34, John Bradley <[email-masked]> wrote:
>>
>>> Phil,
>>>
>>> You know not everyone gets a personalized example:)
>>>
>>> In the below examples there is no proxy or other compromise of the client required only the ability to do what appears to be a SSO login using OAuth.
>>> The attacker needs only a web browser.
>>>
>>> When they tales about compromised clients,  they are not talking about needing to compromise the app on the users phone.
>>>
>>> They can compromise a client on there platform e.g. load it into a iPhone emulator, or just create a new client that emulates the backend API.
>>>
>>> There are already script kits to exploit this.   The vulnerability was distributed in API kits from Faceboo, Apple and others.
>>>
>>> If it was just one developer getting it wrong that would be one thing,  hundreds getting it wrong by using the API in trusted development kits is a much worse problem in my opinion.
>>>
>>> My hope is to at least make it clear to the library authors and tool venders, what are unsafe patterns.
>>>
>>> This exploit is unfortunately not hypothetical.
>>>
>>> John B.
>>>
>>>
>>> On 2012-06-29, at 7:31 PM, Phil Hunt wrote:
>>>
>>>> See below...
>>>>
>>>> Phil
>>>>
>>>> @independentid
>>>> www.independentid.com
>>>> [email-masked]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 2012-06-29, at 1:54 PM, John Bradley wrote:
>>>>
>>>>> No,
>>>>>
>>>>> Trying to explain this over email is a challenge:)
>>>>>
>>>>> This apples to both native apps and Web Servers who are OAuth Clients.
>>>>>
>>>>> Imagine there are two web servers that authenticate people with Facebook Connect (just an example).
>>>>>
>>>>> Site A is I love Puppies   (An evil site)
>>>>> Site B is I Hate Larry Ellison  (A good site)
>>>>>
>>>>> You as a chocolate lover go to Site A and login to get some cool free screensaver of Puppies.
>>>>> Site A gets a token for your social graph no big deal mostly public stuff.  However they discovery you work for Mr Evil who they think is purchasing paradise to put up a parking lot.
>>>>
>>>> Ummm....ok. I didn't want to go political on this. ;-)
>>>>>
>>>>> They then go to site B who is using the implicit flow for Facebook authentication.  They login using a web browser but using any one of a number of browser plugins modify the response to have the access_token that they got from you when you logged into their site.   They now post as you telling everyone that Larry can't sail and has bad fashion sense. (Perhaps true)  You might now have some explaining to do!
>>>>
>>>> Soooo...according to the specs, there are now TWO mistakes:
>>>>
>>>> 1. Implicit is intended ONLY for java script clients in the browser. Implicit clients shouldn't have any data of value (at least retained data).
>>>>
>>>> 2. The MS example states that they have control of the client application and its communications.
>>>>
>>>> Do we need to make #1 even more clearer -- an entire paragraph in all caps maybe? ;-)
>>>>
>>>> Since the researchers put a proxy server in between the app and Facebook. Therefore ANY OAUTH flow would be compromised since they are able to insert tokens into the flow.  Adding client id isn't going to help (so I agree with you there).
>>>>
>>>> But I point out this hack only works if you can intercept the communications path.
>>>>
>>>> If we were talking about some sports network on a public internet site, this problem wouldn't come up unless that hackers have access to the web sites physical network and can reconfigure the clients proxy server settings.
>>>>
>>>> In the end, I don't think this is a valid *oauth* security issue since the assumption is a compromised client and/or communications path. This is a network security issue.
>>>>
>>>>
>>>>> It would be worse if Site B had some PII about you or could transfer the money from your bank based on that authentication.
>>>>
>>>>>
>>>>> The same thing could happen with the code flow if the client is public and doesn't have a secret.   Site A doesn't use the code themselves when you login,  they just let you through to get the puppy photos.
>>>> Agreed.
>>>>> They immediately take the token to site B and paste it into a legitimate response (note the client_id is not in the response or code ) the public client then presents that to the token endpoint with it's client_id to get the access_token.   The token endpoint just hands it over because without a client_secret it is not required to authenticate the client.
>>>>>
>>>>> What Dick and I are saying is that we don't see the need not to verify the client_id in the request to the token endpoint.  If it were required clients would not be able to mistakenly accept codes issued to diffrent clients.
>>>>
>>>>>
>>>>> I strongly suspect most implementations do that already, so why not clarify the spec on that point.
>>>>
>>>>>
>>>>> That won't stop the attack on implicit clients.
>>>>>
>>>>> This is why openID 2.0, openID Connect, SAML and every other identity protocol I can think of audience restrict the assertion to the intended recipient and sign or integrity protect the response.
>>>>>
>>>>> That is not needed for the typical authorization use case of OAuth, but is a really good idea if you are asserting Authentication information to the client.
>>>>>
>>>>> No puppies were hurt in the creation of this message.
>>>>> John B.
>>>>>
>>>>> On 2012-06-29, at 4:16 PM, Phil Hunt wrote:
>>>>>
>>>>>> John,
>>>>>>
>>>>>> I think that helps to clarify the authorize issue.
>>>>>>
>>>>>> But they were talking about a phishing site obtaining a legit access token from Facebook.
>>>>>>> Let's take Soluto's metro app as an example to describe the problem. The app supports Facebook Login. As an attacker, we can write a regular Facebook app. Once the victim user allows our app to access her Facebook data, we receive an access_token from the traffic. Then, on our own machine (i.e., the "attacker" machine), we run the metro app of Soluto, and use a HTTP proxy to insert the victim's access_token into the traffic of Facebook login. Through this way, we are able to log into the victim's Soluto account from our machine. Other than Soluto, we also have confirmed the same issue on another Windows 8 metro-app Givit.
>>>>>>
>>>>>>
>>>>>> Important: the attack works because the researchers had control of the client application.  And thus they were able to insert the token between the metro client app and the server because they are able to get in the communications path. All bets are off. If the attacker can insert a token then can insert appropriate client_id's and responses in the stream as well.
>>>>>>
>>>>>> Phil
>>>>>>
>>>>>> @independentid
>>>>>> www.independentid.com
>>>>>> [email-masked]
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 2012-06-29, at 1:00 PM, John Bradley wrote:
>>>>>>
>>>>>>> The attack requires a web browser that allows modifying the value of the of the redirect URI.   It is dead simple cut token or code from the string and paste in the token or code that was granted by the user you want to impersonate.
>>>>>>>
>>>>>>> OAuth responses are not signed or audience restricted to the client(except confidential clients using the code flow).
>>>>>>>
>>>>>>> In cases where the code or token is passed over a back channel to a server, faking the entire client is the easiest thing for the attacker.
>>>>>>>
>>>>>>> I don't consider these to be authorization attacks,  rather attacks on a client that is inappropariatly making unwarranted assumptions about the presenter of the token.
>>>>>>>
>>>>>>> John B.
>>>>>>> On 2012-06-29, at 3:29 PM, Phil Hunt wrote:
>>>>>>>
>>>>>>>> We need more info on the inject method the researchers used before we can account for it.
>>>>>>>>
>>>>>>>> Phil
>>>>>>>>
>>>>>>>> On 2012-06-29, at 12:16, John Bradley <[email-masked]> wrote:
>>>>>>>>
>>>>>>>>> The same thing can be done with code.
>>>>>>>>>
>>>>>>>>> If the token endpoint checks the client_id before giving out the access token then the attack on code can be prevented, as the token endpoint won't return the access token.
>>>>>>>>>
>>>>>>>>> The spec dosen't require authenticating public clients currently so it is a slightly more difficult attack but possible.
>>>>>>>>>
>>>>>>>>> Dick and I are suggesting closing the hole at the token endpoint so that nether confidential nor public clients using the code flow are susceptible to this substitution attack.
>>>>>>>>>
>>>>>>>>> John B.
>>>>>>>>>
>>>>>>>>> On 2012-06-29, at 2:53 PM, PhiIt helps with the code flow when l Hunt wrote:
>>>>>>>>>
>>>>>>>>>> I'm not seeing how client id helps if a proxy server is somehow involved with inserting the bearer token as the researchers suggested.
>>>>>>>>>>
>>>>>>>>>> Phil
>>>>>>>>>>
>>>>>>>>>> On 2012-06-29, at 11:30, John Bradley <[email-masked]> wrote:
>>>>>>>>>>
>>>>>>>>>>> I think they only exploited the implicit flow.
>>>>>>>>>>>
>>>>>>>>>>> My point was that there is a way you could do the same thing with code if it is a public client that is not authenticating to the token endpoint.
>>>>>>>>>>>
>>>>>>>>>>> In general making identity assumptions in the client based on a code or access_token has risks that are out of scope for OAuth.
>>>>>>>>>>>
>>>>>>>>>>> We do however want to provide good advice about specific things that can leave systems insecure when using OAuth.
>>>>>>>>>>>
>>>>>>>>>>> John B.
>>>>>>>>>>>
>>>>>>>>>>> On 2012-06-29, at 2:22 PM, Phil Hunt wrote:
>>>>>>>>>>>
>>>>>>>>>>>> I'm not clear whether the MS Security Researcher hack was with the authorization code or the access token. If the latter, the client_id is out of the picture isn't it?
>>>>>>>>>>>>
>>>>>>>>>>>> Phil
>>>>>>>>>>>>
>>>>>>>>>>>> @independentid
>>>>>>>>>>>> www.independentid.com
>>>>>>>>>>>> [email-masked]
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 2012-06-29, at 11:14 AM, Dick Hardt wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Jun 29, 2012, at 11:06 AM, John Bradley wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> It is nice to know that I may occasionally be correct:)
>>>>>>>>>>>>>
>>>>>>>>>>>>> You must be delighted when it happens! ;)
>>>>>>>>>>>>>
>>>>>>>>>>>>>> While you may assume that it is reasonable for a client with a code to make a request to the token endpoint including it's client_id and the server to only give out the access token if the client_id in the token request matches the one in the original authorization request.   However the spec specifically doesn't require that.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I think that is an error in the spec and should be changed, or text adding saying that the client_id SHOULD be checked.
>>>>>>>>>>>>>
>>>>>>>>>>>>> -- Dick
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>> OAuth mailing list
>>>>>>>>>>>>> [email-masked]
>>>>>>>>>>>>> https://www.ietf.org/mailman/listinfo/oauth
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>
> <smime.p7s>_______________________________________________
> OAuth mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/oauth

---

From: Phil Hunt <[email-masked]>
Date: Sun, 1 Jul 2012 11:20:37 -0700

Antonio,

This is a systematic issue. This tends to be an issue with authenticating sites using cashed sso to remember users and not one of OAuth2 directly (as the protocol is not directly involved with end-user authentication in authorization flow). However, you are right it becomes a problem for OAuth2 clients because they don't see whether in fact an authentication occurred. One can envision the same thing happening with people at home sharing browsers. The problem is wide spread enough that a lot of existing client web sites today show "Hello Phil, not Phil?" kinds of links somewhere on the page.

While not of malicious intent, the mistaken re-use of cached authentication is covered in the OAuth2 Threat Model Document here: 

4.2.3.  Threat: Malicious client obtains existing authorization by fraud

Authorization servers may wish to automatically process authorization
   requests from clients which have been previously authorized by the
   user.  When the user is redirected to the authorization server's end-
   user authorization endpoint to grant access, the authorization server
   detects that the user has already granted access to that particular
   client.  Instead of prompting the user for approval, the
   authorization server automatically redirects the user back to the
   client.

   A malicious client may exploit that feature and try to obtain such an
   authorization code instead of the legitimate client.

Action item: Should we expand the definition of this threat to include accidental re-use of cached authentication.

Also, it is worth noting that this is another issue that OpenID Connect is aimed at addressing. It allows the client to request re-authentication and re-authorization --> important in these scenarios or for high risk transactions.  FWIW at some point I would like to see a core OAuth2 extension that documents additional parameters enabling the client to request re-authentication.

Phil

@independentid
www.independentid.com
[email-masked]

---

From: John Bradley <[email-masked]>
Date: Sun, 1 Jul 2012 14:35:23 -0400

There are existing mitigations in the spec to to prevent this attack on a confidential client.

code
         REQUIRED.  The authorization code generated by the
         authorization server.  The authorization code MUST expire
         shortly after it is issued to mitigate the risk of leaks.  A
         maximum authorization code lifetime of 10 minutes is
         RECOMMENDED.  The client MUST NOT use the authorization code
         more than once.  If an authorization code is used more than
         once, the authorization server MUST deny the request and SHOULD
         revoke (when possible) all tokens previously issued based on that authorization code.
         The authorization code is bound to the client identifier and redirection URI.

The code in the browser is precluded from being accepted twice by the authorization server.
I don't think any additional security concern is required for this.

Now back in the real world, you are correct, this attack works perfectly well on some authorization servers (Facebook for one).
They however are not following the current OAuth 2 specification, they allow the code to live perhaps indefinitely  (The only way I have found to invalidate code is by resetting the account password),
and also accept it multiple times (I have not found a limit submitting the same code for months).  

Facebook do at-least  bind the code to the client_id, at least for authenticated clients.

I think for this the spec is correct and some implementations are non-conformant.

There is a long list of stupid things people can do if they ignore parts of the spec.

John B.

---

From: Phil Hunt <[email-masked]>
Date: Sun, 1 Jul 2012 11:45:46 -0700

John,

Thanks. I agree.

Regarding my comment (on the other thread:  Inadvertent cross-authentication through cached auth session) was directed at the same thing happening by simply restoring the previous users login state from a browser cookie. A much simpler and unintentional variant of the scenario.

Phil

@independentid
www.independentid.com
[email-masked]

---

From: John Bradley <[email-masked]>
Date: Sun, 1 Jul 2012 16:24:55 -0400

Phil,

Yes certainly that is the case with sharing browsers.

The problem is perhaps worse because the Authorization server may not understand that the "authorization process is  being used as a form of delegated end-user authentication by the client".

Session management and logout are perhaps the hardest problems for SSO.

John B.