HTTPbis M. West Internet-Draft Google, Inc Updates: 6265 (if approved) October 9, 2015 Intended status: Standards Track Expires: April 11, 2016 Cookie Prefixes draft-west-cookie-prefixes-02 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 April 11, 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 April 11, 2016 [Page 1] Internet-Draft cookie-prefixes October 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 "$Origin-" prefix . . . . . . . . . . . . . . . . . . 3 3.3. The "$SecureOrigin-" prefix . . . . . . . . . . . . . . . 4 4. User Agent Requirements . . . . . . . . . . . . . . . . . . . 4 5. Aesthetic Considerations . . . . . . . . . . . . . . . . . . 5 6. Security Considerations . . . . . . . . . . . . . . . . . . . 5 7. Normative References . . . . . . . . . . . . . . . . . . . . 5 Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 5 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 5 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]. The "scheme" component of a URI is defined in Section 3 of [RFC3986]. West Expires April 11, 2016 [Page 2] Internet-Draft cookie-prefixes October 2015 3. Prefixes 3.1. The "$Secure-" prefix If a cookie's name begins with "$Secure-", the cookie MUST be set with a "Secure" attribute. The following cookie would be rejected: Set-Cookie: $Secure-SID=12345; Domain=example.com While the following would be accepted: Set-Cookie: $Secure-SID=12345; Secure; Domain=example.com 3.2. The "$Origin-" prefix If a cookie's name begins with "$Origin-", the cookie MUST be: 1. Sent only to hosts which are identical to the host which set the cookie. That is, a cookie named "$Origin-cookie1" set from "https://example.com" MUST NOT contain a "Domain" attribute (and will therefore sent only to "example.com", and not to "subdomain.example.com"). 2. Sent to every request for a host. That is, a cookie named "$Origin-cookie1" MUST contain a "Path" attribute with a value of "/". 3. Sent only to secure origins, if set from a secure origin. That is, a cookie named "$Origin-cookie1" set from "https://example.com" MUST contain a "Secure" attribute, as it was set from a URI whose "scheme" is considered "secure" by the user agent. The following cookies would always be rejected: Set-Cookie: $Origin-SID=12345 Set-Cookie: $Origin-SID=12345; Secure Set-Cookie: $Origin-SID=12345; Domain=example.com Set-Cookie: $Origin-SID=12345; Secure; Domain=example.com The following would be rejected, if set from a secure origin, but accepted if set from a non-secure origin: Set-Cookie: $Origin-SID=12345; Path=/ While the following would be accepted, if set from a secure origin: West Expires April 11, 2016 [Page 3] Internet-Draft cookie-prefixes October 2015 Set-Cookie: $Origin-SID=12345; Secure; Path=/ 3.3. The "$SecureOrigin-" prefix If a cookie's name begins with "$SecureOrigin-", the cookie MUST be: 1. Sent only to hosts which are identical to the host which set the cookie. That is, a cookie named "$SecureOrigin-cookie1" set from "https://example.com" MUST NOT contain a "Domain" attribute (and will therefore sent only to "example.com", and not to "subdomain.example.com"). 2. Sent to every request for a host. That is, a cookie named "$SecureOrigin-cookie1" MUST contain a "Path" attribute with a value of "/". 3. Sent only to secure origins. That is, a cookie named "$SecureOrigin-cookie1" MUST contain a "Secure" attribute. 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 "$Origin-", then: 1. If the "scheme" component of the "request-uri" denotes a "secure" protocol (as determined by the user agent), and the cookie's "secure-only-flag" is "false", abort these steps and ignore the cookie entirely. 2. If the cookie's "host-only-flag" is "false", abort these steps and ignore the cookie entirely. 3. If the cookie's "path" is not "/", abort these steps and ignore the cookie entirely. 2. If the "cookie-name" begins with the string "$Secure-", and the cookie's "secure-only-flag" is "false", abort these steps and ignore the cookie entirely. 3. If the "cookie-name" begins with the string "$SecureOrigin-", then: West Expires April 11, 2016 [Page 4] Internet-Draft cookie-prefixes October 2015 1. If the cookie's "secure-only-flag" is "false", abort these steps and ignore the cookie entirely. 2. If the cookie's "host-only-flag" is "false", abort these steps and ignore the cookie entirely. 3. If the cookie's "path" is not "/", abort these steps and ignore the cookie entirely. 5. Aesthetic Considerations Prefixes are ugly. :( 6. Security Considerations 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. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ RFC2119, 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, . [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, DOI 10.17487/RFC6265, April 2011, . Appendix A. Acknowledgements Eric Lawrence had this idea a million years ago. Devdatta Akhawe helped justify the potential impact of the scheme on real-world websites. Author's Address West Expires April 11, 2016 [Page 5] Internet-Draft cookie-prefixes October 2015 Mike West Google, Inc Email: mkwst@google.com URI: https://mikewest.org/ West Expires April 11, 2016 [Page 6]