Re: [OAUTH-WG] OAuth browser based apps with first-party same-domain apps

Aaron Parecki <aaron@parecki.com> Sat, 17 February 2024 00:13 UTC

Return-Path: <aaron@parecki.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 23515C14CE30 for <oauth@ietfa.amsl.com>; Fri, 16 Feb 2024 16:13:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.104
X-Spam-Level:
X-Spam-Status: No, score=-2.104 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=parecki.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jea13t1fbNZR for <oauth@ietfa.amsl.com>; Fri, 16 Feb 2024 16:13:25 -0800 (PST)
Received: from mail-vk1-xa2d.google.com (mail-vk1-xa2d.google.com [IPv6:2607:f8b0:4864:20::a2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DAE59C14F5F1 for <oauth@ietf.org>; Fri, 16 Feb 2024 16:13:25 -0800 (PST)
Received: by mail-vk1-xa2d.google.com with SMTP id 71dfb90a1353d-4c025d5329dso1037139e0c.1 for <oauth@ietf.org>; Fri, 16 Feb 2024 16:13:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=parecki.com; s=google; t=1708128804; x=1708733604; darn=ietf.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Y6R8rdpJN4UvuXzKout76PpOROi8m6TPJ+m4aW1DVpw=; b=GrCiEzwpafrfZ/kIfKh4OJMm/Wbh3X/vv1XAyrU0EotIvzU9/u4KY2mrsGWyx+1E2L hCysz6i77C+lFeWbuS57enNYFpJksPDiRIvncEYDav16nrROhGsgiq6ruOc009Fh7E+0 gCoIwaw2W8skbpdErtvqbIMMRToeLWGdfZSGC2jgjJ8In93MwMTTGnBozDCw3rs0Ugr3 QLsigkgXbuRXnue/rSvkUURxPe/V1m0KOOZYbxd4NmoYUwQq7ufIykUNQFC1JXouqYMJ N5TfmwaUGN2gopdSaJrhWi6x999ZEhJNms/1IoycTE2veSB3xQxC5hiI2K7ZmwYZMLUI aHZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708128804; x=1708733604; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y6R8rdpJN4UvuXzKout76PpOROi8m6TPJ+m4aW1DVpw=; b=v/4Z0ddmP7YpxDL3+tmNIV3CCAJCk8WClIP00lyqRFw7jB5wBOoU1akAfAg8GWjb3m nW0TuuF4eGG5cXzx8CodjTAKkBAF1XruNSucGckz7DedSXjTOWDpPh3Cv38rjgmhLGFo JYSr5RxsG0+UrlJ+plZIwCzrKs6FVwvlxV5rZJ0kE0NLb4L2/Cfc1/0GWuCc/TZXBSUC fWaK+mHM5QcXlxtRb6FgJktEE+ckNBlwllzR46f/QG3mNXYqiKfOofNHiu8bJOMZcSlK /h9mTA+ymYHd/1M3ylnC7Qxr1ZCeLAcD+Rh+cxXpxa9AC/xWh9GreyvstxF1uYGY/j9h nQ6A==
X-Gm-Message-State: AOJu0YwHO0eo+cR7op9JlN/VFDWqzixQ6VU1VGZBt5w46Jz1TdABbEot P7bxltlIUBIs3O+aHOlSkowJKozpZU8pzIL+FB+Wd1s/YMc4UoBX8sa4Tmxuf6ySKdjbQNfv5eo =
X-Google-Smtp-Source: AGHT+IGSvw2DwVc0frw3y2v575kZNwWeBHJsi16Xe+W3D5dPW6AfbCxP/IKsog3CcSYXYeWJe9Aqwg==
X-Received: by 2002:a05:6102:509e:b0:46f:37e2:cb12 with SMTP id bl30-20020a056102509e00b0046f37e2cb12mr8902928vsb.3.1708128804209; Fri, 16 Feb 2024 16:13:24 -0800 (PST)
Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com. [209.85.221.173]) by smtp.gmail.com with ESMTPSA id v20-20020a67f1d4000000b0046d30981a16sm152034vsm.33.2024.02.16.16.13.23 for <oauth@ietf.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 16:13:23 -0800 (PST)
Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-4c01c53efe5so1140845e0c.2 for <oauth@ietf.org>; Fri, 16 Feb 2024 16:13:23 -0800 (PST)
X-Received: by 2002:a1f:dac3:0:b0:4b7:a77b:299 with SMTP id r186-20020a1fdac3000000b004b7a77b0299mr5485693vkg.16.1708128803437; Fri, 16 Feb 2024 16:13:23 -0800 (PST)
MIME-Version: 1.0
References: <53D5E5C8-E85E-420B-B34D-CCB5CF752052@1und1.de> <9516BB8F-5752-41D5-8AA7-2547FD8B66BE@1und1.de>
In-Reply-To: <9516BB8F-5752-41D5-8AA7-2547FD8B66BE@1und1.de>
From: Aaron Parecki <aaron@parecki.com>
Date: Fri, 16 Feb 2024 16:13:12 -0800
X-Gmail-Original-Message-ID: <CAGBSGjpE=oyMHcx+UKmVQH9+auKevtWz2iq-7hAoz+nnor0bgg@mail.gmail.com>
Message-ID: <CAGBSGjpE=oyMHcx+UKmVQH9+auKevtWz2iq-7hAoz+nnor0bgg@mail.gmail.com>
To: OAuth WG <oauth@ietf.org>, Kai Lehmann <kai.lehmann=401und1.de@dmarc.ietf.org>
Content-Type: multipart/alternative; boundary="0000000000008f4c82061188ba0d"
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/LcIH-WA_R5jL-Bv5KbJBDb9wy20>
Subject: Re: [OAUTH-WG] OAuth browser based apps with first-party same-domain apps
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.39
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: <https://mailarchive.ietf.org/arch/browse/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: Sat, 17 Feb 2024 00:13:30 -0000

Hi Kai,

This sounds similar to an approach described in this draft, although never
actually implemented as far as I know:
https://www.ietf.org/archive/id/draft-hanson-oauth-cookie-response-mode-00.html

The main difference is the hanson draft does a redirect to the
authorization endpoint, but the access token is still returned by setting a
cookie. There are a few advantages of this approach over submitting a POST
to the token endpoint directly:

• Leverages existing infrastructure at the authorization endpoint,
including rate limits, CSRF protection, bot protection, etc
• Leverages existing logic at the authorization endpoint for applying
policies of the request, things like which clients can request which
scopes, etc, rather than having to redefine all the authorization
parameters at the token endpoint

Since you have to do a redirect the first time the user logs in anyway, the
hanson draft is faster for the first login. I could imagine trying to find
an optimization for the case where the browser wants to refresh the token
while the session at the AS is still active, so maybe we could extend that
to support that use case instead of having to do a full redirect as often.

In any case, both of these approaches are far too experimental to consider
adding to the Browser Apps BCP right now. But I do think there is something
here worth exploring in the future.

Aaron



On Mon, Nov 6, 2023 at 5:22 AM Kai Lehmann <kai.lehmann=
401und1.de@dmarc.ietf.org> wrote:

>
>
>
>
> *From: *Kai Lehmann <kai.lehmann@1und1.de>
> *Date: *Monday, 6. November 2023 at 07:48
> *To: *"oauth@ietf.org" <oauth@ietf.org>
> *Subject: *OAuth browser based apps with first-party same-domain apps
>
>
>
> Hi,
>
>
>
> I’ve been reading through the recent update of the draft for using OAuth
> in browser based apps and highly appreciate the excellent work.
>
>
>
> The draft mentions first-party single-domain browser based apps. Maybe I
> misunderstood this, but it seems to discourage using OAuth in this
> scenario. It is not clear whether the discouraged pattern is to use OAuth
> ATs or session cookies and what would be the recommended approach. At the
> end of the chapter it referes to the other recommended patterns above, but
> one of the patterns is to have ATs in the browser based client with all the
> respective risks. Even in a first-party context, using OAuth and ATs can be
> beneficial as the same public APIs and resource servers can be used which
> are also provided to 3rd parties as well as other first-party clients
> running on mobile devices or desktop. I would like to get a bit more
> clarification on this.
>
>
>
> (I apologize for the next part. I was unable to describe it otherwise.)
>
>
>
> As there have been a draft released for first-party clients, I would like
> to get your thoughts about our approach to integrating first-party browser
> based apps (SameSite with AS) to obtain Access tokens. I have not found
> this approach in any other RFC / draft … maybe for good reasons as it might
> have some flaws. As the browser based app receives Access Tokens, it is
> essentially vulnerable to the same attack scenarios mentioned in the draft.
> We are aware of those risks and mitigate some of them while accepting
> others. If this or similar approaches are already covered by the draft,
> please let me know which one it is related to (apart from the one I
> mentioned already). If this is a different approach, it might be worth
> mentioning in the draft as there have been some discussions around this
> approach and I understood that other implementers had something similar.
>
>
>
> Our approach is that the browser based app requests access tokens by doing
> a token request against the token endpoint of the well-known Authorization
> Server. The trust anchor is the Origin header. The client sends the
> required scope with the POST request and uses a specific grant_type (e.g.
> “first-party-spa”). As this is a first-party request, SameSite ookies
> (without the __Host prefix) are sent with the request. This includes
> session cookies from previously created login sessions. The token endpoint
> of the AS uses the Origin request header to identify/verify the client and
> uses the session cookie to create an Access Token with the requested and
> allowed scope; the scope allowed for the client is configured at the AS and
> the scope of the AS only includes what the client is allowed to have. If
> the client did not sent a scope with the request, the AT will contain the
> scope allowed for that client.
>
>
>
> No refresh tokens are returned. The issued ATs have a limited TTL (e.g. 20
> minutes) and will not be longer than the TTL of the session associated with
> the session cookie. If the login session is terminated, the ATs issued
> based on this login session are being revoked as well (ATs contain
> authentication context identifier and Token introspection checks for
> revocation).
>
>
>
> Should there be no valid login session (cookie) or should the token
> request demand a step-up authentication, the AS will respond with a
> respective error to let the client know that user interaction is required,
> in which case the client will initiate a standard Authcode grant to allow
> user-interaction (re-auth, fulfill obligations). Optionally, the AS can use
> a secondary device to interact with the End-User (e.g. get consent or raise
> level of assurance of the login session) whilst holding back the token
> response or telling the client to resend the token request after a specific
> time so that user interaction can complete on the second device.
>
>
>
> The shortcut by directly calling the Token endpoint has a few advantages:
>
>
>
>    - No iframe with redirect which might end up in a failure not
>    captured. Also no redirect_uri necessary.
>    - No need for PKCE and state
>    - Just one request to obtain the Token(s)
>
>
>
> I hope to get your feedback about this.
>
>
>
> Thanks,
>
> Kai
>
>
>
> *From: *OAuth <oauth-bounces@ietf.org> on behalf of Aaron Parecki <aaron=
> 40parecki.com@dmarc.ietf.org>
> *Date: *Monday, 23. October 2023 at 18:22
> *To: *"oauth@ietf.org" <oauth@ietf.org>
> *Subject: *Re: [OAUTH-WG] I-D Action:
> draft-ietf-oauth-browser-based-apps-15.txt
>
>
>
> After a lot of discussion on the mailing list over the last few months,
> and after some excellent discussions at the OAuth Security Workshop, we've
> been working on revising the draft to provide clearer guidance and clearer
> discussion of the threats and consequences of the various architectural
> patterns in the draft.
>
> I would like to give a huge thanks to Philippe De Ryck for stepping up to
> work on this draft as a co-author!
>
> This version is a huge restructuring of the draft and now starts with a
> concrete description of possible threats of malicious JavaScript as well as
> the consequences of each. The architectural patterns have been updated to
> reference which of each threat is mitigated by the pattern. This
> restructuring should help readers make a better informed decision by being
> able to evaluate the risks and benefits of each solution.
>
> https://datatracker.ietf.org/doc/html/draft-ietf-oauth-browser-based-apps
>
>
>
> https://www.ietf.org/archive/id/draft-ietf-oauth-browser-based-apps-15.html
>
> Please give this a read, I am confident that this is a major improvement
> to the draft!
>
>
>
> Aaron
>
>
>
> On Mon, Oct 23, 2023 at 8:35 AM <internet-drafts@ietf.org> wrote:
>
> Internet-Draft draft-ietf-oauth-browser-based-apps-15.txt is now
> available. It
> is a work item of the Web Authorization Protocol (OAUTH) WG of the IETF.
>
>    Title:   OAuth 2.0 for Browser-Based Apps
>    Authors: Aaron Parecki
>             David Waite
>             Philippe De Ryck
>    Name:    draft-ietf-oauth-browser-based-apps-15.txt
>    Pages:   58
>    Dates:   2023-10-23
>
> Abstract:
>
>    This specification details the threats, attack consequences, security
>    considerations and best practices that must be taken into account
>    when developing browser-based applications that use OAuth 2.0.
>
> Discussion Venues
>
>    This note is to be removed before publishing as an RFC.
>
>    Discussion of this document takes place on the Web Authorization
>    Protocol Working Group mailing list (oauth@ietf.org), which is
>    archived at https://mailarchive.ietf.org/arch/browse/oauth/.
>
>    Source for this draft and an issue tracker can be found at
>    https://github.com/oauth-wg/oauth-browser-based-apps.
>
> The IETF datatracker status page for this Internet-Draft is:
> https://datatracker.ietf.org/doc/draft-ietf-oauth-browser-based-apps/
>
> There is also an HTML version available at:
> https://www.ietf.org/archive/id/draft-ietf-oauth-browser-based-apps-15.html
>
> A diff from the previous version is available at:
>
> https://author-tools.ietf.org/iddiff?url2=draft-ietf-oauth-browser-based-apps-15
>
> Internet-Drafts are also available by rsync at:
> rsync.ietf.org::internet-drafts
>
>
> _______________________________________________
> 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
>