Re: Proposal: Cookie Priorities

Mike West <mkwst@google.com> Mon, 07 March 2016 09:33 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 (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 104301B3D42 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 7 Mar 2016 01:33:38 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -5.78
X-Spam-Level:
X-Spam-Status: No, score=-5.78 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, J_CHICKENPOX_66=0.6, RCVD_IN_DNSWL_HI=-5, RP_MATCHES_RCVD=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D78cH495uiM1 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 7 Mar 2016 01:33:34 -0800 (PST)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 728301B3D41 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Mon, 7 Mar 2016 01:33:33 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1acrRJ-0008AZ-JH for ietf-http-wg-dist@listhub.w3.org; Mon, 07 Mar 2016 09:26:57 +0000
Resent-Date: Mon, 07 Mar 2016 09:26:57 +0000
Resent-Message-Id: <E1acrRJ-0008AZ-JH@frink.w3.org>
Received: from maggie.w3.org ([128.30.52.39]) by frink.w3.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <mkwst@google.com>) id 1acrRB-000895-Mm for ietf-http-wg@listhub.w3.org; Mon, 07 Mar 2016 09:26:49 +0000
Received: from mail-lb0-f181.google.com ([209.85.217.181]) by maggie.w3.org with esmtps (TLS1.2:RSA_ARCFOUR_SHA1:128) (Exim 4.80) (envelope-from <mkwst@google.com>) id 1acrQz-0007sY-7T for ietf-http-wg@w3.org; Mon, 07 Mar 2016 09:26:48 +0000
Received: by mail-lb0-f181.google.com with SMTP id xr8so26548884lbb.1 for <ietf-http-wg@w3.org>; Mon, 07 Mar 2016 01:26:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=T1b1xvNYzhp7kVI7INWYjgGuBOY0q3DrmYjBk/5J8co=; b=R2AtoJuVQ/VC0RSVAmYl1zykNymQtOMeCGGf+bAOOsfWMHGtbT05fB4t609ZPR8LBz zXtXXSyxAPhUfmag6HD8o6Lwzt5qo/IiL1m8l1w6THuY1glaJ71YwZahj3kX08a8iOxO RZ5J57ftVblcQPAvtol0Kdn9nfFrHfBFGw4gW+mcnBYVcOGmXwPreexgc0JoDVPa85x8 JQxN70TJkQ+OltFJ8IjHz8gyhqGVoBv1MzE3FXpjJDLmfBzVeCObJDmIdBwUnmGBs/jh BCe6fK0XGNJnm+3PUbe5sswhx/9WEhB7YyFpc2SFF21gjokiqH1G+TXvc9q9PAh92xm5 rwrg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=T1b1xvNYzhp7kVI7INWYjgGuBOY0q3DrmYjBk/5J8co=; b=KdWO7R30S0LAEDEM8IM9MNmcgHmnmHb3dc8afb5OUSDR3hR5RdpUrzmi91dmLFjF1w zgw4rClKbj7r7GteD3t8TpKP8y0CiX31eRv4VEizXngTbD1A2OheKFHHD/d3crVUfWd+ RnwLli66pFDvf6Z3CF3hfRQJ5Ldctgcjqw+U60XA3J65bttPAkkqS3F2cPvgvoLA+49q qF6cTGeVljkT3EGkx0qewGiQFQ0gsBvrRF8bIk5cd1/sB8PlOJtp9qC0YlY2//z+LNcD JR6aU6JCickKWO9zP5BC58rB1BZUSj0Eu/XUXJ84aMqzxh3IQUiz573sTpb7ffEiCHZw Qsag==
X-Gm-Message-State: AD7BkJLFqbsBySPNY3/53FiBVen33Sr9stGjdtoxHBJ4R734gwF0VEIrQige62Fnyt+EBVxjO1g9oPskFUXhR5R4
X-Received: by 10.112.140.129 with SMTP id rg1mr7645037lbb.80.1457342766556; Mon, 07 Mar 2016 01:26:06 -0800 (PST)
MIME-Version: 1.0
Received: by 10.112.147.38 with HTTP; Mon, 7 Mar 2016 01:25:46 -0800 (PST)
In-Reply-To: <alpine.DEB.2.20.1603070855070.25615@tvnag.unkk.fr>
References: <CAKXHy=dvxE5f25_xx3mKTc+XRDU_Hp=uFDy-iL-_c0s+xHGydw@mail.gmail.com> <alpine.DEB.2.20.1603070855070.25615@tvnag.unkk.fr>
From: Mike West <mkwst@google.com>
Date: Mon, 07 Mar 2016 10:25:46 +0100
Message-ID: <CAKXHy=fZkRnThojTU8V9s-Vyps8jG3xOTEF-yKrDs9cqh546mg@mail.gmail.com>
To: Daniel Stenberg <daniel@haxx.se>
Cc: HTTP Working Group <ietf-http-wg@w3.org>, Samuel Huang <huangs@google.com>, Mark Nottingham <mnot@mnot.net>
Content-Type: multipart/alternative; boundary="001a11c26ba8eb0e13052d720d01"
Received-SPF: pass client-ip=209.85.217.181; envelope-from=mkwst@google.com; helo=mail-lb0-f181.google.com
X-W3C-Hub-Spam-Status: No, score=-7.9
X-W3C-Hub-Spam-Report: AWL=1.840, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_IRR=-3, W3C_WL=-1
X-W3C-Scan-Sig: maggie.w3.org 1acrQz-0007sY-7T 6ce0e6262dbf13a88365892d7c7ed6ac
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Proposal: Cookie Priorities
Archived-At: <http://www.w3.org/mid/CAKXHy=fZkRnThojTU8V9s-Vyps8jG3xOTEF-yKrDs9cqh546mg@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/31210
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: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Thanks for the conversation, folks. A few replies inline:

On Mon, Mar 7, 2016 at 9:12 AM, Daniel Stenberg <daniel@haxx.se> wrote:

> On Thu, 3 Mar 2016, Mike West wrote:
>
> https://tools.ietf.org/html/draft-west-cookie-priority-00. Apologies for
>> the years of delay. :/
>>
>
> Count me as another skeptic.
>
> Since implementing support different cookie priority levels requires
> changing the server ends, wouldn't it be better to ask server admins to
> instead stop polluting the same domain with excessive amounts of cookies? I
> presume the primary cookie limit you're talking about number of cookies per
> domain. Alternatively, advocate for a higher limit (even though RFC6265
> only suggests certain limits, browsers are free to user higher)?
>

Chrome and Firefox both set limit at ~150 cookies per domain. Chrome has a
different eviction mechanism than Firefox, allowing a domain to flex up to
180 cookies before purging it back down to 150. My (vague) understanding is
that we arrived at that mechanism for performance reasons: purging just one
cookie lead to some level of churn for users who hovered around the limit.

Raising the limit is certainly possible, but also has performance impacts
and storage limitations. We'd need to measure those carefully before
bumping the limit, as determining which cookies to send ends up being on
the critical path for every request.


> What happens to cookies that are actually called 'Priority' ? It seems
> like a very standard name for a cookie and to me it seems like there's room
> for confusion for services that already use Priority set to Low/High etc. I
> don't see any mentioning of how to handle this.
>

Like cookies named "HttpOnly" or "MaxAge", this is handled by step 1 of
https://tools.ietf.org/html/rfc6265#section-5.2, which splits the cookie
string on the first ';' into the name/value pair, and the set of attributes.


> This mechanism adds more complexity to an already complicated and messed
> up concept.
>

It also solves a real problem that really exists, at least in the complex
ecosystems of corporate intranets. Both Mark and Martin seem to have
confirmed that the anecdata I provide isn't limited to Google.

I'm also a bit sad to hear that Chrome+Google already implement this, as it
> feels like a certain degree of the old web war tactics all over again. It
> won't really matter what we say in this work group, as Google services will
> work less good without this feature and Chrome already works like this, so
> in order to keep users happy, user agents are strong-armed into following...


On this point, I can only apologize. We didn't follow through on our
commitment to discuss shipping this feature openly, we didn't report our
experimental results, and we didn't get buy-in from other browser vendors.
You're correct that this is bad behavior. If it turns out that Chrome is
the only vendor that's going to implement this, then I'll do my best to get
it removed.

All that said, I think the Chrome team has gotten significantly better at
this since 2013. We have a clear launch process
<http://www.chromium.org/blink#launch-process> for web-facing features, and
if we were launching cookie priorities _today_, the conversation would have
gone differently.

On Mon, Mar 7, 2016 at 4:29 AM, Matthew Kerwin <matthew@kerwin.net.au>
 wrote:

> Regarding "Priority=High": Currently cookies are often used on the
> critical path, and these existing cookies don't have a "Priority"
> attribute. We can't define a new spec that retroactively mandates that
> implementers have to add the attribute, so I imagine we would probably want
> to define it so that "no Priority" is as high as "High Priority." (Unless
> we're proposing to define a new supe..uh..'more important' cookie.) So all
> the existing dead wood remains, and the path of least resistance for
> implementers who want to comply with the spec is: don't do anything. Thus
> it's not a valuable addition.
>

The spec defines a missing `priority` attribute as setting "medium"
priority, which allows an origin to just set priority on those cookies
which are particularly important, or particularly discardable. For
instance. Google sets `priority=high` on authentication cookies, and
`priority=low` on cookies which only contain information that could be
derived (at expense) from the user session data.

Also, just so it's clear: the `priority` attribute is only considered in
the context of a single domain. We don't discard `example.com`'s "low"
priority cookies in order to keep `google.com`'s "high" priority cookies.
We only consider priority when determining which of a particular domain's
to evict, once we know that we need to evict a few. It is quite limited in
scope, and does not override any of the other mechanisms which might cause
a cookie to be removed. In particular, `priority=high` does not change
cookie expiration. I don't think it's fair at all to allude to it as a
supercookie.

Regarding "Priority=Low": this allows/encourages people to add even more
> cookies, because "they're low priority, so they're less harmful." Telling
> people to add a bunch of fluffy cookies because 'they can be pruned if
> there are too many' doesn't seem like an improvement to me. Better advice
> would be: don't send so much cruft in cookies.
>

Given that `priority` only comes into play when cookies are evicted for
exceeding a domain's limit, it doesn't appear that developers have needed
much encouragement. :)

In the particular set of cases I'm concerned with, the problem isn't a
single developer or even a single application stuffinh a user's cookie jar
with 150+ cookies, but a collusion of multiple applications on a single
registrable domain. For each individual application, cookies might be
totally legitimate and not at all crufty; that doesn't change the overall
impact on the domain.

On Fri, Mar 4, 2016 at 1:53 AM, Martin Thomson <martin.thomson@gmail.com>
 wrote:

> I have a small suggestion:
>

> if (request.url.scheme == 'http') {
>   cookie.priority = 'floor';
> }
>

Note that the eviction changes in
https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-00 would still
be effective; I'm working through how those changes impact Google at the
moment, and hope to have a more concrete proposal of what an eviction
algorithm that takes care of both of these proposals might look like. The
initial pass that we planned to start shipping in Chrome 50 caused some
disruption that I'm still working through.

Related story, I believe that some of those people run servers that
> forcibly evict all cookies other than those on a small whitelist to
> prevent this sort of craziness.  That turns out to have beneficial
> properties.


Indeed, Google has put a ton of effort into understanding all the cookies
that are set by Google services, and my understanding is that we do
actively cull cookies coming into/set by our frontend servers. The intranet
(`*.corp.google.com`) is less centralized, and less controllable; I'm told
that the sign-out rates we see internally are orders of magnitude higher
than we see externally, for this reason.

-mike