Re: [OAUTH-WG] A Scope Attack against OAuth 2.0

John Bradley <ve7jtb@ve7jtb.com> Tue, 21 February 2012 22:00 UTC

Return-Path: <ve7jtb@ve7jtb.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 1E76411E8081 for <oauth@ietfa.amsl.com>; Tue, 21 Feb 2012 14:00:00 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.499
X-Spam-Level:
X-Spam-Status: No, score=-3.499 tagged_above=-999 required=5 tests=[AWL=0.099, BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3v3JKM-ERsvu for <oauth@ietfa.amsl.com>; Tue, 21 Feb 2012 13:59:58 -0800 (PST)
Received: from mail-yw0-f44.google.com (mail-yw0-f44.google.com [209.85.213.44]) by ietfa.amsl.com (Postfix) with ESMTP id CC59111E8074 for <oauth@ietf.org>; Tue, 21 Feb 2012 13:59:57 -0800 (PST)
Received: by yhkk25 with SMTP id k25so3622064yhk.31 for <oauth@ietf.org>; Tue, 21 Feb 2012 13:59:57 -0800 (PST)
Received-SPF: pass (google.com: domain of ve7jtb@ve7jtb.com designates 10.236.170.163 as permitted sender) client-ip=10.236.170.163;
Authentication-Results: mr.google.com; spf=pass (google.com: domain of ve7jtb@ve7jtb.com designates 10.236.170.163 as permitted sender) smtp.mail=ve7jtb@ve7jtb.com
Received: from mr.google.com ([10.236.170.163]) by 10.236.170.163 with SMTP id p23mr37961763yhl.36.1329861597359 (num_hops = 1); Tue, 21 Feb 2012 13:59:57 -0800 (PST)
Received: by 10.236.170.163 with SMTP id p23mr29531984yhl.36.1329861596195; Tue, 21 Feb 2012 13:59:56 -0800 (PST)
Received: from [192.168.1.213] ([190.22.73.49]) by mx.google.com with ESMTPS id q68sm37101080yhb.3.2012.02.21.13.59.52 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Feb 2012 13:59:54 -0800 (PST)
Mime-Version: 1.0 (Apple Message framework v1257)
Content-Type: multipart/signed; boundary="Apple-Mail=_98B5B1B7-9061-496F-AC51-88B2C2E502EA"; protocol="application/pkcs7-signature"; micalg="sha1"
From: John Bradley <ve7jtb@ve7jtb.com>
In-Reply-To: <1329860601.42679.YahooMailNeo@web31806.mail.mud.yahoo.com>
Date: Tue, 21 Feb 2012 18:59:44 -0300
Message-Id: <5F0D5C92-1228-4A3E-8CFF-05DC309B4084@ve7jtb.com>
References: <CAGmQQ9eorSS8jWgHZzw_Bq6Eb4Qj+fZ0NUuQx_KJwC_rasUCnA@mail.gmail.com> <OF7789D618.84BDC5CF-ON4A2579A8.0023CB58-4A2579A8.0024278F@au1.ibm.com> <5D97D44A-FF8A-4E67-B22D-FB6019162800@ve7jtb.com> <CAGmQQ9fA6DT=-uBZUFgB=Kz6zr=eGSQUUp6X0w1QyD=O0wZy5Q@mail.gmail.com> <1329626093.59538.YahooMailNeo@web31804.mail.mud.yahoo.com> <CAGmQQ9egR9DGg6LTQVzVxiq1of=WT2Ysv9EEzoK+5b7evwfiOg@mail.gmail.com> <1329860601.42679.YahooMailNeo@web31806.mail.mud.yahoo.com>
To: William Mills <wmills@yahoo-inc.com>
X-Mailer: Apple Mail (2.1257)
X-Gm-Message-State: ALoCoQnkhIz6CGEqI8weOYANZQjQB0rIe22x7/h61bx8G/VSGArnj90b+nhzdzBJN6tNsHKuDhpv
Cc: "Lee, David" <david.lee10@hp.com>, Wenjie Lin <lin.820@osu.edu>, "oauth@ietf.org (oauth@ietf.org)" <oauth@ietf.org>
Subject: Re: [OAUTH-WG] A Scope Attack against OAuth 2.0
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/oauth>, <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/oauth>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 21 Feb 2012 22:00:00 -0000

Removing the unstopped response solves nothing , because the resource owner can revoke a scope at any time after granting it.  
Nothing forces the Authorization server to revoke the refresh or access token if a scope is revoked.  That is a implementation choice of the Authorization server.

This 'attack'  is one that only works with badly designed clients that are making unwarranted assumptions about the behaviour of the Authorization server.  

The only way for a client to know if a token has a scope it to try it, or use a introspection endpoint.  End of story.

John B.
On 2012-02-21, at 6:43 PM, William Mills wrote:

> No, I do not agree that this is an attack.  The resource owner has granted different privs than the client expects, but that was done by the resource owner.   The only "attack" is the resource owner against the client, and the client is going to have to have a way to detect invalid tokens anyway.
> 
> As I said in the first paragraph below, this is already (good or bad) part of the protocol, that the scope profile issued may differ.  What *might* fix this is if the auth server must also return the scopes requested if they are covered by the token; so if the client asks for scope A (we'll say this is a legacy client scope) which is a proper subset of B, and the auth server wants to issue B (the new scope for the new version of a client) then the server would have to return "B A" as the scope list indicating both scope.
> 
> The problem still lies in an unscoped response, which some implementations will want to use "" for.  If we force the above we force global scopes to be named, which isn't horrible.
> 
> From: Wenjie Lin <lin.820@osu.edu>
> To: William Mills <wmills@yahoo-inc.com> 
> Cc: John Bradley <ve7jtb@ve7jtb.com>; "oauth@ietf.org (oauth@ietf.org)" <oauth@ietf.org>; "Lee, David" <david.lee10@hp.com> 
> Sent: Tuesday, February 21, 2012 12:07 PM
> Subject: Re: [OAUTH-WG] A Scope Attack against OAuth 2.0
> 
> Our understanding is that you agree this is indeed a scope attack, that is, the user may get services, which are different than the client has agreed.
> If the protocol adopts the change we’ve suggested, the client immediately figures out the difference between what he has agreed and what is in the access token. How does the client deal with it? Decline the service or take other actions? Indeed, as you rightly pointed out, it is an issue of operation – an excellent note for the implementer. However, this is no longer a protocol issue.
> -W. Lin and D. Lee
> 
> On Sat, Feb 18, 2012 at 8:34 PM, William Mills <wmills@yahoo-inc.com> wrote:
> So, I think what you are pointing out is an operability flaw rather than a security one.  It is possible that the client will be issued a token that does not have the permissions it expects, and the only way for the client to determine this in a guaranteed fashion is to do an operation and see a failure.
> 
> The question then is, does this warrant a MUST rather than SHOULD.  The server may issue a more privileged token for example.  From the scope name there's no way for the client to actually resolve the scope name to privilege, so even if the server provides the scope we might have the same problem.
> 
> There are current usages in comaparable systems where an unscoped token implies no restriction.  The semantics of scope names here have intentionally been left fuzzy.  It's a significant change to try to fix this problem, but the questionis whether it's worth it?  I doubt that will get it right in a way that people will agree with, I don't think you proposed change is sufficient to resolve the problem.
> 
> Would it be sifficient to call it out as an implementors note or a nota bene type editorial comment?
> 
> -bill
> 
> 
> From: Wenjie Lin <lin.820@osu.edu>
> To: John Bradley <ve7jtb@ve7jtb.com> 
> Cc: "oauth@ietf.org (oauth@ietf.org)" <oauth@ietf.org> 
> Sent: Saturday, February 18, 2012 8:18 PM
> Subject: Re: [OAUTH-WG] A Scope Attack against OAuth 2.0
> 
> We appreciate your attention and response to our report.
>  
> Since Authorization Server obtains the scope information ONLY from User, it can’t tell whether the issued access token scope  is different from the one requested by Client, so long as User is consistently sending the same altered scope information to Authorization Server. Consequently, as an Option, Authorization Server may choose not to include the scope response parameter to inform Client of the actual scope granted, and that results in the scope attack. This is a protocol issue and is not an implementation issue; one can come up with an implementation that is compliant with the protocol specification yet with a scope attack.
>  
> One may argue that we only care about User protection and security. Consequently, scope attack is apparently not a protocol security issue. However, it would significantly limit the applicability of the protocol, if Client is knowingly exposed to attacks. We need Client protection and security as well in applications, for instance, cloud services.
>  
> Scope attack can be easily fixed. One can simply make it Required that Authorization Server MUST include the scope response parameter to inform Client of the actual scope granted, as we have proposed for your consideration.
>  
> OAuth 2.0 is a sound protocol design. We prove the security properties (for both User and Client) and scope attack is an issue we’ve got stuck in the proof.
>  
> - W. Lin and D. Lee
> 
> On Sat, Feb 18, 2012 at 2:47 PM, John Bradley <ve7jtb@ve7jtb.com> wrote:
> I agree that it is not a protocol problem.
> 
> The problem is that some developers are not understanding the spec.
> 
> One case I saw recently was a proposal to send a scope to the Authorization endpoint that changed is authentication behaviour e.g. ask for mlti-factor authentication.
> 
> On a superficial reading of the spec they thought that not getting a changed set of scopes back in the response that the Authorization server was indicating that it had done what was asked.
> 
> When I pointed out that the user agent can remove scopes because requests are not signed,  they had a similar solution of forcing all the endpoints to always return the scopes granted.
> 
> I hope I talked them out of that.
> 
> The problem is getting people to use scopes to represent resources and not other arbitrary configuration things,  and to understand that even if they do get a scope granted it could disappear before they get to use the access token and they need to be prepared for that.
> 
> The premise that users get access to y for access to x is something that can be built with OAuth but is not something that can be inferred in the way they are proposing.
> 
> From my perspective replying with granted scopes is a convince for the client, but not something that can be depended upon.
> I don't think we need any normative change.
> 
> A don't make stupid assumptions about the persistence of scopes in tokens note would be as far as I would go.
> 
> John B.
> 
> On 2012-02-18, at 3:34 AM, Shane B Weeden wrote:
> 
> > I agree with others - this is not an attack on the protocol. The user has
> > the choice about which scope to grant and the client's redirect to the
> > authorization endpoint is only a request for a particular set of
> > permissions, not a guarantee that it will get them. The user+authorization
> > server decide which scope is actually granted. The client needs to handle
> > cases where that differs from what it originally wanted.
> >
> >
> >
> >
> > From: Wenjie Lin <lin.820@osu.edu>
> > To:   oauth@ietf.org
> > Date: 18/02/2012 12:12 PM
> > Subject:      [OAUTH-WG] A Scope Attack against OAuth 2.0
> > Sent by:      oauth-bounces@ietf.org
> >
> >
> >
> > We describe an attack on OAuth 2.0 (draft-ietf-oauth-v2-23), called scope
> > attack, provide a live-demo of the attack on Facebook, and propose a fix
> > with discussions.
> >
> >
> >
> >
> >
> > Scope Attack
> >
> >
> > OAuth authorization of services is associated with service agreement scope.
> > For instance, Client provides an online game to User with a service
> > agreement scope A: User authorizes Client to access his profile information
> > and to post messages on his behalf. A malicious User can request for online
> > game with service agreement scope A, manipulate the scope field, and change
> > it to scope B: User authorizes Client to access his profile information.
> > User can still play the games,  yet Client can’t post messages on User’s
> > behalf, as originally agreed.
> >
> >
> > OAuth 2.0 authorization code grant and implicit grant are vulnerable to the
> > scope attack.
> >
> >
> >
> >
> >
> > A Scope Attack Scenario
> >
> >
> > (1) Authorization Server: Facebook (authorization code grant)
> >
> >
> >      (2) Client: Online gaming company Game. It allows User to play the
> >      games with the service agreement scope A: User authorizes Game to
> >      access his profile information and post messages on his behalf.
> >
> >
> >      (3) User: malicious User with an account at Facebook. He attempts to
> >      play the games yet without authorizing Game to post messages on his
> >      behalf, that is, he changes the scope from A to B: authorization of
> >      Client to access his profile information only.
> >
> >
> >
> >
> >
> > Attack Workflow
> >
> >
> >        (1) User requests Game (Client) for permission to play games,
> >        instantiating OAuth 2.0 with scope A.
> >
> >
> >        (2) Game generates an authorization request with a scope
> >        specification A, and redirects User to Facebook with the request.
> >
> >
> >        (3) User manipulates the scope field and changes it to scope B. The
> >        modified request is then sent to Facebook.
> >
> >
> >        (4) User grants the modified request.
> >
> >
> >        (5) Facebook redirects User back to Game with the authorization
> >        code.
> >
> >
> >        (6) Game exchanges the authorization code for an access token.
> >        However it has no knowledge that the scope A has been changed to
> >        scope B.
> >
> >
> >        (7) Game provides online gaming service to User. However, Game
> >        can’t post messages on User’s Facebook page.
> >
> >
> >
> >
> >
> > A Live-Demo: Facebook and CastleVille (IE and Safari tested)
> >
> >
> >      Step 1: Login Facebook and visit Facebook Apps and Game page
> >
> >
> >      https://www.facebook.com/games
> >
> >
> > Step 2: Click CastleVille.
> >
> >
> >      Step 3: When you see the Request for Permission page, instead of
> >
> >
> >            clicking “Allow”, change the scope field in the URL from your
> >            browser from  “scope=email%2Cpublish_stream%2Cpublish_actions”
> >            to “scope=email%2Cpublish_stream”.
> >
> >
> >      Step 4: After the modification, press ENTER to send the modified
> >
> >
> >            request to Facebook. Now you will see the modified Request of
> >            Permission page.
> >
> >
> > Step 5: Click on “Allow” button and enjoy the game.
> >
> >
> > (video: http://www.youtube.com/watch?v=zkmjLa3VU9w)
> >
> >
> >
> >
> >
> > Impact
> >
> >
> > Client provides services to malicious User yet with the modified service
> > agreement scope by User’s design.
> >
> >
> >
> >
> >
> > Manipulating Scope Field
> >
> >
> > The scope field in access token response is required ONLY IF Authorization
> > Server observes that the User authorized scope is different than the
> > original scope. Consequently, User can manipulate the scope field so that
> > Authorization Server cannot detect the change of the scope. As a result
> > Client provides the services yet can’t obtain the information that is
> > specified in the scope of the original service agreement.
> >
> >
> > Client can verify the service agreement scope by checking all the fields
> > against the original User request before providing the requested services
> > to User.  For instance, Client can verify the granted permissions if
> > Authorization Server (e.g. Facebook)  provides an API. However, this is out
> > of the scope of OAuth 2.0, and Client may not check it. We observe: all top
> > five games recommended by Facebook are vulnerable to the scope attack.
> >
> >
> >
> >
> >
> > Proposed Fix
> >
> >
> > Draft-ietf-oauth-v2-23 Section 5.1:
> >
> >
> > Change from
> >
> >
> >      “scope
> >
> >
> >               OPTIONAL, if identical to the scope requested by the client,
> >
> >
> >               otherwise REQUIRED.”
> >
> >
> > to
> >
> >
> > “scope REQUIRED” /* scope: User authorized scope */
> >
> >
> >
> >
> >
> > Remarks
> >
> >
> > (1) The proof of the correctness of OAuth with our proposed fix will be
> > published in an article: “OAuth 2.0 – Attacks, Fixes, Correctness, and
> > Generalizations, Wenjie Lin, David Lee and Steve Lai, to appear”.
> >
> >
> > (2) The implicit grant is also vulnerable to the scope attack. However it
> > cannot be fixed by enforcing scope field in access token response as above;
> > User can change the scope in response before being redirected to Client.
> >
> >
> >
> >
> >
> > Wenjie Lin, The Ohio State University
> >
> >
> > David Lee, HP Labs and The Ohio State University
> >
> >
> > Steve Lai, The Ohio State University
> > _______________________________________________
> > OAuth mailing list
> > OAuth@ietf.org
> > https://www.ietf.org/mailman/listinfo/oauth
> >
> >
> > _______________________________________________
> > OAuth mailing list
> > OAuth@ietf.org
> > https://www.ietf.org/mailman/listinfo/oauth
> 
> 
> 
> 
> 
> 
> _______________________________________________
> OAuth mailing list
> OAuth@ietf.org
> https://www.ietf.org/mailman/listinfo/oauth
> 
> 
> 
> 
> 
> -- 
> Wenjie Lin
> 
>