[Docs] [txt|pdf] [Tracker] [Email] [Diff1] [Diff2] [Nits]

Versions: 00 01 02 03 04 05 draft-ietf-httpbis-cookie-prefixes

HTTPbis                                                          M. West
Internet-Draft                                               Google, Inc
Updates: 6265 (if approved)                            November 30, 2015
Intended status: Standards Track
Expires: June 2, 2016


                            Cookie Prefixes
                     draft-west-cookie-prefixes-05

Abstract

   This document updates RFC6265 by adding a set of restrictions upon
   the names which may be used for cookies with specific properties.
   These restrictions enable user agents to smuggle cookie state to the
   server within the confines of the existing "Cookie" request header
   syntax, and limits the ways in which cookies may be abused in a
   conforming user agent.

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 June 2, 2016.

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 June 2, 2016                  [Page 1]


Internet-Draft               cookie-prefixes               November 2015


   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Terminology and notation  . . . . . . . . . . . . . . . . . .   2
   3.  Prefixes  . . . . . . . . . . . . . . . . . . . . . . . . . .   3
     3.1.  The "__Secure-" prefix  . . . . . . . . . . . . . . . . .   3
     3.2.  The "__Host-" prefix  . . . . . . . . . . . . . . . . . .   3
   4.  User Agent Requirements . . . . . . . . . . . . . . . . . . .   4
   5.  Aesthetic Considerations  . . . . . . . . . . . . . . . . . .   4
     5.1.  Not pretty. . . . . . . . . . . . . . . . . . . . . . . .   4
     5.2.  Why "__"? . . . . . . . . . . . . . . . . . . . . . . . .   4
   6.  Security Considerations . . . . . . . . . . . . . . . . . . .   5
     6.1.  Secure Origins Only . . . . . . . . . . . . . . . . . . .   5
     6.2.  Limitations . . . . . . . . . . . . . . . . . . . . . . .   5
   7.  References  . . . . . . . . . . . . . . . . . . . . . . . . .   5
     7.1.  Normative References  . . . . . . . . . . . . . . . . . .   5
     7.2.  Informative References  . . . . . . . . . . . . . . . . .   5
   Appendix A.  Acknowledgements . . . . . . . . . . . . . . . . . .   6
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .   6

1.  Introduction

   Section 8.5 and Section 8.6 of [RFC6265] spell out some of the
   drawbacks of cookies' implementation: due to historical accident, it
   is impossible for a server to have confidence that a cookie set in a
   secure way (e.g., as a domain cookie with the "Secure" (and possibly
   "HttpOnly") flags set) remains intact and untouched by non-secure
   subdomains.

   We can't alter the syntax of the "Cookie" request header, as that
   would likely break a number of implementations.  This rules out
   sending a cookie's flags along with the cookie directly, but we can
   smuggle information along with the cookie if we reserve certain name
   prefixes for cookies with certain properties.

   This document describes such a scheme, which enables servers to set
   cookies which conforming user agents will ensure are "Secure", and
   locked to a domain.

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].




West                      Expires June 2, 2016                  [Page 2]


Internet-Draft               cookie-prefixes               November 2015


   The "scheme" component of a URI is defined in Section 3 of [RFC3986].

3.  Prefixes

3.1.  The "__Secure-" prefix

   If a cookie's name begins with "__Secure-", the cookie MUST be:

   1.  Set with a "Secure" attribute

   2.  Set from a URI whose "scheme" is considered "secure" by the user
       agent.

   The following cookie would be rejected when set from any origin, as
   the "Secure" flag is not set

   Set-Cookie: __Secure-SID=12345; Domain=example.com

   While the following would be accepted if set from a secure origin
   (e.g.  "https://example.com/"), and rejected otherwise:

   Set-Cookie: __Secure-SID=12345; Secure; Domain=example.com

3.2.  The "__Host-" prefix

   If a cookie's name begins with "__Host-", the cookie MUST be:

   1.  Set with a "Secure" attribute

   2.  Set from a URI whose "scheme" is considered "secure" by the user
       agent.

   3.  Sent only to the host which set the cookie.  That is, a cookie
       named "__Host-cookie1" set from "https://example.com" MUST NOT
       contain a "Domain" attribute (and will therefore be sent only to
       "example.com", and not to "subdomain.example.com").

   4.  Sent to every request for a host.  That is, a cookie named
       "__Host-cookie1" MUST contain a "Path" attribute with a value of
       "/".

   The following cookies would always be rejected:

   Set-Cookie: __Host-SID=12345
   Set-Cookie: __Host-SID=12345; Secure
   Set-Cookie: __Host-SID=12345; Domain=example.com
   Set-Cookie: __Host-SID=12345; Domain=example.com; Path=/
   Set-Cookie: __Host-SID=12345; Secure; Domain=example.com; Path=/



West                      Expires June 2, 2016                  [Page 3]


Internet-Draft               cookie-prefixes               November 2015


   While the following would be accepted if set from a secure origin
   (e.g.  "https://example.com/"), and rejected otherwise:

   Set-Cookie: __Host-SID=12345; Secure; Path=/

4.  User Agent Requirements

   This document updates Section 5.3 of [RFC6265] as follows:

   After step 10 of the current algorithm, the cookies flags are set.
   Insert the following steps to perform the prefix checks this document
   specifies:

   1.  If the "cookie-name" begins with the string "__Secure-" or
       "__Host-", abort these steps and ignore the cookie entirely
       unless both of the following conditions are true:

       *  The cookie's "secure-only-flag" is "true"

       *  "request-uri"'s "scheme" component denotes a "secure" protocol
          (as determined by the user agent)

   2.  If the "cookie-name" begins with the string "__Host-", abort
       these steps and ignore the cookie entirely unless the following
       conditions are true:

       *  The cookie's "host-only-flag" is "true"

       *  The cookie's "path" is "/"

5.  Aesthetic Considerations

5.1.  Not pretty.

   Prefixes are ugly. :(

5.2.  Why "__"?

   We started with "$", but ran into issues with servers that had
   implemented [RFC2109]-style cookies. "__" is a prefix used for a
   number of well-known cookies in the wild (notably Google Analytics's
   "__ut*" cookies, and CloudFlare's "__cfduid"), and so is unlikely to
   produce such compatibility issues, while being uncommon enough to
   mitigate the risk of collisions.







West                      Expires June 2, 2016                  [Page 4]


Internet-Draft               cookie-prefixes               November 2015


6.  Security Considerations

6.1.  Secure Origins Only

   It would certainly be possible to extend this scheme to non-secure
   origins (and an earlier draft of this document did exactly that).
   User agents, however, are slowly moving towards a world where
   features with security implications are available only over secure
   transport (see [SECURE-CONTEXTS], [POWERFUL-FEATURES], and
   [DEPRECATING-HTTP]).  This document follows that trend, limiting
   exciting new cookie properties to secure transport in order to ensure
   that user agents can make claims which middlemen will have a hard
   time violating.

   To that end, note that the requirements listed above mean that
   prefixed cookies will be rejected entirely if a non-secure origin
   attempts to set them.

6.2.  Limitations

   This scheme gives no assurance to the server that the restrictions on
   cookie names are enforced.  Servers could certainly probe the user
   agent's functionality to determine support, or sniff based on the
   "User-Agent" request header, if such assurances were deemed
   necessary.

7.  References

7.1.  Normative References

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [RFC3986]  Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
              Resource Identifier (URI): Generic Syntax", STD 66, RFC
              3986, DOI 10.17487/RFC3986, January 2005,
              <http://www.rfc-editor.org/info/rfc3986>.

   [RFC6265]  Barth, A., "HTTP State Management Mechanism", RFC 6265,
              April 2011.

7.2.  Informative References

   [DEPRECATING-HTTP]
              Barnes, R., "Deprecating Non-Secure HTTP", n.d.,
              <https://blog.mozilla.org/security/2015/04/30/deprecating-
              non-secure-http/>.




West                      Expires June 2, 2016                  [Page 5]


Internet-Draft               cookie-prefixes               November 2015


   [Lawrence2015]
              Lawrence, E., "Duct Tape and Baling Wire -- Cookie
              Prefixes", n.d., <http://textslashplain.com/2015/10/09/
              duct-tape-and-baling-wirecookie-prefixes/>.

   [POWERFUL-FEATURES]
              Palmer, C., "Prefer Secure Origins for Powerful New
              Features", n.d., <https://www.chromium.org/Home/chromium-
              security/prefer-secure-origins-for-powerful-new-features>.

   [RFC2109]  Kristol, D. and L. Montulli, "HTTP State Management
              Mechanism", RFC 2109, DOI 10.17487/RFC2109, February 1997,
              <http://www.rfc-editor.org/info/rfc2109>.

   [SECURE-CONTEXTS]
              West, M., "Secure Contexts", n.d., <https://w3c.github.io/
              webappsec-secure-contexts/>.

Appendix A.  Acknowledgements

   Eric Lawrence had this idea a million years ago, and wrote about its
   genesis in [Lawrence2015].  Devdatta Akhawe helped justify the
   potential impact of the scheme on real-world websites.  Thomas Broyer
   pointed out the issues with a leading "$" in the prefixes, and Brian
   Smith provided valuable contributions to the discussion around a
   replacement (ISO C indeed).

Author's Address

   Mike West
   Google, Inc

   Email: mkwst@google.com
   URI:   https://mikewest.org/

















West                      Expires June 2, 2016                  [Page 6]


Html markup produced by rfcmarkup 1.121, available from https://tools.ietf.org/tools/rfcmarkup/