[OAUTH-WG] Re: Browser-Based Applications - Document Shepherd Review

Philippe De Ryck <philippe@pragmaticwebsecurity.com> Tue, 17 December 2024 07:07 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 2AA99C14F61D for <oauth@ietfa.amsl.com>; Mon, 16 Dec 2024 23:07:53 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.103
X-Spam-Level:
X-Spam-Status: No, score=-2.103 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=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=pragmaticwebsecurity.com header.b="p91CyJxD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.b="DrSR2T96"
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 TGNMdsi5sKRq for <oauth@ietfa.amsl.com>; Mon, 16 Dec 2024 23:07:48 -0800 (PST)
Received: from fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 52D7DC14F619 for <oauth@ietf.org>; Mon, 16 Dec 2024 23:07:48 -0800 (PST)
Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 3F4D5114012C; Tue, 17 Dec 2024 02:07:47 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 17 Dec 2024 02:07:47 -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:subject:subject:to:to; s=fm1; t=1734419267; x=1734505667; bh=Msg3iZIrfRP/EAVHoE0KG6jhszEbku8UGNJtzfbvCAI=; b= p91CyJxDRmxK0qgYeLaoRfg07juy0lBUJVafduTcoFGhaKKwEM1y7pjhE222l60/ NZTV2YlHQvJRdsvRp+ePPlMcIpFznVMwxL6Dq9lllESfuje/sxQoLNNSmJMoHP37 b6z2nXdRPolouWGtBdtwm2uUTbyphtE7G00X4tp/a73hfo3CWxaCL5tZjFYTZ+Rs wVzllPuaQanavKVEex/AQlzwRUZgI1vzotVD+QEwsWa5lkWUxsP34tzR+UK+em2s Nl2jp9DJEHu1FuNQNP9NRWSNFsQldRKf7oGiDoQl9TUoRztTfcn4srnntjc3Q0zD B5iKt2z5lAtyJpBV4E4PIQ==
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:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1734419267; x=1734505667; bh=Msg3iZIrfRP/EAVHoE0KG6jhszEbku8UGNJ tzfbvCAI=; b=DrSR2T96MPuQP6HECWbRTw9+Yj935s6ABH6u6edwV9rrjI1cUw6 U+fEu7jNfV/x3blzbj4EFi59ZETBN9BG+bfv/fdvqY3OvxXl7AeWD63cL8LapdzA mP5DtIfkV9Ie7zH4ntTVbGbAZ6YfFo4R/TwdmMqS/gc0cmV/YrvbPnywmHlITr8R qz62daPPbz4NZ1VZPS9ucpf4S8ViyCxtICOu98oMqpsgYglOpKROB49C0ya5MY9B CYCb671KDVX+9p3o+o4MF50XpsucBnkpJhZkDm7dWzQ1C5J1e91NCEvc5WnZurNP dZt+IpY5eT1mjCKHo6n7+h1jmQoqgRELQKA==
X-ME-Sender: <xms:QiNhZ735fN8V3sKOdSqazjhT-_Guw_D183dGVNR_bTIEYYdCjkUL3A> <xme:QiNhZ6E_yNjYYl50L5bs6NR2qj66vnukqgFhMtitS7L552nP79rxtpyhdaoSGi4YP J8giPm3rLVdlsP1eA>
X-ME-Received: <xmr:QiNhZ74VOnQqJKpyZXpQVSL3gJof5MXo4oAFO7vst0FC5L_4B4pHhcIEqwyi3WGwwsHFfAzuvSDdf0KanQ4_MLZcXzc5vblZ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrleeggddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhkfgtgg fuffgjvefvfhfosegrtdhmrehhtdejnecuhfhrohhmpefrhhhilhhiphhpvgcuffgvucft higtkhcuoehphhhilhhiphhpvgesphhrrghgmhgrthhitgifvggsshgvtghurhhithihrd gtohhmqeenucggtffrrghtthgvrhhnpefhfeefgefhleetkeeftdelieefhfefffekfedu jedtgfetleegffduffevteekkeenucffohhmrghinhepphhorhhtshifihhgghgvrhdrnh gvthdpphhrrghgmhgrthhitgifvggsshgvtghurhhithihrdgtohhmnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhihhlihhpphgvsehprh grghhmrghtihgtfigvsghsvggtuhhrihhthidrtghomhdpnhgspghrtghpthhtohepvddp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprhhifhgrrghtrdhsrdhivghtfhesgh hmrghilhdrtghomhdprhgtphhtthhopehorghuthhhsehivghtfhdrohhrgh
X-ME-Proxy: <xmx:QiNhZw1iT8Aamp0Wr-eiTsnTKI0b-kqPaFXgNg2R8QcXyMimTajfUQ> <xmx:QiNhZ-ExJBqecGycHkvhYyxV0K8rmlPto1rvxb5FH0RHFITl_5YPVg> <xmx:QiNhZx__i0AVfTx0ettAlWV1_4dBIKQpjSggs6dA0ozV--ciQb4lnA> <xmx:QiNhZ7kLA8jGDfvKCM5GANUCwW-ITqMNFXN4fCfLpN4HTUJNe94U8A> <xmx:QyNhZzQ69Ypn038i0VnGuQwSmbdZC409RNtA-Okv1OILVd02C9g9CI79>
Feedback-ID: i21e1449f:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Dec 2024 02:07:46 -0500 (EST)
From: Philippe De Ryck <philippe@pragmaticwebsecurity.com>
Message-Id: <C51F49D4-4AFE-4DE4-AC44-59006789CDBA@pragmaticwebsecurity.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_D2875269-9121-47CA-B757-604150B3FE29"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.200.121\))
Date: Tue, 17 Dec 2024 08:07:34 +0100
In-Reply-To: <CADNypP-jStnCi7n7MQ+EhVFwUOhDMmTcyh086FRVmY4hpWm1VA@mail.gmail.com>
To: Rifaat Shekh-Yusef <rifaat.s.ietf@gmail.com>
References: <CADNypP-jStnCi7n7MQ+EhVFwUOhDMmTcyh086FRVmY4hpWm1VA@mail.gmail.com>
X-Mailer: Apple Mail (2.3826.200.121)
Message-ID-Hash: J6R56PQRPR6VNYWB5EQ3XT2QIVZBTWGL
X-Message-ID-Hash: J6R56PQRPR6VNYWB5EQ3XT2QIVZBTWGL
X-MailFrom: philippe@pragmaticwebsecurity.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-oauth.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: oauth <oauth@ietf.org>
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [OAUTH-WG] Re: Browser-Based Applications - Document Shepherd Review
List-Id: OAUTH WG <oauth.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/ytxDz7dZW4C6LJ4ZG-tFj_hBI6c>
List-Archive: <https://mailarchive.ietf.org/arch/browse/oauth>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Owner: <mailto:oauth-owner@ietf.org>
List-Post: <mailto:oauth@ietf.org>
List-Subscribe: <mailto:oauth-join@ietf.org>
List-Unsubscribe: <mailto:oauth-leave@ietf.org>

Hi Rifaat,

Thank you for the detailed review comments. It took me a while to find some space in my schedule, but I’ve gone through them and addressed most of them in the document. There is one comment that I wanted to follow up here …


> Section 6.1.3.3.2
> I might be missing something here:
> “For such requests, named "CORS-safelisted Requests", the browser will simply send the request and prevent access to the response if the server did not send the proper CORS headers.”
> The above statement indicates that for these requests, the browser ignores the response if it did not get a proper CORS from the server.
> 
> “The consequence of this behavior is that certain endpoints of the resource server could become vulnerable to CSRF, even with CORS enabled as a defense. For example, if the resource server is an API that exposes an endpoint to a body-less POST request, there will be no preflight request and no CSRF defense.”
> This implies that just because there is no preflight request, that the server is vulnerable; would not the browser just ignore the response as indicated in the previous statement?


Your interpretation is correct, and I’ll try to clarify.

In a CSRF attack, the attacker triggers a state-changing operation on the server in the name of the user. When the attacker manages to send such a malicious request without a preflight, the server would process it, and then send a response without proper CORS headers in the response. The browser would ignore this response, as you stated, but at that point, the damage (i.e., a state changing operation) has already been done. 

This type of attack is possible with a body-less POST, or on an API endpoint that accepts JSON with a text/plain Content-Type header (e.g., https://portswigger.net/daily-swig/vulnerability-in-dating-site-okcupid-could-be-used-to-trick-users-into-liking-or-messaging-other-profiles) 

By forcing every request to be non-safelisted, the browser will always send a preflight first, which the server will not agree to. As a result, the browser does not send the actual malicious request.

The approach in the spec to make every request non-safelisted is requiring a custom request header. This always works, and it does not affect same-origin requests in any way, so it is straightforward to implement. Additionally, it does not require a developer to carefully scrutinize each API endpoint to determine if it may be reachable with a safelisted request (which is very nuanced and painstakingly hard to get right). 


I hope this helps. If you feel that there’s an update needed in the spec, feel free to let me know.

Kind regards

Philippe

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