Re: [http-state] Ticket 6: host-only cookies

Adam Barth <ietf@adambarth.com> Tue, 02 February 2010 19:35 UTC

Return-Path: <adam@adambarth.com>
X-Original-To: http-state@core3.amsl.com
Delivered-To: http-state@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 4F2473A6868 for <http-state@core3.amsl.com>; Tue, 2 Feb 2010 11:35:15 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.895
X-Spam-Level:
X-Spam-Status: No, score=-1.895 tagged_above=-999 required=5 tests=[AWL=0.082, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bKYKjXMZAz+s for <http-state@core3.amsl.com>; Tue, 2 Feb 2010 11:35:14 -0800 (PST)
Received: from mail-px0-f186.google.com (mail-px0-f186.google.com [209.85.216.186]) by core3.amsl.com (Postfix) with ESMTP id 4B4133A6833 for <http-state@ietf.org>; Tue, 2 Feb 2010 11:35:14 -0800 (PST)
Received: by pxi16 with SMTP id 16so409109pxi.29 for <http-state@ietf.org>; Tue, 02 Feb 2010 11:35:50 -0800 (PST)
MIME-Version: 1.0
Received: by 10.142.8.14 with SMTP id 14mr4330158wfh.59.1265139350132; Tue, 02 Feb 2010 11:35:50 -0800 (PST)
In-Reply-To: <4B687989.9080003@kristol.org>
References: <7789133a1001220050m56cc438x35099b7972639331@mail.gmail.com> <4B59B834.3030500@gmail.com> <4C374A2653EB5E43AF886CE70DFC567213CE9BE2B4@34093-MBX-C03.mex07a.mlsrvr.com> <7789133a1002012300k4627d9a2sad7f5b776c544487@mail.gmail.com> <4B6854C8.4040602@kristol.org> <7789133a1002020913p13f48804x1174904f3eec9c7d@mail.gmail.com> <4B687989.9080003@kristol.org>
From: Adam Barth <ietf@adambarth.com>
Date: Tue, 2 Feb 2010 11:35:30 -0800
Message-ID: <7789133a1002021135o7d2b3aa4odb929341ab319137@mail.gmail.com>
To: Dave Kristol <dmk-http-state@kristol.org>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: http-state <http-state@ietf.org>
Subject: Re: [http-state] Ticket 6: host-only cookies
X-BeenThere: http-state@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discuss HTTP State Management Mechanism <http-state.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/http-state>, <mailto:http-state-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/http-state>
List-Post: <mailto:http-state@ietf.org>
List-Help: <mailto:http-state-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/http-state>, <mailto:http-state-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 02 Feb 2010 19:35:15 -0000

On Tue, Feb 2, 2010 at 11:14 AM, Dave Kristol
<dmk-http-state@kristol.org> wrote:
> Adam Barth wrote:
>> Do you mean that
>>
>> Set-Cookie: foo=bar; Domain=example.com
>>
>> and
>>
>> Set-Cookie: foo=bar; Domain=.example.com
>>
>> are treated differently by user agents?  That might be true according
>> to 2109 (I'd have to check), but I don't think that's how user agents
>> work in practice.  They appear to ignore the leading dot.  If you have
>> a test case that show a difference, I'd be very interested in seeing
>> it.
>
> That is what I meant, and I do not have a test case.  That is what 2109
> said, and I believe (though it's been many years now... ugh!) I adopted that
> from Netscape's spec.  Generally speaking, the idea was that, in the absence
> of Domain=, the cookie should be returned only to the server that sent it.

I believe this is the line of code in Firefox that causes the leading
dot in the domain attribute to be ignored.

http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/src/nsCookieService.cpp#2159

There's a similar line of code in Chrome in the GetCookieDomainKey
function in this file:

http://src.chromium.org/viewvc/chrome/trunk/src/net/base/cookie_monster.cc?view=markup

Here's the comment:

  // Get the normalized domain specified in cookie line.
  // Note: The RFC says we can reject a cookie if the domain
  // attribute does not start with a dot. IE/FF/Safari however, allow a cookie
  // of the form domain=my.domain.com, treating it the same as
  // domain=.my.domain.com -- for compatibility we do the same here.  Firefox
  // also treats domain=.....my.domain.com like domain=.my.domain.com, but
  // neither IE nor Safari do this, and we don't either.

Note that Firefox now acts like IE/Chrome/Safari in regards to
Domain=.....my.domain.com

Adam