Re: [OAUTH-WG] Evaluation of Scope Management in Refresh Token Behavior

Neil Madden <neil.e.madden@gmail.com> Tue, 20 February 2024 19:42 UTC

Return-Path: <neil.e.madden@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 A5A56C180B63 for <oauth@ietfa.amsl.com>; Tue, 20 Feb 2024 11:42:34 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.084
X-Spam-Level:
X-Spam-Status: No, score=-1.084 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, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01, T_REMOTE_IMAGE=0.01, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 ZU2Z7T26hq1X for <oauth@ietfa.amsl.com>; Tue, 20 Feb 2024 11:42:30 -0800 (PST)
Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 418BAC180B5D for <oauth@ietf.org>; Tue, 20 Feb 2024 11:42:30 -0800 (PST)
Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-411baa02bc3so13501725e9.1 for <oauth@ietf.org>; Tue, 20 Feb 2024 11:42:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708458148; x=1709062948; darn=ietf.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=kW075mX07Jx/Flssh0KlpSm3s2qXCfJ+TicRa7kk32s=; b=fnZNBzys++m9OU5RkdbcpTENlI49Sl43fNfIT8NMNGKSqMXt9QrpCB6R12q8WWS96q cg+sAepSGkY/UchZcdE0686KSJZ3Q71t0q78heprnh85MRbJl+okE4quUFXJVlvM120E IWl+EFclH7XXJq3X6GuMnpJfXL9g+4R6LBunw9nDFjxib38ze+JHm5IhBd3YI3W393Ub kq8CoiUK1AKh7XQ9s5k/YzKF5ZJwIxLq57oIRfs2C38lbKXydLkhiMktUp5Tq7uT0z25 x3x4ni6VY4Id2v9fo6Dk2UprpvvyJc3lbw4MpOfuxtD/mfHnxY6tDsDcy97Pj9hpsLkF laTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708458148; x=1709062948; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kW075mX07Jx/Flssh0KlpSm3s2qXCfJ+TicRa7kk32s=; b=S6RhqBAwSdDhbYHnZEdNFfCqRLkY7Q/K+aAAJd+jj7UPtLTTaeO47xyABcs95yq1aI 3oSaA2s7EIXQPT1/XAlG1zbnmLbCTWKDcXz5badDcAuUVVoYKLjCWzvemluvxpnZYsQE yXyWMzP+G/zpE9z1mHoO9HXBo9mgJX8b0pP3UaOGYyIdcYa3PcZY0uVVixKOUkyLvTmC PcGSBG/og1iQ4s0Udo7KqMao8iitMFpncOUaRK6OTTAVuRvQ419as1Ln8cVyVxT16ear IMWzuJflYsDOATMn3f1pYLLsrHAowuFxuiW3GkYPw9R/2tog7U6DGG1Ra+9l7VIWPYZ4 TP9Q==
X-Gm-Message-State: AOJu0Yyqp9rJCx6zyL35N7L/cpv7m/LMAAkj1c2wMIKUFeCqg1lqsC6r U4+wVmODL+T9INPRjgcEgVabA1/REoUR2i6yqJDy1xAZS3SUA5bJ
X-Google-Smtp-Source: AGHT+IE51Azn42igyyvmVoxKcHFVi+TS9hdHkOAQ9DvI7ILdIv10moBgbBk4enFsIef3iT0C8CGrHA==
X-Received: by 2002:a05:600c:198e:b0:412:6df1:e496 with SMTP id t14-20020a05600c198e00b004126df1e496mr2627350wmq.3.1708458147848; Tue, 20 Feb 2024 11:42:27 -0800 (PST)
Received: from smtpclient.apple ([213.31.127.136]) by smtp.gmail.com with ESMTPSA id ka7-20020a05600c584700b004101543e843sm51147wmb.10.2024.02.20.11.42.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2024 11:42:27 -0800 (PST)
From: Neil Madden <neil.e.madden@gmail.com>
Message-Id: <13C59DD4-94E0-47AC-9A7E-D7B463BD1552@gmail.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_176E6302-C505-4B91-86FB-C7F3EEC9D576"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\))
Date: Tue, 20 Feb 2024 19:42:25 +0000
In-Reply-To: <CAD=XBCqs-Qf7P--KvqQcJq37Agh3gn-bfwfj7tZvwdngx+4k+A@mail.gmail.com>
Cc: oauth <oauth@ietf.org>, janak@wso2.com, thilinasenarath97@gmail.com, "piraveena@wso2.com" <piraveena@wso2.com>
To: Sachin Mamoru <sachinmamoru@gmail.com>
References: <CAD=XBCog_o8GzpDMTYKvvi=2mneM0nW0vfCc=FubtOFNF5WM=A@mail.gmail.com> <374ADB2C-2F74-4B95-8CDA-3266089CD00C@gmail.com> <CAD=XBCqs-Qf7P--KvqQcJq37Agh3gn-bfwfj7tZvwdngx+4k+A@mail.gmail.com>
X-Mailer: Apple Mail (2.3696.120.41.1.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/-rvMzuJzcaHA1UFl5EV9RXXBlnY>
Subject: Re: [OAUTH-WG] Evaluation of Scope Management in Refresh Token Behavior
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: Tue, 20 Feb 2024 19:42:34 -0000

It sounds like they are violating the spec then. On the other hand, the fact that the scope can be "increased back to the original scope" maybe suggests the effective scope of the refresh token is still the same? Either way, the spec is pretty clear, regardless of what some vendor does.

-- Neil

> On 20 Feb 2024, at 19:26, Sachin Mamoru <sachinmamoru@gmail.com> wrote:
> 
> Hi Neil,
> 
> Thanks for the clarification.
> But Curity has a different approach and they implemented it according to the concept of narrowing down the refresh token scopes.
> 
> "The scope was originally read openid profile and after refresh the access was reduced to read profile (i.e., the access_token now only has read profile scope and any new tokens obtained using the refresh token daa38700-ba96-4ef1-8b30-5cb3527aae19 will have the same, reduced scope). Note that increasing the scope of access cannot be done in this way unless first reduced and increased back to the original scope."
> 
> [1] https://curity.io/resources/learn/refresh-tokens/#changing-scope-of-access-token-on-refresh <https://curity.io/resources/learn/refresh-tokens/#changing-scope-of-access-token-on-refresh>
> 
> Thanks & Regards,
> Sachin
> 
> On Tue, 20 Feb 2024 at 21:59, Neil Madden <neil.e.madden@gmail.com <mailto:neil.e.madden@gmail.com>> wrote:
> 
> 
>> On 20 Feb 2024, at 11:02, Sachin Mamoru <sachinmamoru@gmail.com <mailto:sachinmamoru@gmail.com>> wrote:
>> 
>> 
>> Hi Neil,
>> 
>> Does that mean it should be identical to the narrowed scope request or the original request scope?
> 
> It says it has to be identical to the scope of the existing refresh token in the request, not the scope specified in the request. So effectively you can never downscope a refresh token in this way. Whatever scope you specify, any RT returned must always retain the original scope. 
> 
> (There are other ways to downscope a RT, eg ForgeRock’s macaroons allow you to attenuate the scope if you wish). 
> 
> — Neil
> 
>> 
>> On Tue, 20 Feb 2024 at 16:31, Sachin Mamoru <sachinmamoru@gmail.com <mailto:sachinmamoru@gmail.com>> wrote:
>> 
>> 
>> On Tue, 20 Feb 2024 at 12:23, Neil Madden <neil.e.madden@gmail.com <mailto:neil.e.madden@gmail.com>> wrote:
>> 
>>> On 20 Feb 2024, at 06:44, Sachin Mamoru <sachinmamoru@gmail.com <mailto:sachinmamoru@gmail.com>> wrote:
>>> 
>>> 
>>> Hi All,
>>> 
>>> When we request an access token using 3 scopes (scope1, scope2, scope3).
>>> Then will receive a refresh token (refresh_token1) with the access token.
>>> 
>>> After that will request another access token with refresh_token1 and provide the scope list as scope1 and scope2 (Narrow down scopes).
>>> Similarly, get another refresh token (refresh_token2) with the access token.
>>> 
>>> Now if we request another access token with refresh_token2, we cannot request scope3, instead, we can either request both scope1 and scope2 or one of them.
>>> 
>>> But in the specification, didn't able to find anything related to narrow-down scopes with refresh token.
>>> 
>>> From Spec
>>> 
>>> 1.5.  Refresh Token - Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires or to obtain additional access tokens with identical or narrower scope (access tokens may have a shorter lifetime and fewer permissions than authorized by the resource owner).
>>> 
>>> 6.  Refreshing an Access Token
>>> The scope of the access request as described by Section 3.3.  The requested scope MUST NOT include any scope not originally granted by the resource owner, and if omitted is treated as equal to the scope originally granted by the resource owner.
>>> 
>>> https://datatracker.ietf.org/doc/html/rfc6749 <https://datatracker.ietf.org/doc/html/rfc6749>
>>> 
>>> IMO, from a security aspect, the current behaviour is much more secure because it is designed to maintain the principle of least privilege, where it updates the refresh token authorised scopes based on the requested ones.
>>> 
>>> What should be the correct behaviour?
>>> narrow-down scope refresh token should also be able to request access token with original scope list?
>> 
>> Also from section 6:
>> 
>> If a
>>    new refresh token is issued, the refresh token scope MUST be
>>    identical to that of the refresh token included by the client in the
>>    request.
>> 
>> 
>> 
>> 
>> — Neil
>> 
>> 
>> -- 
>> 
>>  	
>> Sachin Mamoru 
>> Software Engineer, WSO2
>> +94771292681 <tel:+94771292681>	
>> |	sachinmamoru.me  <https://sachinmamoru.me/>
>> sachinmamoru@gmail.com  <mailto:sachinmamoru@gmail.com>
>>  <https://www.linkedin.com/in/sachin-mamoru/>	 <https://twitter.com/MamoruSachin>
>> 
>> 
>> 
>> -- 
>> 
>>  	
>> Sachin Mamoru 
>> Software Engineer, WSO2
>> +94771292681 <tel:+94771292681>	
>> |	sachinmamoru.me  <https://sachinmamoru.me/>
>> sachinmamoru@gmail.com  <mailto:sachinmamoru@gmail.com>
>>  <https://www.linkedin.com/in/sachin-mamoru/>	 <https://twitter.com/MamoruSachin>
>> 
> 
> 
> -- 
> 
>  	
> Sachin Mamoru 
> Software Engineer, WSO2
> +94771292681 <tel:+94771292681>	
> |	sachinmamoru.me  <https://sachinmamoru.me/>
> sachinmamoru@gmail.com  <mailto:sachinmamoru@gmail.com>
>  <https://www.linkedin.com/in/sachin-mamoru/>	 <https://twitter.com/MamoruSachin>
>