idnits 2.17.1 draft-west-cookie-prefixes-05.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 (November 30, 2015) is 3068 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 248, 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 HTTPbis M. West 3 Internet-Draft Google, Inc 4 Updates: 6265 (if approved) November 30, 2015 5 Intended status: Standards Track 6 Expires: June 2, 2016 8 Cookie Prefixes 9 draft-west-cookie-prefixes-05 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 June 2, 2016. 37 Copyright Notice 39 Copyright (c) 2015 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 . . . . . . . . . . . . . . . . . . . 5 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 107 2. Set from a URI whose "scheme" is considered "secure" by the user 108 agent. 110 The following cookie would be rejected when set from any origin, as 111 the "Secure" flag is not set 113 Set-Cookie: __Secure-SID=12345; Domain=example.com 115 While the following would be accepted if set from a secure origin 116 (e.g. "https://example.com/"), and rejected otherwise: 118 Set-Cookie: __Secure-SID=12345; Secure; Domain=example.com 120 3.2. The "__Host-" prefix 122 If a cookie's name begins with "__Host-", the cookie MUST be: 124 1. Set with a "Secure" attribute 126 2. Set from a URI whose "scheme" is considered "secure" by the user 127 agent. 129 3. Sent only to the host which set the cookie. That is, a cookie 130 named "__Host-cookie1" set from "https://example.com" MUST NOT 131 contain a "Domain" attribute (and will therefore be sent only to 132 "example.com", and not to "subdomain.example.com"). 134 4. Sent to every request for a host. That is, a cookie named 135 "__Host-cookie1" MUST contain a "Path" attribute with a value of 136 "/". 138 The following cookies would always be rejected: 140 Set-Cookie: __Host-SID=12345 141 Set-Cookie: __Host-SID=12345; Secure 142 Set-Cookie: __Host-SID=12345; Domain=example.com 143 Set-Cookie: __Host-SID=12345; Domain=example.com; Path=/ 144 Set-Cookie: __Host-SID=12345; Secure; Domain=example.com; Path=/ 145 While the following would be accepted if set from a secure origin 146 (e.g. "https://example.com/"), and rejected otherwise: 148 Set-Cookie: __Host-SID=12345; Secure; Path=/ 150 4. User Agent Requirements 152 This document updates Section 5.3 of [RFC6265] as follows: 154 After step 10 of the current algorithm, the cookies flags are set. 155 Insert the following steps to perform the prefix checks this document 156 specifies: 158 1. If the "cookie-name" begins with the string "__Secure-" or 159 "__Host-", abort these steps and ignore the cookie entirely 160 unless both of the following conditions are true: 162 * The cookie's "secure-only-flag" is "true" 164 * "request-uri"'s "scheme" component denotes a "secure" protocol 165 (as determined by the user agent) 167 2. If the "cookie-name" begins with the string "__Host-", abort 168 these steps and ignore the cookie entirely unless the following 169 conditions are true: 171 * The cookie's "host-only-flag" is "true" 173 * The cookie's "path" is "/" 175 5. Aesthetic Considerations 177 5.1. Not pretty. 179 Prefixes are ugly. :( 181 5.2. Why "__"? 183 We started with "$", but ran into issues with servers that had 184 implemented [RFC2109]-style cookies. "__" is a prefix used for a 185 number of well-known cookies in the wild (notably Google Analytics's 186 "__ut*" cookies, and CloudFlare's "__cfduid"), and so is unlikely to 187 produce such compatibility issues, while being uncommon enough to 188 mitigate the risk of collisions. 190 6. Security Considerations 192 6.1. Secure Origins Only 194 It would certainly be possible to extend this scheme to non-secure 195 origins (and an earlier draft of this document did exactly that). 196 User agents, however, are slowly moving towards a world where 197 features with security implications are available only over secure 198 transport (see [SECURE-CONTEXTS], [POWERFUL-FEATURES], and 199 [DEPRECATING-HTTP]). This document follows that trend, limiting 200 exciting new cookie properties to secure transport in order to ensure 201 that user agents can make claims which middlemen will have a hard 202 time violating. 204 To that end, note that the requirements listed above mean that 205 prefixed cookies will be rejected entirely if a non-secure origin 206 attempts to set them. 208 6.2. Limitations 210 This scheme gives no assurance to the server that the restrictions on 211 cookie names are enforced. Servers could certainly probe the user 212 agent's functionality to determine support, or sniff based on the 213 "User-Agent" request header, if such assurances were deemed 214 necessary. 216 7. References 218 7.1. Normative References 220 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 221 Requirement Levels", BCP 14, RFC 2119, March 1997. 223 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 224 Resource Identifier (URI): Generic Syntax", STD 66, RFC 225 3986, DOI 10.17487/RFC3986, January 2005, 226 . 228 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 229 April 2011. 231 7.2. Informative References 233 [DEPRECATING-HTTP] 234 Barnes, R., "Deprecating Non-Secure HTTP", n.d., 235 . 238 [Lawrence2015] 239 Lawrence, E., "Duct Tape and Baling Wire -- Cookie 240 Prefixes", n.d., . 243 [POWERFUL-FEATURES] 244 Palmer, C., "Prefer Secure Origins for Powerful New 245 Features", n.d., . 248 [RFC2109] Kristol, D. and L. Montulli, "HTTP State Management 249 Mechanism", RFC 2109, DOI 10.17487/RFC2109, February 1997, 250 . 252 [SECURE-CONTEXTS] 253 West, M., "Secure Contexts", n.d., . 256 Appendix A. Acknowledgements 258 Eric Lawrence had this idea a million years ago, and wrote about its 259 genesis in [Lawrence2015]. Devdatta Akhawe helped justify the 260 potential impact of the scheme on real-world websites. Thomas Broyer 261 pointed out the issues with a leading "$" in the prefixes, and Brian 262 Smith provided valuable contributions to the discussion around a 263 replacement (ISO C indeed). 265 Author's Address 267 Mike West 268 Google, Inc 270 Email: mkwst@google.com 271 URI: https://mikewest.org/