Re: Signing Set-Cookie

Justin Richer <jricher@mit.edu> Wed, 08 June 2022 16:25 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id F0E25C157B4C for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 8 Jun 2022 09:25:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.761
X-Spam-Level:
X-Spam-Status: No, score=-2.761 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=mit.edu
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 E1qhwctT1oWu for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 8 Jun 2022 09:25:52 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0A8EFC157B41 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 8 Jun 2022 09:25:51 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.92) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1nyySv-0007Db-0L for ietf-http-wg-dist@listhub.w3.org; Wed, 08 Jun 2022 16:23:29 +0000
Resent-Date: Wed, 08 Jun 2022 16:23:29 +0000
Resent-Message-Id: <E1nyySv-0007Db-0L@lyra.w3.org>
Received: from mimas.w3.org ([128.30.52.79]) by lyra.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <jricher@mit.edu>) id 1nyySs-0007CS-IW for ietf-http-wg@listhub.w3.org; Wed, 08 Jun 2022 16:23:26 +0000
Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by mimas.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <jricher@mit.edu>) id 1nyySq-00049d-St for ietf-http-wg@w3.org; Wed, 08 Jun 2022 16:23:26 +0000
Received: from smtpclient.apple (static-71-174-62-56.bstnma.fios.verizon.net [71.174.62.56]) (authenticated bits=0) (User authenticated as jricher@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 258GMmSG001740 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 8 Jun 2022 12:22:49 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1654705370; bh=jDUDvPp+6P39KMdQgMoZXfIl2Q+zFJA01txtMyb8qTw=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=iK/S3IYIoe0QYgsKXaZ9/nrf8YaKxqZ/2HKzUzPZeaiCwwfHEVkapL5qe2eOjwA2M 0+k31BPGjyr5g3zJSiZ0ZDklYTpUytlWK7MlKbgQtIf0Hrnc0zf9qTYBXefw2D8Sm5 xkHgAJkaqRGODsm2VMjKsR6qvAR5NxTET5jGDiePPdlDxxWClcdgC0n+6H0TKYwntV Zf6El6ReeIbVl6lkhTlkTN4Px1H5UdUgsgWfTDpajVWjCwHwj2DF0RZ/aA19oubpkz /MfDLmN+eEG5jSgPIFXHq23orEcThpmGY+Vyp4MnqHo0RILQuMJPZiKEscFBo3OeQ1 ydfME1fuuMlFw==
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\))
From: Justin Richer <jricher@mit.edu>
In-Reply-To: <CACsn0cnRDhGnJctUH3_wBuLfkEmnxHaP5fjEjLdHcYyAwV6EtA@mail.gmail.com>
Date: Wed, 08 Jun 2022 12:22:48 -0400
Cc: Willy Tarreau <w@1wt.eu>, Martin Thomson <mt@lowentropy.net>, HTTP Working Group <ietf-http-wg@w3.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <7A963736-420F-4A4D-9AB0-41201AE923CC@mit.edu>
References: <A0601849-2870-4150-9926-5FA706D7F6DE@mit.edu> <CACcvr==K0gjhOaBaxt8vK80UYo1tAHVrh78yCcAEMvwx4tT=ag@mail.gmail.com> <7dff30c8-faac-413f-8387-f0a5a51fc6ff@beta.fastmail.com> <A659F1C6-97D6-48FB-BDED-B885AF93E553@mit.edu> <5f586a5b-4d62-40c8-8fa8-f747d08fd52f@beta.fastmail.com> <20220607062716.GA5885@1wt.eu> <E20AAD79-5757-4269-BFB1-6DD6CA8B2867@mit.edu> <CACsn0cnRDhGnJctUH3_wBuLfkEmnxHaP5fjEjLdHcYyAwV6EtA@mail.gmail.com>
To: Watson Ladd <watsonbladd@gmail.com>
X-Mailer: Apple Mail (2.3696.100.31)
X-W3C-Hub-DKIM-Status: validation passed: (address=jricher@mit.edu domain=mit.edu), signature is good
X-W3C-Hub-Spam-Status: No, score=-7.4
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, W3C_AA=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: mimas.w3.org 1nyySq-00049d-St 4bc943230298a6f43872dd8303264c3a
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Signing Set-Cookie
Archived-At: <https://www.w3.org/mid/7A963736-420F-4A4D-9AB0-41201AE923CC@mit.edu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/40085
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

I disagree that my attitude will lead to disaster — and in fact think quite the opposite, it will avoid disaster — but I appreciate your stance.

The escaping transformation is an interesting idea, and could actually be applied to more than just set-cookie.

We already have a flag that transforms the value, `sf`, and so another flag, `enc` or `b64` is not out of the question. Then the recommendation/requirement would be to use this flag with Set-Cookie and similar fields to avoid this problem.

Before someone asks: No, I do not think this is a good idea to apply to all field values by default.

What do folks think of this?

 — Justin

> On Jun 7, 2022, at 7:34 PM, Watson Ladd <watsonbladd@gmail.com> wrote:
> 
> On Tue, Jun 7, 2022 at 10:35 AM Justin Richer <jricher@mit.edu> wrote:
>> 
>> 
>> While I agree that the combination could potentially be problematic, and definitely is distasteful from a security purity standpoint, what I’m not seeing is an attack where two distinct non-theoretical valid values of Set-Cookie could be combined into another valid Set-Cookie header. Yes in theory there’s a comma in the syntax, but I’m not seeing how that could be used to mount an actual attack in a meaningful way. The two Set-Cookie headers combined would need to have the exact same content as the single Set-Cookie header on its own, but be interpreted in a different way by the verifier in such a way that would affect the application. The attacker here isn’t substituting a completely different value, and is not adding a value where one wasn’t before. Can someone please give me a concrete demonstration that shows this is something we should actually protect against and not just something to warn against?
> 
> This is the attitude that leads to disaster. Clever attackers will
> find ways in which the assumptions underlying the analysis of the
> harmlessness of the confusion are broken. Its much easier to design
> things to be injective and thus never have to worry, than to have to
> ask about the construction of cookie values each and every time a user
> uses them. This isn't "security purity", it's what's required to
> ensure that users are safe, without having to understand and get the
> details right each and every time. We've learnt these lessons the hard
> way, and it's disappointing to see them get ignored.
> 
>> 
>> Regardless, what is the recommended approach? Martin’s seems to be “throw out HTTP Signatures entirely”, but he’s said that since the work started. :) What I think though is that we’ve got a few potential approaches:
>> 
>> - Never sign Set-Cookie
>> - Never sign multiple Set-Cookie headers
>> - Have a special syntax for dealing with Set-Cookie (probably a derived component, but I’m not thrilled about this one)
>> - Warn against weirdness with multiple Set-Cookie headers
>> 
>> Any other approaches?
> 
> Apply an escaping transformation or some sort of base64 before turning
> into a List.
> 
>> 
>> — Justin
> 
> 
> 
> --
> Astra mortemque praestare gradatim