Re: [OAUTH-WG] Cookies & headers in OAuth 2.0 Security Best Current Practice?

Philippe De Ryck <philippe@pragmaticwebsecurity.com> Mon, 06 November 2023 16:45 UTC

Return-Path: <philippe@pragmaticwebsecurity.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 8ED37C17C8BC for <oauth@ietfa.amsl.com>; Mon, 6 Nov 2023 08:45:50 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.105
X-Spam-Level:
X-Spam-Status: No, score=-7.105 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_HI=-5, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, 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=pragmaticwebsecurity.com header.b="EuIfyJnJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.b="Q1ZP4kpk"
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 j9faHvudNhTL for <oauth@ietfa.amsl.com>; Mon, 6 Nov 2023 08:45:46 -0800 (PST)
Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 EEA60C17C8A4 for <oauth@ietf.org>; Mon, 6 Nov 2023 08:45:45 -0800 (PST)
Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id BA6605C029D; Mon, 6 Nov 2023 11:45:42 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 06 Nov 2023 11:45:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= pragmaticwebsecurity.com; h=cc:cc:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1699289142; x=1699375542; bh=cnvYDxZTHpLweYrREuP4cRWsIls11feo9v2 OEpuIK4Q=; b=EuIfyJnJ6Bt1o8wwEnsleAigAt1AF4z98lykiKz77I3lgrxbX1D /9Hb+Dwyuj+Iyif5DYJk56GbG96peu9oXKr3JZ2i11b0B0u1kMzYkOgePUNcTvkB KECXwMDeCAWe9BN2HjVf4SyvUWSqcMsjl5rXMypEUJcoXPqdBNFUf3bKN4b+7b+m nH3FbX5QMtqy8BT7YSFwLRCb4yyHmCTb3kqP5d0JXEJhbq/7psy3IkPb6LvggFpM dtQd7JUNhI5ec2MLMhC/S2EkN2Y+7IVp+LZ3hzu7IN6+G3UdpFzep2THsM+tnJLi qcBoMhw9kypGdFSm+GcktYLksDvyYjcw1+g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1699289142; x=1699375542; bh=cnvYDxZTHpLwe YrREuP4cRWsIls11feo9v2OEpuIK4Q=; b=Q1ZP4kpkOxrnPeqnZ4M92aGYtVPJZ JmhoYTsjmUBjQD6hbCvaA854VMVjegNWTIUsSNjwBbPMk9KGae3i3j6vzgSwkWC6 QsLhWKnneeEHdrWR6mn57u5hiY+0o91+tle1ksAd5PKMyhNSLgzTziGFvJC68UCY fP+utiJc6JgL9bJc35camjpmCgOO1piit09haAyJ1tXm3gLzlVgokwZQcU7hcKVF +LDfZRRyWAQ5+Y4MYzK/Qo48PIaLkv1faRFP80m+t/PZD2am/l4KqQROJ6n0jCko lWqz3cg3z081ec4sEHVJrCQxx1i7vFsYB9LYJEpKf6MQIwrIACh1ynn6g==
X-ME-Sender: <xms:NhhJZVxt6uTYoHvrMOVgrQ8iUPp9I2havXulPOkYK8q6uyM52U_T1A> <xme:NhhJZVRU1_aNQ67gq9G0rm1C3mVH8kPTU5gM1DE1GGJD-WnB0GxHyCuUjKZfq9pk2 bKc7UQWIeNUgWcjkw>
X-ME-Received: <xmr:NhhJZfW3QhwxxcBcDAodL5WBteDUlHqyl0Sd0pMv5HG-1H6YmIS6RlYsIOtHVVaYSJJVXMFTBqPCzFKmMksQgFPw0NPg0ug>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddugedgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhushhpvggtthffohhmrghinhculdegledmnecujfgurhephffktgggufffjgevvfhf ofesrgdtmherhhdtjeenucfhrhhomheprfhhihhlihhpphgvucffvgcutfihtghkuceoph hhihhlihhpphgvsehprhgrghhmrghtihgtfigvsghsvggtuhhrihhthidrtghomheqnecu ggftrfgrthhtvghrnhepiefhudejgeevheffgefhheeiveefvefhjedvudfgfffgjedtle fgleeuheeuueffnecuffhomhgrihhnpehprhgrghhmrghtihgtfigvsghsvggtuhhrihht hidrtghomhdpghhithhhuhgsrdhiohdpihgvthhfrdhorhhgpdhhthhtphhhvggruggvrh hsrdhmhienucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehphhhilhhiphhpvgesphhrrghgmhgrthhitgifvggsshgvtghurhhithihrdgtohhm
X-ME-Proxy: <xmx:NhhJZXjdbUos5MhhR99wRVF0pineoe8zeMa06Rum93n2Lt8ACBaLFA> <xmx:NhhJZXDgpNwXxkT4C_5VcC2kd97apv2QT-DrF5HgXSuqIhk-M59AlQ> <xmx:NhhJZQLM_psukOlNrcCzmdmiG0Sbh--tF3jgmEONsLaRI_QS0ynuXA> <xmx:NhhJZePvf_wO7q1Ry2YXroB-xyBWMu9JmOz1m1oNkRNG76Ip4t4qrw>
Feedback-ID: i21e1449f:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Nov 2023 11:45:41 -0500 (EST)
From: Philippe De Ryck <philippe@pragmaticwebsecurity.com>
Message-Id: <D3DF8002-B819-4E60-AF46-71D4F47822AE@pragmaticwebsecurity.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_A4FCAAAF-293F-4A95-9A0A-C194B4334179"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\))
Date: Mon, 06 Nov 2023 17:45:39 +0100
In-Reply-To: <CAD9ie-tEhWrEKeByEFx+Tvfk6_LTwzDfAZy9gq_dib2zfqz7tQ@mail.gmail.com>
Cc: Giuseppe De Marco <demarcog83@gmail.com>, Daniel Fett <fett=40danielfett.de@dmarc.ietf.org>, Aaron Parecki <aaron=40parecki.com@dmarc.ietf.org>, oauth@ietf.org
To: Dick.Hardt@gmail.com
References: <CAD9ie-sh0qnGzg5VwU_enq2Br9hH5zgm86z9i7vdMj_uQs=4yA@mail.gmail.com> <CAGBSGjrMDrXMd2ApKmLn_LVgMSLME-wvHqPCTpzgDxk5_+kRSA@mail.gmail.com> <f6383d62-9586-49c9-a824-9d92288ee4bd@danielfett.de> <CAGBSGjqe2HjJuh6OgJy5VU+w8HRyu159uJtMnmXS+LPWg_LphA@mail.gmail.com> <CAD9ie-sfrzEMvS8yk49XSNfvwRbcj1tPKfmNxC97VAF4pRqcfg@mail.gmail.com> <C3E1A2E4-AFE0-4C85-8F53-0C1C0154107A@gmail.com> <CAP_qYyktwsB_d0pqhMacM3Ma+wMUdDdKT56EMv6LY2xKndRVQA@mail.gmail.com> <CAD9ie-tEhWrEKeByEFx+Tvfk6_LTwzDfAZy9gq_dib2zfqz7tQ@mail.gmail.com>
X-Mailer: Apple Mail (2.3731.600.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/YTB5F6pTR4EPwkRHDTzBZwD6wT4>
Subject: Re: [OAUTH-WG] Cookies & headers in OAuth 2.0 Security Best Current Practice?
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: Mon, 06 Nov 2023 16:45:50 -0000

While I understand the idea of pointing to additional security resources, I’m not sure if it is the role of the security BCP (or other specs) to take on the responsibility to address these issues. In my point of view, the security BCP should focus on OAuth aspects, and discuss security topics that are directly relevant to that purpose. 

Concretely for the security mechanisms discussed here, I can see how cookie configurations could be relevant (the session with the AS is inherent to OAuth), but I don’t see defenses such as CSP as relevant in that scope. If these are in scope, should we then also provide advice or pointers on avoiding server-side implementation vulnerabilities, such as SQL injection or SSRF?

Additionally, many of these security mechanisms are quite complex and non-trivial to deploy. For example, adding a generic pointer stating “you should add CSP” does not say much, as CSP can control more than a dozen features. 

To summarize, I would keep the scope of these specs as narrow as possible and avoid aiming to address security concerns that are beyond the realm of OAuth.

Philippe

—
Pragmatic Web Security
Security for developers
https://pragmaticwebsecurity.com

> On 6 Nov 2023, at 15:39, Dick Hardt <dick.hardt@gmail.com> wrote:
> 
> +1 to referring to calling out that cookies / headers should follow best security practice, and pointing to living documents
> 
> On Mon, Nov 6, 2023 at 6:21 AM Giuseppe De Marco <demarcog83@gmail.com <mailto:demarcog83@gmail.com>> wrote:
>> Hi,
>> 
>> everytime I have implemented SAML2, OAuth 2.0, OpenID Connect, for different projects and orgs, I have included secured web cookie in the recipe.
>> For the implementation profile of OpenID4VP I did the same, where the secured and httponly cookie is used an in particular as a basic security requirement for the cross device flow [1].
>> 
>> Even if I got perfectly Daniel's and Aaron's editorial strategy and I agree, I think that Dick's proposal and your confirmation on that, Neil, is something to take into account to bring developers awareness during the implementation phases.
>> A ref to living OWASP specs surrounded by a generic refs to the user agent security, even if out of scope, I think that should be in the specs.
>> 
>> [1] https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/relying-party-solution.html#remote-protocol-flow
>> 
>> Il giorno lun 6 nov 2023 alle ore 15:11 Neil Madden <neil.e.madden@gmail.com <mailto:neil.e.madden@gmail.com>> ha scritto:
>>> Although I think we could add some basic advice, the list of security headers to use is still evolving. For example, there were several headers added after Spectre to limit cross-site interactions. And then there’s things like the “X-XSS-Protection” header, which was best practice to add to responses not too long ago but has now been universally removed from browsers as it enabled certain content disclosure attacks.
>>> 
>>> Cookie security attributes are perhaps a bit more stable, but in general we probably just want to point people at “living” guidance like OWASP.
>>> 
>>> — Neil
>>> 
>>>> On 5 Nov 2023, at 19:28, Dick Hardt <dick.hardt@gmail.com <mailto:dick.hardt@gmail.com>> wrote:
>>>> 
>>>> The cookie and header recommendations I am thinking of would be for the AS as well as the client. 
>>>> 
>>>> A number of XSS attacks can be thwarted by a modern browser and the right HTTP headers.
>>>> 
>>>> My question is: Did the authors consider adding cookie and header recommendations, and decided it was too general? 
>>>> 
>>>> Cookie and header best security practices have been around for years -- I'm not suggesting we make anything up -- I'm suggesting we raise awareness. 
>>>> 
>>>> I consider myself to be fairly security aware, and I was not aware of some of the HTTP headers that are best security practice. 
>>>> 
>>>> /Dick
>>>> 
>>>> 
>>>> On Sun, Nov 5, 2023 at 11:19 AM Aaron Parecki <aaron=40parecki.com@dmarc.ietf.org <mailto:40parecki.com@dmarc.ietf.org>> wrote:
>>>>> I don't think it's necessary to say "do the right things with cookies" in the Security BCP. The Browser Apps BCP has a much deeper discussion of how different browser-based architectures work with cookies so that seems like a better place to actually have a real discussion about it.
>>>>> 
>>>>> Also +1 to what Daniel said about not continuing to add little things. Plus I think it's too late anyway, publication has already been requested for the Security BCP.
>>>>> 
>>>>> Aaron
>>>>> 
>>>>> On Sun, Nov 5, 2023 at 11:14 AM Daniel Fett <fett=40danielfett.de@dmarc.ietf.org <mailto:40danielfett.de@dmarc.ietf.org>> wrote:
>>>>>> I agree with Aaron! 
>>>>>> 
>>>>>> Also we should be very careful about any additions to the Security BCP at this point. It is very easy to re-start the "one more thing" loop we've been stuck in for the last years. There may be more useful things to say, but we should put them on the list for a future second version of the BCP.
>>>>>> 
>>>>>> -Daniel
>>>>>> 
>>>>>> Am 05.11.23 um 20:03 schrieb Aaron Parecki:
>>>>>>> I don't think the Security BCP should incorporate cookie best practices directly in the document. If anything, it sounds like possibly a candidate for inclusion in the Browser Apps BCP. 
>>>>>>> 
>>>>>>> There are already some mentions of these cookie properties mentioned in the Browser Apps BCP, though only in reference to specific architectures, not as a general best practice. For example:
>>>>>>> 
>>>>>>> https://www.ietf.org/archive/id/draft-ietf-oauth-browser-based-apps-15.html#pattern-bff-cookie-security
>>>>>>> 
>>>>>>> Aaron
>>>>>>> 
>>>>>>> On Sun, Nov 5, 2023 at 10:48 AM Dick Hardt <dick.hardt@gmail.com <mailto:dick.hardt@gmail.com>> wrote:
>>>>>>>> Hey
>>>>>>>> 
>>>>>>>> I was reviewing security on some sites I managed and checked to see if the recommendations were in the BCP.
>>>>>>>> 
>>>>>>>> I don't see anything around cookies such as httpOnly, sameSite, secure. 
>>>>>>>> 
>>>>>>>> I saw some HTTP security header suggestions buried in 4.16 (X-Frame-Options, CSP), but not for Strict-Transport-Security, Permissions-Policy, or X-Content-Type-Options, and the CSP guidance is rather vague.
>>>>>>>> 
>>>>>>>> I understand these are general web security best practices, and perhaps I missed it, but I think it would be useful to call out that best security practices around cookies and headers should also be followed in Section 2, and either have the best practices included, or direct the reader where to find them.
>>>>>>>> 
>>>>>>>> /Dick
>>>>>>>> 
>>>>>>>> _______________________________________________
>>>>>>>> OAuth mailing list
>>>>>>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>>>>>>> https://www.ietf.org/mailman/listinfo/oauth
>>>>>>> 
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> OAuth mailing list
>>>>>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>>>>>> https://www.ietf.org/mailman/listinfo/oauth
>>>>>> _______________________________________________
>>>>>> OAuth mailing list
>>>>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>>>>> https://www.ietf.org/mailman/listinfo/oauth
>>>>> _______________________________________________
>>>>> OAuth mailing list
>>>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>>>> https://www.ietf.org/mailman/listinfo/oauth
>>>> _______________________________________________
>>>> OAuth mailing list
>>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>>> https://www.ietf.org/mailman/listinfo/oauth
>>> 
>>> _______________________________________________
>>> OAuth mailing list
>>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>>> https://www.ietf.org/mailman/listinfo/oauth
> _______________________________________________
> OAuth mailing list
> OAuth@ietf.org
> https://www.ietf.org/mailman/listinfo/oauth