Re: Signing Set-Cookie

Justin Richer <> Fri, 17 June 2022 21:01 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id D2BF4C147921 for <>; Fri, 17 Jun 2022 14:01:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2.759
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: (amavisd-new); dkim=pass (2048-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id qQdjkkS7RiD7 for <>; Fri, 17 Jun 2022 14:01:34 -0700 (PDT)
Received: from ( []) (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 (Postfix) with ESMTPS id DA21DC14CF03 for <>; Fri, 17 Jun 2022 14:01:34 -0700 (PDT)
Received: from lists by with local (Exim 4.92) (envelope-from <>) id 1o2J3I-0007S7-5W for; Fri, 17 Jun 2022 20:58:48 +0000
Resent-Date: Fri, 17 Jun 2022 20:58:48 +0000
Resent-Message-Id: <>
Received: from ([]) by with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <>) id 1o2J3G-0007RE-Jf for; Fri, 17 Jun 2022 20:58:46 +0000
Received: from ([] by with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <>) id 1o2J3F-00016M-3J for; Fri, 17 Jun 2022 20:58:46 +0000
Received: from ( []) (authenticated bits=0) (User authenticated as jricher@ATHENA.MIT.EDU) by (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;; 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 <>
Message-Id: <>
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: <>
Cc: Willy Tarreau <>, Martin Thomson <>, HTTP Working Group <>
To: Watson Ladd <>
References: <> <> <> <> <> <> <> <> <>
X-Mailer: Apple Mail (2.3696.100.31)
X-W3C-Hub-DKIM-Status: validation passed: (, 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: 1o2J3F-00016M-3J 0e88269a0eaf8b53fc0814d8788bcfec
Subject: Re: Signing Set-Cookie
Archived-At: <>
X-Mailing-List: <> archive/latest/40159
Precedence: list
List-Id: <>
List-Help: <>
List-Post: <>
List-Unsubscribe: <>


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: <>

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 <> 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 <> wrote:
>> On Tue, Jun 7, 2022 at 10:35 AM Justin Richer <> 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