HTTPbis M. West
Internet-Draft Google, Inc
Updates: 6265 (if approved) February 20, 2015
Intended status: Standards Track
Expires: August 24, 2015
First-Party-Only Cookies
draft-west-first-party-cookies-01
Abstract
This document updates RFC6265 by defining a "First-Party-Only"
attribute which allows servers to assert that a cookie ought to be
sent only in a "first-party" context. This assertion allows user
agents to mitigate the risk of cross-site request forgery attacks,
and other related paths to cross-origin information leakage.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on August 24, 2015.
Copyright Notice
Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
West Expires August 24, 2015 [Page 1]
Internet-Draft first-party-cookies February 2015
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terminology and notation . . . . . . . . . . . . . . . . . . 3
2.1. First-party and Third-party Requests . . . . . . . . . . 3
3. Server Requirements . . . . . . . . . . . . . . . . . . . . . 4
3.1. Grammar . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2. Semantics of the "First-Party-Only" Attribute (Non-
Normative) . . . . . . . . . . . . . . . . . . . . . . . 5
4. User Agent Requirements . . . . . . . . . . . . . . . . . . . 5
4.1. The "First-Party" attribute . . . . . . . . . . . . . . . 5
4.2. Monkey-patching the Storage Model . . . . . . . . . . . . 5
4.3. Monkey-patching the "Cookie" header . . . . . . . . . . . 6
5. Authoring Considerations . . . . . . . . . . . . . . . . . . 6
5.1. Mashups and Widgets . . . . . . . . . . . . . . . . . . . 6
6. Privacy Considerations . . . . . . . . . . . . . . . . . . . 6
7. Security Considerations . . . . . . . . . . . . . . . . . . . 7
7.1. Limitations . . . . . . . . . . . . . . . . . . . . . . . 7
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 7
9. References . . . . . . . . . . . . . . . . . . . . . . . . . 7
9.1. Normative References . . . . . . . . . . . . . . . . . . 7
9.2. Informative References . . . . . . . . . . . . . . . . . 8
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 8
1. Introduction
Section 8.2 of [RFC6265] eloquently notes that cookies are a form of
ambient authority, attached by default to requests the user agent
sends on a user's behalf. Even when an attacker doesn't know the
contents of a user's cookies, she can still execute commands on the
user's behalf (and with the user's authority) by asking the user
agent to send HTTP requests to unwary servers.
Here, we update [RFC6265] with a simple mitigation strategy that
allows servers to declare certain cookies as "First-party-only",
meaning they should be attached to requests if and only if those
requests occur in a first-party context. We define "first-party
context" in terms of a user agent's top-level browsing context, which
is the only security context a user can reasonably be expected to
understand.
Note that the mechanism outlined here is backwards compatible with
the existing cookie syntax. Servers may serve first-party cookies to
all user agents; those that do not support the "First-Party-Only"
West Expires August 24, 2015 [Page 2]
Internet-Draft first-party-cookies February 2015
attribute will simply store a cookie which is returned in all
applicable contexts, just as they do today.
1.1. Examples
First-party-only cookies are set via the "First-Party-Only" attribute
in the "Set-Cookie" header field. That is, given a server's response
to a user agent which contains the following header field:
Set-Cookie: SID=31d4d96e407aad42; First-Party-Only
Subsequent requests from that user agent can be expected to contain
the following header field if and only if both the requested resource
and the resource in the top-level browsing context match the cookie.
2. Terminology and notation
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
This specification uses the Augmented Backus-Naur Form (ABNF)
notation of [RFC5234].
Two sequences of octets are said to case-insensitively match each
other if and only if they are equivalent under the "i;ascii-casemap"
collation defined in [RFC4790].
The terms "active document", and "top-level browsing context" are
defined in the HTML Living Standard. [HTML]
The term "origin" and the mechanism of deriving an origin from a URI
are defined in [RFC6454].
2.1. First-party and Third-party Requests
The URL displayed in a user agent's address bar is the only security
context directly exposed to users, and therefore the only signal
users can reasonably rely upon to determine whether or not they trust
a particular website.
With that in mind, we define a "first-party" request as an HTTP
request for a resource whose URL's origin matches the origin of the
URL the user sees in the address bar. A "third-party" request is an
HTTP request for a resource at any other origin.
To be more precise, given an HTTP request "request":
West Expires August 24, 2015 [Page 3]
Internet-Draft first-party-cookies February 2015
1. Let "context" be the top-level browsing context in the window
responsible for "request".
2. Let "top-origin" be the origin of the location of the active
document in "context".
3. If the origin of "request"'s URL is the same as "top-origin",
"request" is a *first-party request*. Otherwise, "request" is a
*third-party request*.
Note that we deal with the document's location in step 2 above, not
with the document's origin. For example, a top-level document from
"https://example.com" which has been sandboxed into a unique origin
still creates a non-unique first-party context for subsequent
requests.
This definition has a few implications:
o New windows create new first-party contexts.
o Full-page navigations create new first-party contexts. Notably,
this includes both HTTP and ""-driven redirects.
o "