Re: [OAUTH-WG] OAuth v2-18 comment on "state" parameter
Eran Hammer-Lahav <eran@hueniverse.com> Wed, 20 July 2011 17:37 UTC
Return-Path: <eran@hueniverse.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 E88E221F87C7 for <oauth@ietfa.amsl.com>; Wed, 20 Jul 2011 10:37:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.28
X-Spam-Level:
X-Spam-Status: No, score=-2.28 tagged_above=-999 required=5 tests=[AWL=-0.281, BAYES_00=-2.599, J_CHICKENPOX_45=0.6]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4mlXiztr7OTv for <oauth@ietfa.amsl.com>; Wed, 20 Jul 2011 10:37:36 -0700 (PDT)
Received: from p3plex1out02.prod.phx3.secureserver.net (p3plex1out02.prod.phx3.secureserver.net [72.167.180.18]) by ietfa.amsl.com (Postfix) with SMTP id 3771221F87AF for <oauth@ietf.org>; Wed, 20 Jul 2011 10:37:36 -0700 (PDT)
Received: (qmail 8742 invoked from network); 20 Jul 2011 17:37:35 -0000
Received: from unknown (HELO smtp.ex1.secureserver.net) (72.167.180.21) by p3plex1out02.prod.phx3.secureserver.net with SMTP; 20 Jul 2011 17:37:35 -0000
Received: from P3PW5EX1MB01.EX1.SECURESERVER.NET ([10.6.135.19]) by P3PW5EX1HT003.EX1.SECURESERVER.NET ([72.167.180.21]) with mapi; Wed, 20 Jul 2011 10:37:23 -0700
From: Eran Hammer-Lahav <eran@hueniverse.com>
To: Bob Van Zant <bob@veznat.com>
Date: Wed, 20 Jul 2011 10:36:54 -0700
Thread-Topic: [OAUTH-WG] OAuth v2-18 comment on "state" parameter
Thread-Index: AcxG+hgaeDk+Q8bmRXuNeCjV4JMNVAABq/cQ
Message-ID: <90C41DD21FB7C64BB94121FBBC2E72345020652CE2@P3PW5EX1MB01.EX1.SECURESERVER.NET>
References: <CADrOfLJSd8Z=QfCcGUdFBU314rmjv9-u25Vta+ObXfNAwoA06w@mail.gmail.com> <4E22B021.7080009@cisco.com> <90C41DD21FB7C64BB94121FBBC2E7234501D6E0656@P3PW5EX1MB01.EX1.SECURESERVER.NET> <CAGHdeD711qcuZiJ6C8miMNfTW1iDTvqG1KKrEZrWsM2Mxxs3WA@mail.gmail.com> <CADrOfLJd7jtfJGBwxaX1bQHN-Ow=T-kGLTgOWw0rR1cYGCpzog@mail.gmail.com> <90C41DD21FB7C64BB94121FBBC2E72345020652CA4@P3PW5EX1MB01.EX1.SECURESERVER.NET> <CADrOfLJLe_JdGZTWdSGLvXySbh==3oNuYJHQRPWL+RsN9b6AAA@mail.gmail.com>
In-Reply-To: <CADrOfLJLe_JdGZTWdSGLvXySbh==3oNuYJHQRPWL+RsN9b6AAA@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Cc: OAuth WG <oauth@ietf.org>
Subject: Re: [OAUTH-WG] OAuth v2-18 comment on "state" parameter
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: Wed, 20 Jul 2011 17:37:37 -0000
I think most of your description isn't very relevant to this particular attack. I'll skip to the part where the legitimate client gets a maliciously modified state parameter value. Your concern seems to be a simple code injection attack (e.g. that some clients will not properly protect their code from invalid state values). For example, a client may use state to pass a JSON string and when it receives it back, calls eval() on the raw state value or even JSON.parse without catching exceptions. The right way to address this is to add a new security consideration section discussion the various Injection Attacks possible. Using state to include malicious code is one. Another is code injection in the redirect_uri by a malicious client to an authorization server supporting dynamic redirection URIs. Then of course, there really is no need for any elaborate setup for anyone to send requests to the client redirection URI endpoint directly (without following any of the flow). In such a case, the enforcement of safe state values by the authorization server will accomplish nothing if the client doesn't perform its own validation (and we're back to square one). In other words, I can call any endpoint on the client with any malicious parameters and try to break it. But even if you perform input validation on the client side, which should prevent a code injection attack, you are still open to other malicious manipulation of the state parameter. For example, a naïve client can use the state parameter to pass a user id so that when the redirection callback is called, it can link the access token to that account. That of course, would be a very bad thing (tm) without some protection (e.g. state cookie) which the client can use to validate the state value. In short, over specification does not solve ignorance. We can and should highlight the possible code injection attacks on both the client and authorization server, as well as other security concerns around the state parameter. But at the end, it is up to both the client and authorization server developers to build secure applications. So, anyone volunteering to propose text? EHL > -----Original Message----- > From: bigbadbob0@gmail.com [mailto:bigbadbob0@gmail.com] On Behalf Of > Bob Van Zant > Sent: Wednesday, July 20, 2011 9:29 AM > To: Eran Hammer-Lahav > Cc: Breno; OAuth WG > Subject: Re: [OAUTH-WG] OAuth v2-18 comment on "state" parameter > > The problem lies in the inherent trust of the state parameter. The naive > client application developer assumes that state goes out to the authorization > server and comes back unchanged; because that's what the spec says will > happen. > > As a malicious person I use the client application and steal the client id when > I'm redirected to the authorization server. > > I then craft my own authorization URL pretending to act on behalf of the > client application. > > http://example.com/oauth/authorize?client_id=deadbeef&response_type= > code&state=%3Cscript%3Ealert%28%22omg%22%29%3B%3C%2Fscript%3E > > I send that out to unsuspecting people. Those people are sent to my site; > maybe they trust it. The site is asking them to authorize an application they > perhaps they're familiar with. So they do. > > Now the assumption, and it's really not much of a leap of faith, is that some > client developer is going to take that state variable and put it directly into > their site. In PHP it could be something silly > like: > > Thanks for authorizing our app, $_GET["state"]. > > Chrome protects me from this basic attack (I just inserted it into one of my > demos): Refused to execute a JavaScript script. Source code of script found > within request. Other browsers won't. Real attackers are more creative than > me. > > -Bob > > > > > > On Wed, Jul 20, 2011 at 9:11 AM, Eran Hammer-Lahav > <eran@hueniverse.com> wrote: > > Can you provide examples of bad values and how they make the > implementation less secure? What's the attack vector here? > > > > EHL > > > >> -----Original Message----- > >> From: bigbadbob0@gmail.com [mailto:bigbadbob0@gmail.com] On Behalf > Of > >> Bob Van Zant > >> Sent: Wednesday, July 20, 2011 9:10 AM > >> To: Breno; Eran Hammer-Lahav > >> Cc: OAuth WG > >> Subject: Re: [OAUTH-WG] OAuth v2-18 comment on "state" parameter > >> > >> I think somewhere in here my original comments got lost. The spec, as > >> written, provides no limitations on what can go in the state variable. > >> If we don't define those limitations in the spec implementors are > >> going to define their own limitations (I'm on the verge of doing it myself). > >> > >> I propose that the state variable be limited to the set of characters > >> [a-zA-Z0- 9_-] and be restricted to a maximum length of 150 characters. > >> It's simple, doesn't require URL encoding, and will be hard for a > >> client application to turn into a vulnerability. It provides plenty > >> of uniqueness (it can fit a sha512) for even the largest and most used > client applications. > >> > >> -Bob > >> > >> > >> On Wed, Jul 20, 2011 at 8:24 AM, Breno <breno.demedeiros@gmail.com> > >> wrote: > >> > > >> > > >> > On Mon, Jul 18, 2011 at 11:32 PM, Eran Hammer-Lahav > >> > <eran@hueniverse.com> > >> > wrote: > >> >> > >> >> > >> >> > -----Original Message----- > >> >> > From: oauth-bounces@ietf.org [mailto:oauth-bounces@ietf.org] On > >> >> > Behalf Of Eliot Lear > >> >> > Sent: Sunday, July 17, 2011 2:49 AM > >> >> > >> >> > One other point: if the redirection_uri can have fragments and > >> >> > can be provided, why is state necessary? > >> >> > >> >> First, I assume you mean query instead of fragment. > >> >> > >> >> This was discussed on the list about a year ago. There isn't a > >> >> requirement to support both dynamic redirection URIs as well as a > >> >> special state parameter. However, the state parameter provides a > >> >> better way to allow customization of the redirection request > >> >> alongside full registration of the redirection URI. Section 3.1.2 > >> >> recommends using the state parameter over changing the redirection > >> >> URI > >> itself. > >> >> > >> >> Using state is much simpler because the authorization server does > >> >> not have to implement potentially insecure URI comparison > >> >> algorithms for dynamic redirection URIs. > >> > > >> > Agree -- for instance, Google's provider doesn't allow arbitrary > >> > dynamic specification of query or fragment parameters in redirect > >> > URIs, for instance, due largely to security considerations. > >> > > >> >> > >> >> EHL > >> >> _______________________________________________ > >> >> OAuth mailing list > >> >> OAuth@ietf.org > >> >> https://www.ietf.org/mailman/listinfo/oauth > >> > > >> > > >> > > >> > -- > >> > Breno de Medeiros > >> > > >> > > >
- [OAUTH-WG] OAuth v2-18 comment on "state" paramet… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eliot Lear
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Breno
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Bob Van Zant
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Aiden Bell
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Aiden Bell
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Eran Hammer-Lahav
- Re: [OAUTH-WG] OAuth v2-18 comment on "state" par… Aiden Bell