Re: Signing Set-Cookie

Justin Richer <jricher@mit.edu> Fri, 17 June 2022 21:01 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 D2BF4C147921 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 17 Jun 2022 14:01:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.759
X-Spam-Level:
X-Spam-Status: No, score=-2.759 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, HTML_MESSAGE=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=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 qQdjkkS7RiD7 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 17 Jun 2022 14:01:34 -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 DA21DC14CF03 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 17 Jun 2022 14:01:34 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.92) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1o2J3I-0007S7-5W for ietf-http-wg-dist@listhub.w3.org; Fri, 17 Jun 2022 20:58:48 +0000
Resent-Date: Fri, 17 Jun 2022 20:58:48 +0000
Resent-Message-Id: <E1o2J3I-0007S7-5W@lyra.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by lyra.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <jricher@mit.edu>) id 1o2J3G-0007RE-Jf for ietf-http-wg@listhub.w3.org; Fri, 17 Jun 2022 20:58:46 +0000
Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <jricher@mit.edu>) id 1o2J3F-00016M-3J for ietf-http-wg@w3.org; Fri, 17 Jun 2022 20:58:46 +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 25HKw7C3004766 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jun 2022 16:58:08 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1655499489; bh=ScLD7WLJeOuaIyB+Sgl0P+SoLCzgR/ebrqZe6L35GHo=; h=From:Subject:Date:In-Reply-To:Cc:To:References; b=OP2FVs06V6QoW0VKNz69z9JnKGsPJoOlrTDHPtjA9Xs8kLq3L+Owbvv9e627sF/S5 lDsTo+NUUHH5/TkbNXq9FxPH/y1QR70W29rlFdJcuNC8zg+tK9gUvpsd1c3IOT0yXA 6mOg1nEiXUPtZSNjhad3GG8s0v+TTdC0dPSXd3v1xRVXnzIeJGrzM/Dvsrv+dDY1Qq wPW4sV3fDJ64F8T2aHNel68e11vu7EF8AyBveCSZlZpqyBgFTj8gD0fCbc2R/fmO+1 IwzOKZn7PGxMlodVylqkLZQlnjEqamw2x9eL2dHKn1LLzxRKdSOH0rou8zQCAg1HEd GhhTO0D29KETA==
From: Justin Richer <jricher@mit.edu>
Message-Id: <FFE77176-6716-4975-BFBE-CF68BE86F81A@mit.edu>
Content-Type: multipart/alternative; boundary="Apple-Mail=_DCD96DE5-22EB-44D1-B2DC-704CD7545B43"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\))
Date: Fri, 17 Jun 2022 16:58:07 -0400
In-Reply-To: <7A963736-420F-4A4D-9AB0-41201AE923CC@mit.edu>
Cc: Willy Tarreau <w@1wt.eu>, Martin Thomson <mt@lowentropy.net>, HTTP Working Group <ietf-http-wg@w3.org>
To: Watson Ladd <watsonbladd@gmail.com>
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> <7A963736-420F-4A4D-9AB0-41201AE923CC@mit.edu>
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, HTML_MESSAGE=0.001, 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: titan.w3.org 1o2J3F-00016M-3J 0e88269a0eaf8b53fc0814d8788bcfec
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Signing Set-Cookie
Archived-At: <https://www.w3.org/mid/FFE77176-6716-4975-BFBE-CF68BE86F81A@mit.edu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/40159
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>

All,

I’ve pushed updated language to the security considerations, including more comprehensive discussion of the issue with internal commas. 

I’ve raised a separate issue to track a proposal for allowing wrapped encoding of problematic field values:

https://github.com/httpwg/http-extensions/issues/2166 <https://github.com/httpwg/http-extensions/issues/2166>

Functionally, this proposal turns each field line into a ByteSequence and the combination into a List, and the whole thing gets serialized as a strict List value.

What I like about this proposed approach is that it’s applicable across all different fields, regardless of the input itself. If an application wants to do this all throughout, it can.

 — Justin

> On Jun 8, 2022, at 12:22 PM, Justin Richer <jricher@mit.edu> wrote:
> 
> 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
> 
>