Re: [OAUTH-WG] OAuth v2-18 comment on "state" parameter

Bob Van Zant <bob@veznat.com> Wed, 20 July 2011 16:28 UTC

Return-Path: <bigbadbob0@gmail.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 64AA521F8AF4 for <oauth@ietfa.amsl.com>; Wed, 20 Jul 2011 09:28:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.883
X-Spam-Level:
X-Spam-Status: No, score=-2.883 tagged_above=-999 required=5 tests=[AWL=0.094, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, RCVD_IN_DNSWL_LOW=-1]
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 9jp+Rv+HPkoe for <oauth@ietfa.amsl.com>; Wed, 20 Jul 2011 09:28:44 -0700 (PDT)
Received: from mail-qy0-f172.google.com (mail-qy0-f172.google.com [209.85.216.172]) by ietfa.amsl.com (Postfix) with ESMTP id 5567521F8915 for <oauth@ietf.org>; Wed, 20 Jul 2011 09:28:44 -0700 (PDT)
Received: by qyk9 with SMTP id 9so3615799qyk.10 for <oauth@ietf.org>; Wed, 20 Jul 2011 09:28:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=nqtX94ObFV1YYEE3JjNbc7nIFCG3Yjh3LIgSa18WPdE=; b=o7DX/ZKSkpLae46O6BsDNoNO9gCwl6FWz3wQEqYvCucLzhooHuPKPJqGZeTiZKIGIJ MmmnAyDJhpbo8Q1/3lS360vh4t3upagAPyCyjgrxrTtpnqhJyKzCvqd+sfYSPfkJwliO bSIObaQJ9M3UGUOHqTc/iCYV14rehRA5nnNlc=
MIME-Version: 1.0
Received: by 10.229.30.138 with SMTP id u10mr5033294qcc.3.1311179323542; Wed, 20 Jul 2011 09:28:43 -0700 (PDT)
Sender: bigbadbob0@gmail.com
Received: by 10.229.100.136 with HTTP; Wed, 20 Jul 2011 09:28:43 -0700 (PDT)
In-Reply-To: <90C41DD21FB7C64BB94121FBBC2E72345020652CA4@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>
Date: Wed, 20 Jul 2011 09:28:43 -0700
X-Google-Sender-Auth: pJuFyg5XV1W6taKcJ8rVkFoeXSA
Message-ID: <CADrOfLJLe_JdGZTWdSGLvXySbh==3oNuYJHQRPWL+RsN9b6AAA@mail.gmail.com>
From: Bob Van Zant <bob@veznat.com>
To: Eran Hammer-Lahav <eran@hueniverse.com>
Content-Type: text/plain; charset="ISO-8859-1"
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 16:28:45 -0000

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
>> >
>> >
>