Re: [OAUTH-WG] Confusion on Implicit Grant flow

John Bradley <ve7jtb@ve7jtb.com> Tue, 10 February 2015 13:15 UTC

Return-Path: <ve7jtb@ve7jtb.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 7E19C1A0204 for <oauth@ietfa.amsl.com>; Tue, 10 Feb 2015 05:15:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.601
X-Spam-Level:
X-Spam-Status: No, score=-2.601 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QJDKYxF1fOdf for <oauth@ietfa.amsl.com>; Tue, 10 Feb 2015 05:15:17 -0800 (PST)
Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com [209.85.216.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DE0FB1A01F2 for <oauth@ietf.org>; Tue, 10 Feb 2015 05:15:14 -0800 (PST)
Received: by mail-qc0-f175.google.com with SMTP id c9so28333802qcz.6 for <oauth@ietf.org>; Tue, 10 Feb 2015 05:15:14 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=q5Y7Xv4GbiL3DFMjbn3J9BSA7kpNscpQdIAKuLaTaFg=; b=k6o14vmw9AQZnqEMlkzfBgKU86JskYA82wwNXL5yNhG7zppjNnIlRqUZfPj0cZj3WR AN3JhlCMxpcP/Re3LnQqQetiw5TZS3x3WlWt68FY6jTjYkoJUT8bCFRmBn9xKwDse+sw U+iTKZWV43tIhaA52q8mglWAqyrMrpp8bo/2JKApElXM2SJpTmLZIBakfHFejKvLSFM4 EmI0rkHma1SHuKuB1PpEAhQpzSzNf85nyAuZM34/3Le2rYedPHaFpfKLxjRsfI0LAr8F x2ff9qkEqmpondVL5j+Mi1p+w8NG5Ub+zSsUJLc4y5PU3pQsHmdU3iUuEKQUlLqeqXjK Ktew==
X-Gm-Message-State: ALoCoQkH1Po6Wy+5w1lu8zPevS5oh/VOnc96fqqgeuvRs4QMYfEIdFXd9EMa5QrkQ65bu0Nb4EiO
X-Received: by 10.224.75.7 with SMTP id w7mr53384055qaj.6.1423574113927; Tue, 10 Feb 2015 05:15:13 -0800 (PST)
Received: from [192.168.8.101] ([181.202.146.189]) by mx.google.com with ESMTPSA id 34sm15135241qgh.28.2015.02.10.05.15.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Feb 2015 05:15:13 -0800 (PST)
Content-Type: multipart/signed; boundary="Apple-Mail=_54AB1EF1-7196-4781-BE3E-49FF6DB4E503"; protocol="application/pkcs7-signature"; micalg=sha1
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\))
From: John Bradley <ve7jtb@ve7jtb.com>
In-Reply-To: <54D9DA7E.8010606@gmail.com>
Date: Tue, 10 Feb 2015 10:15:08 -0300
Message-Id: <F5AB5DA8-8F07-4146-86E0-049B965ECAB3@ve7jtb.com>
References: <BLUPR04MB6918C7701D0DB90B0FA6B0D95380@BLUPR04MB691.namprd04.prod.outlook.com> <CANSMLKFMUQsBfOo=i0ki8PF_8PjRf7W3t=PiPo7qnftN9gUyWg@mail.gmail.com> <54D91317.9010101@redhat.com> <1E340378-2D34-4AC8-906C-415EF025068E@ve7jtb.com> <54D91D87.8040303@redhat.com> <FD337176-C292-4688-9CFA-A3C7DF40FCA2@ve7jtb.com> <54D92A3C.4060106@redhat.com> <32B26B45-FB75-47DF-8E34-42943B13F0E0@ve7jtb.com> <54D93578.9050105@redhat.com> <61E85A1A-E52C-4709-A1A4-791E4141B8B1@ve7jtb.com> <54D9DA7E.8010606@gmail.com>
To: Sergey Beryozkin <sberyozkin@gmail.com>
X-Mailer: Apple Mail (2.2070.6)
Archived-At: <http://mailarchive.ietf.org/arch/msg/oauth/gKd60Pojdt4EvRf7ErrN8-DY5l0>
Cc: oauth@ietf.org
Subject: Re: [OAUTH-WG] Confusion on Implicit Grant flow
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.15
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, 10 Feb 2015 13:15:30 -0000

The issue is maintaining key material in the browser.

Web Crypto will help with that , but is not deployed widely in browsers at the moment.

Thinking about it a bit someone could make a more secure flow for JS clients using code and some Connect extensions now.

If I were concerned about logging the AT, then I would have the JS make a CORS call to the authorization endpoint with:
response_type=code+id_token              [http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html]
code_challenge=(challenge value)        [ https://tools.ietf.org/html/draft-ietf-oauth-spop-02]
code_challenge_method=S256

The response is fragment encoded,  and the id_token contains a detached sig of code for the JS to verify along with the client as the "aud" signed with RSA key of the AS as the default.
The JS would be the callback URI and extract the code and id_tokens

The JS then makes a CORS call to the token_endpoint sending
code_verifier=(verifier value)

Code could be logged but wouldn't be usable without knowing the code_verifier.
This effectively turns the JS into a semi confidential client.    

We have been looking at PKCE/SPOP for native apps, but nothing would stop it from working with JS clients.

In Connect the JS client crates a nonce value and sends that with the request.  That value comes back in the signed_id token allowing the JS to know that the code and id_token are in reply to it's request and not replayed from another session.

I think using token binding to associate the JS clients TLS key to the AT so that it cannot be replayed from a different browser is the best option over the longer term.
That provides the best protection from plugins and scripts extracting the AT from the running JS.

John B.

> On Feb 10, 2015, at 7:16 AM, Sergey Beryozkin <sberyozkin@gmail.com> wrote:
> 
> Hi John
> On 09/02/15 22:59, John Bradley wrote:
>> The security problem was people only doing host name matching on redirect_uri and attackers finding redirectors to use.   That impacted all public clients not just implicit.
>> Implicit took most of the heat because that was what Facebook was using, and they had the largest issue.
>> 
>> Connect has a response_mode that allows the response to be form encoded rather than fragment.
>> I read RFC 5849 as only allowing code to be query encoded.   The response_mode was intended for the new response types we defined in http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html
>> 
>> The spec for response mode is here http://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html
>> 
>> We haven't done anything with it recently.  I don't know if the OAuth WG wants to take it up.
>> 
> What is your opinion on providing a feature 'symmetric' to the one where a signed and/or encrypted code request is passed to AS ? The feature would return a signed and/or encrypted code in the redirect URI as usual.
> 
> I'm not sure it would help the implicit clients though...Unless the encryption key can be derived from a combination of the client_id and some extra piece of information encoded in the JS script but also known to AS (via the registration, etc)
> 
> Thanks, Sergey
> 
> 
> 
> 
>> John B.
>>> On Feb 9, 2015, at 7:32 PM, Bill Burke <bburke@redhat.com> wrote:
>>> 
>>> 
>>> 
>>> On 2/9/2015 5:03 PM, John Bradley wrote:
>>>> OK, I don't know if the WG has discussed the issue of fragments in browser history.
>>>> 
>>>> So you are trading off several round trips against the possibility of a token leaking in browser history or bookmark?
>>>> 
>>> 
>>> Yes, bookmarking tokens is a little scary, IMO, as we've already run into users bookmarking URLs with codes in them.
>>> 
>>> Also, wasn't there additional security vulnerabilities surrounding implicit flow?  Maybe these were just the product of incorrect implementations, I don't remember, it was a while ago.
>>> 
>>>> One extension that Connect introduced was a "code id_token" response type that is fragment encoded.  That would let you pass the code directly to the JS saving two legs.
>>>> 
>>> 
>>> It looks like OIDC added a "response_mode" parameter where you can specify "query" or "fragment".  Thanks for pointing this out!
>>> 
>>> 
>>> Thanks for all the help.
>>> 
>>> 
>>> --
>>> Bill Burke
>>> JBoss, a division of Red Hat
>>> http://bill.burkecentral.com
>> 
>> 
>> 
>> _______________________________________________
>> 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