Re: [OAUTH-WG] [EXTERNAL] Rotating RTs and grace periods

David Waite <david@alkaline-solutions.com> Tue, 02 November 2021 22:21 UTC

Return-Path: <david@alkaline-solutions.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 332913A0E14 for <oauth@ietfa.amsl.com>; Tue, 2 Nov 2021 15:21:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.997
X-Spam-Level:
X-Spam-Status: No, score=-1.997 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, HTTPS_HTTP_MISMATCH=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=alkaline-solutions.com
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 l2ZI2OqwWG6c for <oauth@ietfa.amsl.com>; Tue, 2 Nov 2021 15:21:21 -0700 (PDT)
Received: from caesium6.alkaline.solutions (caesium6.alkaline.solutions [157.230.133.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 05D4A3A0E0F for <oauth@ietf.org>; Tue, 2 Nov 2021 15:21:20 -0700 (PDT)
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by caesium6.alkaline.solutions (Postfix) with ESMTPA id 65DC720650A; Tue, 2 Nov 2021 22:21:15 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alkaline-solutions.com; s=dkim; t=1635891676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yl/kuT46slrgc2CoJJd8BdoutKuV2swP8NL6nPpOFCk=; b=EKH1BFejrvWnQ0jqOfGuxoFpzIA2TBI31aNzAQkwo+ZPJp/UNQ/0MEimvVeykFjFrk+gDW vWMNQzYpbpNHDtclVqIY8hcb4NMOFuJpyP7nxwgYNoQogBqy3yhVnV1euxKD76U9/1EYZB Y/bA3ZvOEt0118kmqtCnUB4Whvt+9JM=
From: David Waite <david@alkaline-solutions.com>
Message-Id: <297E366B-1A3A-471E-BF30-A27AC2907CA5@alkaline-solutions.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_DB130E35-3719-4540-A838-6EFA6A722659"
Mime-Version: 1.0
Date: Tue, 02 Nov 2021 16:21:14 -0600
In-Reply-To: <3EE54DA7-F92F-4CF7-9DE1-9BEE9C14CD35@forgerock.com>
Cc: Pieter Kasselman <pieter.kasselman@microsoft.com>, oauth <oauth@ietf.org>
To: Neil Madden <neil.madden@forgerock.com>
References: <AM7PR83MB0452C77D32B98A7409681699918B9@AM7PR83MB0452.EURPRD83.prod.outlook.com> <3EE54DA7-F92F-4CF7-9DE1-9BEE9C14CD35@forgerock.com>
Authentication-Results: caesium6.alkaline.solutions; auth=pass smtp.mailfrom=david@alkaline-solutions.com
X-Spamd-Bar: +
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/CTmi_XNYi-sNYG3wHQKeiXSfB5M>
Subject: Re: [OAUTH-WG] [EXTERNAL] Rotating RTs and grace periods
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.29
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: Tue, 02 Nov 2021 22:21:26 -0000

My perspective is that the rotation of refresh tokens is an AS mechanism to push for one-time-usage and break idempotency. This is specifically employed to reduce the impact in scenarios where the refresh token can be leaked and used by a third party attacker. A leaked refresh token can only be used in environments where the client credentials required for a refresh grant can also be leaked.

So,

1. Refresh token rotation is just one mechanism an AS could use to attempt to make reuse of leaked refresh tokens harder. Therefore it is entirely acceptable for an AS to have a policy around a grace period, as well as other policies - the goal is to try to make attacker’s jobs harder while letting through as many legitimate requests as possible

2. In scenarios where the client is expected to have non-exfiltratable credentials, the need for these sorts of protections goes down possibly to zero. Of course, this has a component of the AS trust of the client, e.g. to not be leveraging exportable keys.

-DW

> On Nov 2, 2021, at 3:20 PM, Neil Madden <neil.madden@forgerock.com> wrote:
> 
> The grace period is to allow the client to retry if it fails to receive the new RT for any reason. For example, the client performs a successful refresh flow but loses mobile network signal before receiving the response. The grace period allows the client to simply retry the request, whereas without a grace period the first request would have invalidated the old RT leaving the client with no option but to perform a full authorization flow again to get a new one. 
> 
> I’m generally against allowing a grace period at all, but given that it’s a common request and some implementations are already allowing this, I’m hoping we can find some wording we can all agree on. 
> 
> I agree that a grace period is more acceptable if the RT is sender-constrained by something like DPoP, but then in that case does RT rotation add anything anyway? The current BCP lists these two as either/or rather than defence in depth. 
> 
> — Neil
> 
>> On 2 Nov 2021, at 14:09, Pieter Kasselman <pieter.kasselman@microsoft.com> wrote:
>> 
>> 
>> Neil
>>  
>> Is the goal to accommodate network latency or clock drift? It would be helpful to include reasons for why a grace period should be considered if it is allowed.
>>  
>> Without knowing the reasons for the grace period it is not clear why a grace period is a better solution than just extending the expiry time by a set time (60 seconds in your example) and having the client present the token a little earlier.
>>  
>> If grace periods are allowed, it may be worth considering adding additional mitigations against replay. For example, a grace period may be allowed if the refresh token is sender constrained with DPoP so there is at least some assurances that the request is originating from the sender (especially if the nonce option is used with DPoP).
>>  
>> I would worry about adding more complexity and less predictability by adding grace periods though (e.g. by looking at a refresh token, will you be able to tell if it can still be used or not), but your point that implementors may solve for it in other less predictable ways raises a valid point.
>>  
>> Cheers
>>  
>> Pieter
>>  
>> From: OAuth <oauth-bounces@ietf.org> On Behalf Of Neil Madden
>> Sent: Tuesday 2 November 2021 10:29
>> To: oauth <oauth@ietf.org>
>> Subject: [EXTERNAL] [OAUTH-WG] Rotating RTs and grace periods
>>  
>> Hi all,
>>  
>> There was a previous discussion on whether to allow a grace period during refresh token rotation, allowing the client to retry a refresh if the response fails to be received due to some transient network issue/timeout [1]. Vittorio mentioned that Auth0 already implement such a grace period. We (ForgeRock) currently do not, but we do periodically receive requests to support this. The current security BCP draft is silent on whether implementing such a grace period is a good idea, but I think we should add some guidance here one way or another.
>>  
>> My own opinion is that a grace period is not a good idea, and if it is to be supported as an option then it should be kept as short as possible. The reason (as I mentioned in the previous thread) is that it is quite easy for an attacker to observe when a legitimate client performs a refresh flow and so can easily sneak in their own request afterwards within the grace period. There are several reasons why it is easy for an attacker to observe this:
>>  
>> - RT rotation is primarily intended for public clients, such as mobile apps and SPAs. These clients are geographically distributed across the internet, and so there is a good chance that the attacker is able to observe the network traffic of at least some of these client instances.
>> - The refresh flow is typically the only request that the client makes directly to the AS after initial authorization, so despite the traffic being encrypted it is very easy for an observer to determine that the client is performing a refresh whenever it makes any connection to the AS.
>> - As well as observing the request itself, an attacker may be able to observe the DNS lookup for the AS hostname instead, which is even more likely to be observable and also in plaintext most of the time.
>> - An attacker in a position to steal RTs from e.g. localStorage, is probably also in a good position to either observe when the legitimate client refreshes or to actually force it to refresh early (e.g., by deleting the corresponding AT from the same storage).
>>  
>> I know some people argue that a grace period is a reasonable trade-off between security and usability. But I think that this kind of attack would be quite easy to carry out in practice for the reasons I suggest above, so I think the security actually degrades extremely quickly if you allow a grace period of any reasonable length. 
>>  
>> On the other hand, if we discourage this entirely then people may use dubious workarounds instead (e.g., one proposal I’ve seen was to use an ID token with the JWT Bearer grant, effectively turning the ID Token into an ad-hoc RT with much fewer protections).
>>  
>> As a strawman, what would people think of wording like the following:
>>  
>> ---
>> The AS MAY allow the original RT to be replayed for a short grace period to allow the client to recover if the response is not received due to a network problem or other transient issue. However, implementors should be aware that an attacker may be able to easily observe when the legitimate client makes a refresh request to the AS and so time their use of a stolen RT to occur within the grace period. Any grace period MUST be kept as short as possible, and MUST NOT exceed 60 seconds. Clients should prefer sender-constrained refresh tokens if recovery from network issues is a priority.
>> —
>>  
>> (The 60 seconds limit here is based on Auth0’s grace period).
>>  
>> [1]: https://mailarchive.ietf.org/arch/msg/oauth/WXwKxQM2poW7bqOOGGp4POYolFk/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailarchive.ietf.org%2Farch%2Fmsg%2Foauth%2FWXwKxQM2poW7bqOOGGp4POYolFk%2F&data=04%7C01%7Cpieter.kasselman%40microsoft.com%7Cbdb0969234774ba6f87608d99deba06c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637714457664531224%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CDskCHwXxJxGdmudTW33gUT5f3%2B835uZDxyNEmKkiFc%3D&reserved=0> 
>>  
>> Kind regards,
>>  
>> Neil
>> 
> _______________________________________________
> OAuth mailing list
> OAuth@ietf.org
> https://www.ietf.org/mailman/listinfo/oauth