idnits 2.17.1 draft-ietf-httpbis-cookie-prefixes-00.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (February 23, 2016) is 2983 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'RFC2109' is defined on line 244, but no explicit reference was found in the text -- Obsolete informational reference (is this intentional?): RFC 2109 (Obsoleted by RFC 2965) Summary: 1 error (**), 0 flaws (~~), 2 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTP Working Group M. West 3 Internet-Draft Google, Inc 4 Updates: 6265 (if approved) February 23, 2016 5 Intended status: Standards Track 6 Expires: August 26, 2016 8 Cookie Prefixes 9 draft-ietf-httpbis-cookie-prefixes-00 11 Abstract 13 This document updates RFC6265 by adding a set of restrictions upon 14 the names which may be used for cookies with specific properties. 15 These restrictions enable user agents to smuggle cookie state to the 16 server within the confines of the existing "Cookie" request header 17 syntax, and limits the ways in which cookies may be abused in a 18 conforming user agent. 20 Status of This Memo 22 This Internet-Draft is submitted in full conformance with the 23 provisions of BCP 78 and BCP 79. 25 Internet-Drafts are working documents of the Internet Engineering 26 Task Force (IETF). Note that other groups may also distribute 27 working documents as Internet-Drafts. The list of current Internet- 28 Drafts is at http://datatracker.ietf.org/drafts/current/. 30 Internet-Drafts are draft documents valid for a maximum of six months 31 and may be updated, replaced, or obsoleted by other documents at any 32 time. It is inappropriate to use Internet-Drafts as reference 33 material or to cite them other than as "work in progress." 35 This Internet-Draft will expire on August 26, 2016. 37 Copyright Notice 39 Copyright (c) 2016 IETF Trust and the persons identified as the 40 document authors. All rights reserved. 42 This document is subject to BCP 78 and the IETF Trust's Legal 43 Provisions Relating to IETF Documents 44 (http://trustee.ietf.org/license-info) in effect on the date of 45 publication of this document. Please review these documents 46 carefully, as they describe your rights and restrictions with respect 47 to this document. Code Components extracted from this document must 48 include Simplified BSD License text as described in Section 4.e of 49 the Trust Legal Provisions and are provided without warranty as 50 described in the Simplified BSD License. 52 Table of Contents 54 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 55 2. Terminology and notation . . . . . . . . . . . . . . . . . . 2 56 3. Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . 3 57 3.1. The "__Secure-" prefix . . . . . . . . . . . . . . . . . 3 58 3.2. The "__Host-" prefix . . . . . . . . . . . . . . . . . . 3 59 4. User Agent Requirements . . . . . . . . . . . . . . . . . . . 4 60 5. Aesthetic Considerations . . . . . . . . . . . . . . . . . . 4 61 5.1. Not pretty. . . . . . . . . . . . . . . . . . . . . . . . 4 62 5.2. Why "__"? . . . . . . . . . . . . . . . . . . . . . . . . 4 63 6. Security Considerations . . . . . . . . . . . . . . . . . . . 4 64 6.1. Secure Origins Only . . . . . . . . . . . . . . . . . . . 5 65 6.2. Limitations . . . . . . . . . . . . . . . . . . . . . . . 5 66 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 5 67 7.1. Normative References . . . . . . . . . . . . . . . . . . 5 68 7.2. Informative References . . . . . . . . . . . . . . . . . 5 69 Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 6 70 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6 72 1. Introduction 74 Section 8.5 and Section 8.6 of [RFC6265] spell out some of the 75 drawbacks of cookies' implementation: due to historical accident, it 76 is impossible for a server to have confidence that a cookie set in a 77 secure way (e.g., as a domain cookie with the "Secure" (and possibly 78 "HttpOnly") flags set) remains intact and untouched by non-secure 79 subdomains. 81 We can't alter the syntax of the "Cookie" request header, as that 82 would likely break a number of implementations. This rules out 83 sending a cookie's flags along with the cookie directly, but we can 84 smuggle information along with the cookie if we reserve certain name 85 prefixes for cookies with certain properties. 87 This document describes such a scheme, which enables servers to set 88 cookies which conforming user agents will ensure are "Secure", and 89 locked to a domain. 91 2. Terminology and notation 93 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 94 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 95 document are to be interpreted as described in [RFC2119]. 97 The "scheme" component of a URI is defined in Section 3 of [RFC3986]. 99 3. Prefixes 101 3.1. The "__Secure-" prefix 103 If a cookie's name begins with "__Secure-", the cookie MUST be: 105 1. Set with a "Secure" attribute 106 2. Set from a URI whose "scheme" is considered "secure" by the user 107 agent. 109 The following cookie would be rejected when set from any origin, as 110 the "Secure" flag is not set 112 Set-Cookie: __Secure-SID=12345; Domain=example.com 114 While the following would be accepted if set from a secure origin 115 (e.g. "https://example.com/"), and rejected otherwise: 117 Set-Cookie: __Secure-SID=12345; Secure; Domain=example.com 119 3.2. The "__Host-" prefix 121 If a cookie's name begins with "__Host-", the cookie MUST be: 123 1. Set with a "Secure" attribute 124 2. Set from a URI whose "scheme" is considered "secure" by the user 125 agent. 126 3. Sent only to the host which set the cookie. That is, a cookie 127 named "__Host-cookie1" set from "https://example.com" MUST NOT 128 contain a "Domain" attribute (and will therefore be sent only to 129 "example.com", and not to "subdomain.example.com"). 130 4. Sent to every request for a host. That is, a cookie named 131 "__Host-cookie1" MUST contain a "Path" attribute with a value of 132 "/". 134 The following cookies would always be rejected: 136 Set-Cookie: __Host-SID=12345 137 Set-Cookie: __Host-SID=12345; Secure 138 Set-Cookie: __Host-SID=12345; Domain=example.com 139 Set-Cookie: __Host-SID=12345; Domain=example.com; Path=/ 140 Set-Cookie: __Host-SID=12345; Secure; Domain=example.com; Path=/ 141 While the following would be accepted if set from a secure origin 142 (e.g. "https://example.com/"), and rejected otherwise: 144 Set-Cookie: __Host-SID=12345; Secure; Path=/ 146 4. User Agent Requirements 148 This document updates Section 5.3 of [RFC6265] as follows: 150 After step 10 of the current algorithm, the cookies flags are set. 151 Insert the following steps to perform the prefix checks this document 152 specifies: 154 1. If the "cookie-name" begins with the string "__Secure-" or 155 "__Host-", abort these steps and ignore the cookie entirely 156 unless both of the following conditions are true: 158 * The cookie's "secure-only-flag" is "true" 159 * "request-uri"'s "scheme" component denotes a "secure" protocol 160 (as determined by the user agent) 161 2. If the "cookie-name" begins with the string "__Host-", abort 162 these steps and ignore the cookie entirely unless the following 163 conditions are true: 165 * The cookie's "host-only-flag" is "true" 166 * The cookie's "path" is "/" 168 5. Aesthetic Considerations 170 5.1. Not pretty. 172 Prefixes are ugly. :( 174 5.2. Why "__"? 176 We started with "$", but ran into issues with servers that had 177 implemented [RFC2109]-style cookies. "__" is a prefix used for a 178 number of well-known cookies in the wild (notably Google Analytics's 179 "__ut*" cookies, and CloudFlare's "__cfduid"), and so is unlikely to 180 produce such compatibility issues, while being uncommon enough to 181 mitigate the risk of collisions. 183 6. Security Considerations 184 6.1. Secure Origins Only 186 It would certainly be possible to extend this scheme to non-secure 187 origins (and an earlier draft of this document did exactly that). 188 User agents, however, are slowly moving towards a world where 189 features with security implications are available only over secure 190 transport (see [SECURE-CONTEXTS], [POWERFUL-FEATURES], and 191 [DEPRECATING-HTTP]). This document follows that trend, limiting 192 exciting new cookie properties to secure transport in order to ensure 193 that user agents can make claims which middlemen will have a hard 194 time violating. 196 To that end, note that the requirements listed above mean that 197 prefixed cookies will be rejected entirely if a non-secure origin 198 attempts to set them. 200 6.2. Limitations 202 This scheme gives no assurance to the server that the restrictions on 203 cookie names are enforced. Servers could certainly probe the user 204 agent's functionality to determine support, or sniff based on the 205 "User-Agent" request header, if such assurances were deemed 206 necessary. 208 7. References 210 7.1. Normative References 212 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 213 Requirement Levels", BCP 14, RFC 2119, 214 DOI 10.17487/RFC2119, March 1997, 215 . 217 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 218 Resource Identifier (URI): Generic Syntax", STD 66, 219 RFC 3986, DOI 10.17487/RFC3986, January 2005, 220 . 222 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 223 DOI 10.17487/RFC6265, April 2011, 224 . 226 7.2. Informative References 228 [DEPRECATING-HTTP] 229 Barnes, R., "Deprecating Non-Secure HTTP", April 2015, 230 . 233 [Lawrence2015] 234 Lawrence, E., "Duct Tape and Baling Wire -- Cookie 235 Prefixes", October 2015, 236 . 239 [POWERFUL-FEATURES] 240 Palmer, C., "Prefer Secure Origins for Powerful New 241 Features", 2015, . 244 [RFC2109] Kristol, D. and L. Montulli, "HTTP State Management 245 Mechanism", RFC 2109, DOI 10.17487/RFC2109, February 1997, 246 . 248 [SECURE-CONTEXTS] 249 West, M., "Secure Contexts", 2016, . 252 Appendix A. Acknowledgements 254 Eric Lawrence had this idea a million years ago, and wrote about its 255 genesis in [Lawrence2015]. Devdatta Akhawe helped justify the 256 potential impact of the scheme on real-world websites. Thomas Broyer 257 pointed out the issues with a leading "$" in the prefixes, and Brian 258 Smith provided valuable contributions to the discussion around a 259 replacement (ISO C indeed). 261 Author's Address 263 Mike West 264 Google, Inc 266 Email: mkwst@google.com 267 URI: https://mikewest.org/