idnits 2.17.1 draft-ietf-httpbis-rfc6265bis-07.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: ---------------------------------------------------------------------------- == There is 1 instance of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (7 December 2020) is 1228 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) -- Possible downref: Non-RFC (?) normative reference: ref. 'FETCH' -- Possible downref: Non-RFC (?) normative reference: ref. 'HTML' ** Obsolete normative reference: RFC 3490 (Obsoleted by RFC 5890, RFC 5891) ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) -- Possible downref: Non-RFC (?) normative reference: ref. 'SERVICE-WORKERS' -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 3 errors (**), 0 flaws (~~), 3 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTP M. West, Ed. 3 Internet-Draft Google, Inc 4 Obsoletes: 6265 (if approved) J. Wilander, Ed. 5 Intended status: Standards Track Apple, Inc 6 Expires: 10 June 2021 7 December 2020 8 Cookies: HTTP State Management Mechanism 9 draft-ietf-httpbis-rfc6265bis-07 11 Abstract 13 This document defines the HTTP Cookie and Set-Cookie header fields. 14 These header fields can be used by HTTP servers to store state 15 (called cookies) at HTTP user agents, letting the servers maintain a 16 stateful session over the mostly stateless HTTP protocol. Although 17 cookies have many historical infelicities that degrade their security 18 and privacy, the Cookie and Set-Cookie header fields are widely used 19 on the Internet. This document obsoletes RFC 6265. 21 Note to Readers 23 Discussion of this draft takes place on the HTTP working group 24 mailing list (ietf-http-wg@w3.org), which is archived at 25 https://lists.w3.org/Archives/Public/ietf-http-wg/ 26 (https://lists.w3.org/Archives/Public/ietf-http-wg/). 28 Working Group information can be found at http://httpwg.github.io/ 29 (http://httpwg.github.io/); source code and issues list for this 30 draft can be found at https://github.com/httpwg/http-extensions/ 31 labels/6265bis (https://github.com/httpwg/http-extensions/ 32 labels/6265bis). 34 Status of This Memo 36 This Internet-Draft is submitted in full conformance with the 37 provisions of BCP 78 and BCP 79. 39 Internet-Drafts are working documents of the Internet Engineering 40 Task Force (IETF). Note that other groups may also distribute 41 working documents as Internet-Drafts. The list of current Internet- 42 Drafts is at https://datatracker.ietf.org/drafts/current/. 44 Internet-Drafts are draft documents valid for a maximum of six months 45 and may be updated, replaced, or obsoleted by other documents at any 46 time. It is inappropriate to use Internet-Drafts as reference 47 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on 10 June 2021. 50 Copyright Notice 52 Copyright (c) 2020 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 57 license-info) in effect on the date of publication of this document. 58 Please review these documents carefully, as they describe your rights 59 and restrictions with respect to this document. Code Components 60 extracted from this document must include Simplified BSD License text 61 as described in Section 4.e of the Trust Legal Provisions and are 62 provided without warranty as described in the Simplified BSD License. 64 This document may contain material from IETF Documents or IETF 65 Contributions published or made publicly available before November 66 10, 2008. The person(s) controlling the copyright in some of this 67 material may not have granted the IETF Trust the right to allow 68 modifications of such material outside the IETF Standards Process. 69 Without obtaining an adequate license from the person(s) controlling 70 the copyright in such materials, this document may not be modified 71 outside the IETF Standards Process, and derivative works of it may 72 not be created outside the IETF Standards Process, except to format 73 it for publication as an RFC or to translate it into languages other 74 than English. 76 Table of Contents 78 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 79 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 5 80 2.1. Conformance Criteria . . . . . . . . . . . . . . . . . . 5 81 2.2. Syntax Notation . . . . . . . . . . . . . . . . . . . . . 5 82 2.3. Terminology . . . . . . . . . . . . . . . . . . . . . . . 6 83 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 7 84 3.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 7 85 4. Server Requirements . . . . . . . . . . . . . . . . . . . . . 9 86 4.1. Set-Cookie . . . . . . . . . . . . . . . . . . . . . . . 9 87 4.1.1. Syntax . . . . . . . . . . . . . . . . . . . . . . . 9 88 4.1.2. Semantics (Non-Normative) . . . . . . . . . . . . . . 11 89 4.1.3. Cookie Name Prefixes . . . . . . . . . . . . . . . . 14 90 4.2. Cookie . . . . . . . . . . . . . . . . . . . . . . . . . 16 91 4.2.1. Syntax . . . . . . . . . . . . . . . . . . . . . . . 16 92 4.2.2. Semantics . . . . . . . . . . . . . . . . . . . . . . 16 93 5. User Agent Requirements . . . . . . . . . . . . . . . . . . . 16 94 5.1. Subcomponent Algorithms . . . . . . . . . . . . . . . . . 17 95 5.1.1. Dates . . . . . . . . . . . . . . . . . . . . . . . . 17 96 5.1.2. Canonicalized Host Names . . . . . . . . . . . . . . 18 97 5.1.3. Domain Matching . . . . . . . . . . . . . . . . . . . 19 98 5.1.4. Paths and Path-Match . . . . . . . . . . . . . . . . 19 99 5.2. "Same-site" and "cross-site" Requests . . . . . . . . . . 20 100 5.2.1. Document-based requests . . . . . . . . . . . . . . . 21 101 5.2.2. Worker-based requests . . . . . . . . . . . . . . . . 22 102 5.3. The Set-Cookie Header . . . . . . . . . . . . . . . . . . 23 103 5.3.1. The Expires Attribute . . . . . . . . . . . . . . . . 25 104 5.3.2. The Max-Age Attribute . . . . . . . . . . . . . . . . 25 105 5.3.3. The Domain Attribute . . . . . . . . . . . . . . . . 26 106 5.3.4. The Path Attribute . . . . . . . . . . . . . . . . . 26 107 5.3.5. The Secure Attribute . . . . . . . . . . . . . . . . 27 108 5.3.6. The HttpOnly Attribute . . . . . . . . . . . . . . . 27 109 5.3.7. The SameSite Attribute . . . . . . . . . . . . . . . 27 110 5.4. Storage Model . . . . . . . . . . . . . . . . . . . . . . 28 111 5.5. The Cookie Header . . . . . . . . . . . . . . . . . . . . 33 112 6. Implementation Considerations . . . . . . . . . . . . . . . . 36 113 6.1. Limits . . . . . . . . . . . . . . . . . . . . . . . . . 36 114 6.2. Application Programming Interfaces . . . . . . . . . . . 36 115 6.3. IDNA Dependency and Migration . . . . . . . . . . . . . . 36 116 7. Privacy Considerations . . . . . . . . . . . . . . . . . . . 37 117 7.1. Third-Party Cookies . . . . . . . . . . . . . . . . . . . 37 118 7.2. User Controls . . . . . . . . . . . . . . . . . . . . . . 38 119 7.3. Expiration Dates . . . . . . . . . . . . . . . . . . . . 38 120 8. Security Considerations . . . . . . . . . . . . . . . . . . . 38 121 8.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 38 122 8.2. Ambient Authority . . . . . . . . . . . . . . . . . . . . 39 123 8.3. Clear Text . . . . . . . . . . . . . . . . . . . . . . . 39 124 8.4. Session Identifiers . . . . . . . . . . . . . . . . . . . 40 125 8.5. Weak Confidentiality . . . . . . . . . . . . . . . . . . 41 126 8.6. Weak Integrity . . . . . . . . . . . . . . . . . . . . . 41 127 8.7. Reliance on DNS . . . . . . . . . . . . . . . . . . . . . 42 128 8.8. SameSite Cookies . . . . . . . . . . . . . . . . . . . . 42 129 8.8.1. Defense in depth . . . . . . . . . . . . . . . . . . 43 130 8.8.2. Top-level Navigations . . . . . . . . . . . . . . . . 43 131 8.8.3. Mashups and Widgets . . . . . . . . . . . . . . . . . 44 132 8.8.4. Server-controlled . . . . . . . . . . . . . . . . . . 44 133 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 134 9.1. Cookie . . . . . . . . . . . . . . . . . . . . . . . . . 44 135 9.2. Set-Cookie . . . . . . . . . . . . . . . . . . . . . . . 44 136 9.3. Cookie Attribute Registry . . . . . . . . . . . . . . . . 45 137 9.3.1. Procedure . . . . . . . . . . . . . . . . . . . . . . 45 138 9.3.2. Registration . . . . . . . . . . . . . . . . . . . . 45 139 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 46 140 10.1. Normative References . . . . . . . . . . . . . . . . . . 46 141 10.2. Informative References . . . . . . . . . . . . . . . . . 48 142 Appendix A. Changes . . . . . . . . . . . . . . . . . . . . . . 49 143 A.1. draft-ietf-httpbis-rfc6265bis-00 . . . . . . . . . . . . 49 144 A.2. draft-ietf-httpbis-rfc6265bis-01 . . . . . . . . . . . . 50 145 A.3. draft-ietf-httpbis-rfc6265bis-02 . . . . . . . . . . . . 50 146 A.4. draft-ietf-httpbis-rfc6265bis-03 . . . . . . . . . . . . 51 147 A.5. draft-ietf-httpbis-rfc6265bis-04 . . . . . . . . . . . . 51 148 A.6. draft-ietf-httpbis-rfc6265bis-05 . . . . . . . . . . . . 52 149 A.7. draft-ietf-httpbis-rfc6265bis-06 . . . . . . . . . . . . 52 150 A.8. draft-ietf-httpbis-rfc6265bis-07 . . . . . . . . . . . . 52 151 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 53 152 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 53 154 1. Introduction 156 This document defines the HTTP Cookie and Set-Cookie header fields. 157 Using the Set-Cookie header field, an HTTP server can pass name/value 158 pairs and associated metadata (called cookies) to a user agent. When 159 the user agent makes subsequent requests to the server, the user 160 agent uses the metadata and other information to determine whether to 161 return the name/value pairs in the Cookie header. 163 Although simple on their surface, cookies have a number of 164 complexities. For example, the server indicates a scope for each 165 cookie when sending it to the user agent. The scope indicates the 166 maximum amount of time in which the user agent should return the 167 cookie, the servers to which the user agent should return the cookie, 168 and the URI schemes for which the cookie is applicable. 170 For historical reasons, cookies contain a number of security and 171 privacy infelicities. For example, a server can indicate that a 172 given cookie is intended for "secure" connections, but the Secure 173 attribute does not provide integrity in the presence of an active 174 network attacker. Similarly, cookies for a given host are shared 175 across all the ports on that host, even though the usual "same-origin 176 policy" used by web browsers isolates content retrieved via different 177 ports. 179 There are two audiences for this specification: developers of cookie- 180 generating servers and developers of cookie-consuming user agents. 182 To maximize interoperability with user agents, servers SHOULD limit 183 themselves to the well-behaved profile defined in Section 4 when 184 generating cookies. 186 User agents MUST implement the more liberal processing rules defined 187 in Section 5, in order to maximize interoperability with existing 188 servers that do not conform to the well-behaved profile defined in 189 Section 4. 191 This document specifies the syntax and semantics of these headers as 192 they are actually used on the Internet. In particular, this document 193 does not create new syntax or semantics beyond those in use today. 194 The recommendations for cookie generation provided in Section 4 195 represent a preferred subset of current server behavior, and even the 196 more liberal cookie processing algorithm provided in Section 5 does 197 not recommend all of the syntactic and semantic variations in use 198 today. Where some existing software differs from the recommended 199 protocol in significant ways, the document contains a note explaining 200 the difference. 202 This document obsoletes [RFC6265]. 204 2. Conventions 206 2.1. Conformance Criteria 208 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 209 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 210 document are to be interpreted as described in [RFC2119]. 212 Requirements phrased in the imperative as part of algorithms (such as 213 "strip any leading space characters" or "return false and abort these 214 steps") are to be interpreted with the meaning of the key word 215 ("MUST", "SHOULD", "MAY", etc.) used in introducing the algorithm. 217 Conformance requirements phrased as algorithms or specific steps can 218 be implemented in any manner, so long as the end result is 219 equivalent. In particular, the algorithms defined in this 220 specification are intended to be easy to understand and are not 221 intended to be performant. 223 2.2. Syntax Notation 225 This specification uses the Augmented Backus-Naur Form (ABNF) 226 notation of [RFC5234]. 228 The following core rules are included by reference, as defined in 229 [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF 230 (CR LF), CTLs (controls), DIGIT (decimal 0-9), DQUOTE (double quote), 231 HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), NUL (null octet), 232 OCTET (any 8-bit sequence of data except NUL), SP (space), HTAB 233 (horizontal tab), CHAR (any [USASCII] character), VCHAR (any visible 234 [USASCII] character), and WSP (whitespace). 236 The OWS (optional whitespace) and BWS (bad whitespace) rules are 237 defined in Section 3.2.3 of [RFC7230]. 239 2.3. Terminology 241 The terms "user agent", "client", "server", "proxy", and "origin 242 server" have the same meaning as in the HTTP/1.1 specification 243 ([RFC7230], Section 2). 245 The request-host is the name of the host, as known by the user agent, 246 to which the user agent is sending an HTTP request or from which it 247 is receiving an HTTP response (i.e., the name of the host to which it 248 sent the corresponding HTTP request). 250 The term request-uri refers to "request-target" as defined in 251 Section 5.3 of [RFC7230]. 253 Two sequences of octets are said to case-insensitively match each 254 other if and only if they are equivalent under the i;ascii-casemap 255 collation defined in [RFC4790]. 257 The term string means a sequence of non-NUL octets. 259 The terms "active document", "ancestor browsing context", "browsing 260 context", "dedicated worker", "Document", "WorkerGlobalScope", 261 "sandboxed origin browsing context flag", "parent browsing context", 262 "shared worker", "the worker's Documents", "nested browsing context", 263 and "top-level browsing context" are defined in [HTML]. 265 "Service Workers" are defined in the Service Workers specification 266 [SERVICE-WORKERS]. 268 The term "origin", the mechanism of deriving an origin from a URI, 269 and the "the same" matching algorithm for origins are defined in 270 [RFC6454]. 272 "Safe" HTTP methods include "GET", "HEAD", "OPTIONS", and "TRACE", as 273 defined in Section 4.2.1 of [RFC7231]. 275 A domain's "public suffix" is the portion of a domain that is 276 controlled by a public registry, such as "com", "co.uk", and 277 "pvt.k12.wy.us". A domain's "registrable domain" is the domain's 278 public suffix plus the label to its left. That is, for 279 "https://www.site.example", the public suffix is "example", and the 280 registrable domain is "site.example". Whenever possible, user agents 281 SHOULD use an up-to-date public suffix list, such as the one 282 maintained by the Mozilla project at [PSL]. 284 The term "request", as well as a request's "client", "current url", 285 "method", and "target browsing context", are defined in [FETCH]. 287 3. Overview 289 This section outlines a way for an origin server to send state 290 information to a user agent and for the user agent to return the 291 state information to the origin server. 293 To store state, the origin server includes a Set-Cookie header in an 294 HTTP response. In subsequent requests, the user agent returns a 295 Cookie request header to the origin server. The Cookie header 296 contains cookies the user agent received in previous Set-Cookie 297 headers. The origin server is free to ignore the Cookie header or 298 use its contents for an application-defined purpose. 300 Origin servers MAY send a Set-Cookie response header with any 301 response. User agents MAY ignore Set-Cookie headers contained in 302 responses with 100-level status codes but MUST process Set-Cookie 303 headers contained in other responses (including responses with 400- 304 and 500-level status codes). An origin server can include multiple 305 Set-Cookie header fields in a single response. The presence of a 306 Cookie or a Set-Cookie header field does not preclude HTTP caches 307 from storing and reusing a response. 309 Origin servers SHOULD NOT fold multiple Set-Cookie header fields into 310 a single header field. The usual mechanism for folding HTTP headers 311 fields (i.e., as defined in Section 3.2.2 of [RFC7230]) might change 312 the semantics of the Set-Cookie header field because the %x2C (",") 313 character is used by Set-Cookie in a way that conflicts with such 314 folding. 316 3.1. Examples 318 Using the Set-Cookie header, a server can send the user agent a short 319 string in an HTTP response that the user agent will return in future 320 HTTP requests that are within the scope of the cookie. For example, 321 the server can send the user agent a "session identifier" named SID 322 with the value 31d4d96e407aad42. The user agent then returns the 323 session identifier in subsequent requests. 325 == Server -> User Agent == 327 Set-Cookie: SID=31d4d96e407aad42 329 == User Agent -> Server == 331 Cookie: SID=31d4d96e407aad42 332 The server can alter the default scope of the cookie using the Path 333 and Domain attributes. For example, the server can instruct the user 334 agent to return the cookie to every path and every subdomain of 335 site.example. 337 == Server -> User Agent == 339 Set-Cookie: SID=31d4d96e407aad42; Path=/; Domain=site.example 341 == User Agent -> Server == 343 Cookie: SID=31d4d96e407aad42 345 As shown in the next example, the server can store multiple cookies 346 at the user agent. For example, the server can store a session 347 identifier as well as the user's preferred language by returning two 348 Set-Cookie header fields. Notice that the server uses the Secure and 349 HttpOnly attributes to provide additional security protections for 350 the more sensitive session identifier (see Section 4.1.2). 352 == Server -> User Agent == 354 Set-Cookie: SID=31d4d96e407aad42; Path=/; Secure; HttpOnly 355 Set-Cookie: lang=en-US; Path=/; Domain=site.example 357 == User Agent -> Server == 359 Cookie: SID=31d4d96e407aad42; lang=en-US 361 Notice that the Cookie header above contains two cookies, one named 362 SID and one named lang. If the server wishes the user agent to 363 persist the cookie over multiple "sessions" (e.g., user agent 364 restarts), the server can specify an expiration date in the Expires 365 attribute. Note that the user agent might delete the cookie before 366 the expiration date if the user agent's cookie store exceeds its 367 quota or if the user manually deletes the server's cookie. 369 == Server -> User Agent == 371 Set-Cookie: lang=en-US; Expires=Wed, 09 Jun 2021 10:18:14 GMT 373 == User Agent -> Server == 375 Cookie: SID=31d4d96e407aad42; lang=en-US 376 Finally, to remove a cookie, the server returns a Set-Cookie header 377 with an expiration date in the past. The server will be successful 378 in removing the cookie only if the Path and the Domain attribute in 379 the Set-Cookie header match the values used when the cookie was 380 created. 382 == Server -> User Agent == 384 Set-Cookie: lang=; Expires=Sun, 06 Nov 1994 08:49:37 GMT 386 == User Agent -> Server == 388 Cookie: SID=31d4d96e407aad42 390 4. Server Requirements 392 This section describes the syntax and semantics of a well-behaved 393 profile of the Cookie and Set-Cookie headers. 395 4.1. Set-Cookie 397 The Set-Cookie HTTP response header is used to send cookies from the 398 server to the user agent. 400 4.1.1. Syntax 402 Informally, the Set-Cookie response header contains the header name 403 "Set-Cookie" followed by a ":" and a cookie. Each cookie begins with 404 a name-value-pair, followed by zero or more attribute-value pairs. 405 Servers SHOULD NOT send Set-Cookie headers that fail to conform to 406 the following grammar: 408 set-cookie-header = "Set-Cookie:" SP BWS set-cookie-string 409 set-cookie-string = BWS cookie-pair *( BWS ";" OWS cookie-av ) 410 cookie-pair = cookie-name BWS "=" BWS cookie-value 411 cookie-name = 1*cookie-octet 412 cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE ) 413 cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E 414 / %x80-FF 415 ; octets excluding CTLs, 416 ; whitespace DQUOTE, comma, semicolon, 417 ; and backslash 419 cookie-av = expires-av / max-age-av / domain-av / 420 path-av / secure-av / httponly-av / 421 samesite-av / extension-av 422 expires-av = "Expires" BWS "=" BWS sane-cookie-date 423 sane-cookie-date = 424 425 max-age-av = "Max-Age" BWS "=" BWS non-zero-digit *DIGIT 426 ; In practice, both expires-av and max-age-av 427 ; are limited to dates representable by the 428 ; user agent. 429 non-zero-digit = %x31-39 430 ; digits 1 through 9 431 domain-av = "Domain" BWS "=" BWS domain-value 432 domain-value = 433 ; defined in [RFC1034], Section 3.5, as 434 ; enhanced by [RFC1123], Section 2.1 435 path-av = "Path" BWS "=" BWS path-value 436 path-value = *av-octet 437 secure-av = "Secure" 438 httponly-av = "HttpOnly" 439 samesite-av = "SameSite" BWS "=" BWS samesite-value 440 samesite-value = "Strict" / "Lax" / "None" 441 extension-av = *av-octet 442 av-octet = %x20-3A / %x3C-7E 443 ; any CHAR except CTLs or ";" 445 Note that some of the grammatical terms above reference documents 446 that use different grammatical notations than this document (which 447 uses ABNF from [RFC5234]). 449 The semantics of the cookie-value are not defined by this document. 451 To maximize compatibility with user agents, servers that wish to 452 store arbitrary data in a cookie-value SHOULD encode that data, for 453 example, using Base64 [RFC4648]. 455 Per the grammar above, the cookie-value MAY be wrapped in DQUOTE 456 characters. Note that in this case, the initial and trailing DQUOTE 457 characters are not stripped. They are part of the cookie-value, and 458 will be included in Cookie headers sent to the server. 460 The portions of the set-cookie-string produced by the cookie-av term 461 are known as attributes. To maximize compatibility with user agents, 462 servers SHOULD NOT produce two attributes with the same name in the 463 same set-cookie-string. (See Section 5.4 for how user agents handle 464 this case.) 466 Servers SHOULD NOT include more than one Set-Cookie header field in 467 the same response with the same cookie-name. (See Section 5.3 for 468 how user agents handle this case.) 470 If a server sends multiple responses containing Set-Cookie headers 471 concurrently to the user agent (e.g., when communicating with the 472 user agent over multiple sockets), these responses create a "race 473 condition" that can lead to unpredictable behavior. 475 NOTE: Some existing user agents differ in their interpretation of 476 two-digit years. To avoid compatibility issues, servers SHOULD use 477 the rfc1123-date format, which requires a four-digit year. 479 NOTE: Some user agents store and process dates in cookies as 32-bit 480 UNIX time_t values. Implementation bugs in the libraries supporting 481 time_t processing on some systems might cause such user agents to 482 process dates after the year 2038 incorrectly. 484 4.1.2. Semantics (Non-Normative) 486 This section describes simplified semantics of the Set-Cookie header. 487 These semantics are detailed enough to be useful for understanding 488 the most common uses of cookies by servers. The full semantics are 489 described in Section 5. 491 When the user agent receives a Set-Cookie header, the user agent 492 stores the cookie together with its attributes. Subsequently, when 493 the user agent makes an HTTP request, the user agent includes the 494 applicable, non-expired cookies in the Cookie header. 496 If the user agent receives a new cookie with the same cookie-name, 497 domain-value, and path-value as a cookie that it has already stored, 498 the existing cookie is evicted and replaced with the new cookie. 499 Notice that servers can delete cookies by sending the user agent a 500 new cookie with an Expires attribute with a value in the past. 502 Unless the cookie's attributes indicate otherwise, the cookie is 503 returned only to the origin server (and not, for example, to any 504 subdomains), and it expires at the end of the current session (as 505 defined by the user agent). User agents ignore unrecognized cookie 506 attributes (but not the entire cookie). 508 4.1.2.1. The Expires Attribute 510 The Expires attribute indicates the maximum lifetime of the cookie, 511 represented as the date and time at which the cookie expires. The 512 user agent is not required to retain the cookie until the specified 513 date has passed. In fact, user agents often evict cookies due to 514 memory pressure or privacy concerns. 516 4.1.2.2. The Max-Age Attribute 518 The Max-Age attribute indicates the maximum lifetime of the cookie, 519 represented as the number of seconds until the cookie expires. The 520 user agent is not required to retain the cookie for the specified 521 duration. In fact, user agents often evict cookies due to memory 522 pressure or privacy concerns. 524 NOTE: Some existing user agents do not support the Max-Age attribute. 525 User agents that do not support the Max-Age attribute ignore the 526 attribute. 528 If a cookie has both the Max-Age and the Expires attribute, the Max- 529 Age attribute has precedence and controls the expiration date of the 530 cookie. If a cookie has neither the Max-Age nor the Expires 531 attribute, the user agent will retain the cookie until "the current 532 session is over" (as defined by the user agent). 534 4.1.2.3. The Domain Attribute 536 The Domain attribute specifies those hosts to which the cookie will 537 be sent. For example, if the value of the Domain attribute is 538 "site.example", the user agent will include the cookie in the Cookie 539 header when making HTTP requests to site.example, www.site.example, 540 and www.corp.site.example. (Note that a leading %x2E ("."), if 541 present, is ignored even though that character is not permitted, but 542 a trailing %x2E ("."), if present, will cause the user agent to 543 ignore the attribute.) If the server omits the Domain attribute, the 544 user agent will return the cookie only to the origin server. 546 WARNING: Some existing user agents treat an absent Domain attribute 547 as if the Domain attribute were present and contained the current 548 host name. For example, if site.example returns a Set-Cookie header 549 without a Domain attribute, these user agents will erroneously send 550 the cookie to www.site.example as well. 552 The user agent will reject cookies unless the Domain attribute 553 specifies a scope for the cookie that would include the origin 554 server. For example, the user agent will accept a cookie with a 555 Domain attribute of "site.example" or of "foo.site.example" from 556 foo.site.example, but the user agent will not accept a cookie with a 557 Domain attribute of "bar.site.example" or of "baz.foo.site.example". 559 NOTE: For security reasons, many user agents are configured to reject 560 Domain attributes that correspond to "public suffixes". For example, 561 some user agents will reject Domain attributes of "com" or "co.uk". 562 (See Section 5.4 for more information.) 564 4.1.2.4. The Path Attribute 566 The scope of each cookie is limited to a set of paths, controlled by 567 the Path attribute. If the server omits the Path attribute, the user 568 agent will use the "directory" of the request-uri's path component as 569 the default value. (See Section 5.1.4 for more details.) 571 The user agent will include the cookie in an HTTP request only if the 572 path portion of the request-uri matches (or is a subdirectory of) the 573 cookie's Path attribute, where the %x2F ("/") character is 574 interpreted as a directory separator. 576 Although seemingly useful for isolating cookies between different 577 paths within a given host, the Path attribute cannot be relied upon 578 for security (see Section 8). 580 4.1.2.5. The Secure Attribute 582 The Secure attribute limits the scope of the cookie to "secure" 583 channels (where "secure" is defined by the user agent). When a 584 cookie has the Secure attribute, the user agent will include the 585 cookie in an HTTP request only if the request is transmitted over a 586 secure channel (typically HTTP over Transport Layer Security (TLS) 587 [RFC2818]). 589 Although seemingly useful for protecting cookies from active network 590 attackers, the Secure attribute protects only the cookie's 591 confidentiality. An active network attacker can overwrite Secure 592 cookies from an insecure channel, disrupting their integrity (see 593 Section 8.6 for more details). 595 4.1.2.6. The HttpOnly Attribute 597 The HttpOnly attribute limits the scope of the cookie to HTTP 598 requests. In particular, the attribute instructs the user agent to 599 omit the cookie when providing access to cookies via "non-HTTP" APIs 600 (such as a web browser API that exposes cookies to scripts). 602 Note that the HttpOnly attribute is independent of the Secure 603 attribute: a cookie can have both the HttpOnly and the Secure 604 attribute. 606 4.1.2.7. The SameSite Attribute 608 The "SameSite" attribute limits the scope of the cookie such that it 609 will only be attached to requests if those requests are same-site, as 610 defined by the algorithm in Section 5.2. For example, requests for 611 "https://site.example/sekrit-image" will attach same-site cookies if 612 and only if initiated from a context whose "site for cookies" is an 613 origin with a scheme and registered domain of "https" and 614 "site.example" respectively. 616 If the "SameSite" attribute's value is "Strict", the cookie will only 617 be sent along with "same-site" requests. If the value is "Lax", the 618 cookie will be sent with same-site requests, and with "cross-site" 619 top-level navigations, as described in Section 5.3.7.1. If the value 620 is "None", the cookie will be sent with same-site and cross-site 621 requests. If the "SameSite" attribute's value is something other 622 than these three known keywords, the attribute's value will be 623 subject to a default enforcement mode that is equivalent to "Lax". 625 The "SameSite" attribute affects cookie creation as well as delivery. 626 Cookies which assert "SameSite=Lax" or "SameSite=Strict" cannot be 627 set in responses to cross-site subresource requests, or cross-site 628 nested navigations. They can be set along with any top-level 629 navigation, cross-site or otherwise. 631 4.1.3. Cookie Name Prefixes 633 Section 8.5 and Section 8.6 of this document spell out some of the 634 drawbacks of cookies' historical implementation. In particular, it 635 is impossible for a server to have confidence that a given cookie was 636 set with a particular set of attributes. In order to provide such 637 confidence in a backwards-compatible way, two common sets of 638 requirements can be inferred from the first few characters of the 639 cookie's name. 641 The normative requirements for the prefixes described below are 642 detailed in the storage model algorithm defined in Section 5.4. 644 4.1.3.1. The "__Secure-" Prefix 646 If a cookie's name begins with a case-sensitive match for the string 647 "__Secure-", then the cookie will have been set with a "Secure" 648 attribute. 650 For example, the following "Set-Cookie" header would be rejected by a 651 conformant user agent, as it does not have a "Secure" attribute. 653 Set-Cookie: __Secure-SID=12345; Domain=site.example 655 Whereas the following "Set-Cookie" header would be accepted: 657 Set-Cookie: __Secure-SID=12345; Domain=site.example; Secure 659 4.1.3.2. The "__Host-" Prefix 661 If a cookie's name begins with a case-sensitive match for the string 662 "__Host-", then the cookie will have been set with a "Secure" 663 attribute, a "Path" attribute with a value of "/", and no "Domain" 664 attribute. 666 This combination yields a cookie that hews as closely as a cookie can 667 to treating the origin as a security boundary. The lack of a 668 "Domain" attribute ensures that the cookie's "host-only-flag" is 669 true, locking the cookie to a particular host, rather than allowing 670 it to span subdomains. Setting the "Path" to "/" means that the 671 cookie is effective for the entire host, and won't be overridden for 672 specific paths. The "Secure" attribute ensures that the cookie is 673 unaltered by non-secure origins, and won't span protocols. 675 Ports are the only piece of the origin model that "__Host-" cookies 676 continue to ignore. 678 For example, the following cookies would always be rejected: 680 Set-Cookie: __Host-SID=12345 681 Set-Cookie: __Host-SID=12345; Secure 682 Set-Cookie: __Host-SID=12345; Domain=site.example 683 Set-Cookie: __Host-SID=12345; Domain=site.example; Path=/ 684 Set-Cookie: __Host-SID=12345; Secure; Domain=site.example; Path=/ 686 While the following would be accepted if set from a secure origin 687 (e.g. "https://site.example/"), and rejected otherwise: 689 Set-Cookie: __Host-SID=12345; Secure; Path=/ 691 4.2. Cookie 693 4.2.1. Syntax 695 The user agent sends stored cookies to the origin server in the 696 Cookie header. If the server conforms to the requirements in 697 Section 4.1 (and the user agent conforms to the requirements in 698 Section 5), the user agent will send a Cookie header that conforms to 699 the following grammar: 701 cookie-header = "Cookie:" SP cookie-string 702 cookie-string = cookie-pair *( ";" SP cookie-pair ) 704 4.2.2. Semantics 706 Each cookie-pair represents a cookie stored by the user agent. The 707 cookie-pair contains the cookie-name and cookie-value the user agent 708 received in the Set-Cookie header. 710 Notice that the cookie attributes are not returned. In particular, 711 the server cannot determine from the Cookie header alone when a 712 cookie will expire, for which hosts the cookie is valid, for which 713 paths the cookie is valid, or whether the cookie was set with the 714 Secure or HttpOnly attributes. 716 The semantics of individual cookies in the Cookie header are not 717 defined by this document. Servers are expected to imbue these 718 cookies with application-specific semantics. 720 Although cookies are serialized linearly in the Cookie header, 721 servers SHOULD NOT rely upon the serialization order. In particular, 722 if the Cookie header contains two cookies with the same name (e.g., 723 that were set with different Path or Domain attributes), servers 724 SHOULD NOT rely upon the order in which these cookies appear in the 725 header. 727 5. User Agent Requirements 729 This section specifies the Cookie and Set-Cookie headers in 730 sufficient detail that a user agent implementing these requirements 731 precisely can interoperate with existing servers (even those that do 732 not conform to the well-behaved profile described in Section 4). 734 A user agent could enforce more restrictions than those specified 735 herein (e.g., for the sake of improved security); however, 736 experiments have shown that such strictness reduces the likelihood 737 that a user agent will be able to interoperate with existing servers. 739 5.1. Subcomponent Algorithms 741 This section defines some algorithms used by user agents to process 742 specific subcomponents of the Cookie and Set-Cookie headers. 744 5.1.1. Dates 746 The user agent MUST use an algorithm equivalent to the following 747 algorithm to parse a cookie-date. Note that the various boolean 748 flags defined as a part of the algorithm (i.e., found-time, found- 749 day-of-month, found-month, found-year) are initially "not set". 751 1. Using the grammar below, divide the cookie-date into date-tokens. 753 cookie-date = *delimiter date-token-list *delimiter 754 date-token-list = date-token *( 1*delimiter date-token ) 755 date-token = 1*non-delimiter 757 delimiter = %x09 / %x20-2F / %x3B-40 / %x5B-60 / %x7B-7E 758 non-delimiter = %x00-08 / %x0A-1F / DIGIT / ":" / ALPHA / %x7F-FF 759 non-digit = %x00-2F / %x3A-FF 761 day-of-month = 1*2DIGIT [ non-digit *OCTET ] 762 month = ( "jan" / "feb" / "mar" / "apr" / 763 "may" / "jun" / "jul" / "aug" / 764 "sep" / "oct" / "nov" / "dec" ) *OCTET 765 year = 2*4DIGIT [ non-digit *OCTET ] 766 time = hms-time [ non-digit *OCTET ] 767 hms-time = time-field ":" time-field ":" time-field 768 time-field = 1*2DIGIT 770 2. Process each date-token sequentially in the order the date-tokens 771 appear in the cookie-date: 773 1. If the found-time flag is not set and the token matches the 774 time production, set the found-time flag and set the hour- 775 value, minute-value, and second-value to the numbers denoted 776 by the digits in the date-token, respectively. Skip the 777 remaining sub-steps and continue to the next date-token. 779 2. If the found-day-of-month flag is not set and the date-token 780 matches the day-of-month production, set the found-day-of- 781 month flag and set the day-of-month-value to the number 782 denoted by the date-token. Skip the remaining sub-steps and 783 continue to the next date-token. 785 3. If the found-month flag is not set and the date-token matches 786 the month production, set the found-month flag and set the 787 month-value to the month denoted by the date-token. Skip the 788 remaining sub-steps and continue to the next date-token. 790 4. If the found-year flag is not set and the date-token matches 791 the year production, set the found-year flag and set the 792 year-value to the number denoted by the date-token. Skip the 793 remaining sub-steps and continue to the next date-token. 795 3. If the year-value is greater than or equal to 70 and less than or 796 equal to 99, increment the year-value by 1900. 798 4. If the year-value is greater than or equal to 0 and less than or 799 equal to 69, increment the year-value by 2000. 801 1. NOTE: Some existing user agents interpret two-digit years 802 differently. 804 5. Abort these steps and fail to parse the cookie-date if: 806 * at least one of the found-day-of-month, found-month, found- 807 year, or found-time flags is not set, 809 * the day-of-month-value is less than 1 or greater than 31, 811 * the year-value is less than 1601, 813 * the hour-value is greater than 23, 815 * the minute-value is greater than 59, or 817 * the second-value is greater than 59. 819 (Note that leap seconds cannot be represented in this syntax.) 821 6. Let the parsed-cookie-date be the date whose day-of-month, month, 822 year, hour, minute, and second (in UTC) are the day-of-month- 823 value, the month-value, the year-value, the hour-value, the 824 minute-value, and the second-value, respectively. If no such 825 date exists, abort these steps and fail to parse the cookie-date. 827 7. Return the parsed-cookie-date as the result of this algorithm. 829 5.1.2. Canonicalized Host Names 831 A canonicalized host name is the string generated by the following 832 algorithm: 834 1. Convert the host name to a sequence of individual domain name 835 labels. 837 2. Convert each label that is not a Non-Reserved LDH (NR-LDH) label, 838 to an A-label (see Section 2.3.2.1 of [RFC5890] for the former 839 and latter), or to a "punycode label" (a label resulting from the 840 "ToASCII" conversion in Section 4 of [RFC3490]), as appropriate 841 (see Section 6.3 of this specification). 843 3. Concatenate the resulting labels, separated by a %x2E (".") 844 character. 846 5.1.3. Domain Matching 848 A string domain-matches a given domain string if at least one of the 849 following conditions hold: 851 * The domain string and the string are identical. (Note that both 852 the domain string and the string will have been canonicalized to 853 lower case at this point.) 855 * All of the following conditions hold: 857 - The domain string is a suffix of the string. 859 - The last character of the string that is not included in the 860 domain string is a %x2E (".") character. 862 - The string is a host name (i.e., not an IP address). 864 5.1.4. Paths and Path-Match 866 The user agent MUST use an algorithm equivalent to the following 867 algorithm to compute the default-path of a cookie: 869 1. Let uri-path be the path portion of the request-uri if such a 870 portion exists (and empty otherwise). For example, if the 871 request-uri contains just a path (and optional query string), 872 then the uri-path is that path (without the %x3F ("?") character 873 or query string), and if the request-uri contains a full 874 absoluteURI, the uri-path is the path component of that URI. 876 2. If the uri-path is empty or if the first character of the uri- 877 path is not a %x2F ("/") character, output %x2F ("/") and skip 878 the remaining steps. 880 3. If the uri-path contains no more than one %x2F ("/") character, 881 output %x2F ("/") and skip the remaining step. 883 4. Output the characters of the uri-path from the first character up 884 to, but not including, the right-most %x2F ("/"). 886 A request-path path-matches a given cookie-path if at least one of 887 the following conditions holds: 889 * The cookie-path and the request-path are identical. 891 Note that this differs from the rules in [RFC3986] for equivalence 892 of the path component, and hence two equivalent paths can have 893 different cookies. 895 * The cookie-path is a prefix of the request-path, and the last 896 character of the cookie-path is %x2F ("/"). 898 * The cookie-path is a prefix of the request-path, and the first 899 character of the request-path that is not included in the cookie- 900 path is a %x2F ("/") character. 902 5.2. "Same-site" and "cross-site" Requests 904 Two origins, A and B, are considered same-site if the following 905 algorithm returns true: 907 1. If A and B are both the same globally unique identifier, return 908 true. 910 2. If A and B are both scheme/host/port triples: 912 1. If A's scheme does not equal B's scheme, return false. 914 2. Let hostA be A's host, and hostB be B's host. 916 3. If hostA equals hostB and hostA's registrable domain is null, 917 return true. 919 4. If hostA's registrable domain equals hostB's registrable 920 domain and is non-null, return true. 922 3. Return false. 924 Note: The port component of the origins is not considered. 926 A request is "same-site" if its target's URI's origin is same-site 927 with the request's client's "site for cookies" (which is an origin), 928 or if the request has no client. The request is otherwise "cross- 929 site". 931 The request's client's "site for cookies" is calculated depending 932 upon its client's type, as described in the following subsections: 934 5.2.1. Document-based requests 936 The URI displayed in a user agent's address bar is the only security 937 context directly exposed to users, and therefore the only signal 938 users can reasonably rely upon to determine whether or not they trust 939 a particular website. The origin of that URI represents the context 940 in which a user most likely believes themselves to be interacting. 941 We'll define this origin, the top-level browsing context's active 942 document's origin, as the "top-level origin". 944 For a document displayed in a top-level browsing context, we can stop 945 here: the document's "site for cookies" is the top-level origin. 947 For documents which are displayed in nested browsing contexts, we 948 need to audit the origins of each of a document's ancestor browsing 949 contexts' active documents in order to account for the "multiple- 950 nested scenarios" described in Section 4 of [RFC7034]. A document's 951 "site for cookies" is the top-level origin if and only if the top- 952 level origin is same-site with the document's origin, and with each 953 of the document's ancestor documents' origins. Otherwise its "site 954 for cookies" is an origin set to a globally unique identifier. 956 Given a Document ("document"), the following algorithm returns its 957 "site for cookies": 959 1. Let "top-document" be the active document in "document"'s 960 browsing context's top-level browsing context. 962 2. Let "top-origin" be the origin of "top-document"'s URI if "top- 963 document"'s sandboxed origin browsing context flag is set, and 964 "top-document"'s origin otherwise. 966 3. Let "documents" be a list containing "document" and each of 967 "document"'s ancestor browsing contexts' active documents. 969 4. For each "item" in "documents": 971 1. Let "origin" be the origin of "item"'s URI if "item"'s 972 sandboxed origin browsing context flag is set, and "item"'s 973 origin otherwise. 975 2. If "origin" is not same-site with "top-origin", return an 976 origin set to a globally unique identifier. 978 5. Return "top-origin". 980 5.2.2. Worker-based requests 982 Worker-driven requests aren't as clear-cut as document-driven 983 requests, as there isn't a clear link between a top-level browsing 984 context and a worker. This is especially true for Service Workers 985 [SERVICE-WORKERS], which may execute code in the background, without 986 any document visible at all. 988 Note: The descriptions below assume that workers must be same-origin 989 with the documents that instantiate them. If this invariant changes, 990 we'll need to take the worker's script's URI into account when 991 determining their status. 993 5.2.2.1. Dedicated and Shared Workers 995 Dedicated workers are simple, as each dedicated worker is bound to 996 one and only one document. Requests generated from a dedicated 997 worker (via "importScripts", "XMLHttpRequest", "fetch()", etc) define 998 their "site for cookies" as that document's "site for cookies". 1000 Shared workers may be bound to multiple documents at once. As it is 1001 quite possible for those documents to have distinct "site for 1002 cookies" values, the worker's "site for cookies" will be an origin 1003 set to a globally unique identifier in cases where the values are not 1004 all same-site with the worker's origin, and the worker's origin in 1005 cases where the values agree. 1007 Given a WorkerGlobalScope ("worker"), the following algorithm returns 1008 its "site for cookies": 1010 1. Let "site" be "worker"'s origin. 1012 2. For each "document" in "worker"'s Documents: 1014 1. Let "document-site" be "document"'s "site for cookies" (as 1015 defined in Section 5.2.1). 1017 2. If "document-site" is not same-site with "site", return an 1018 origin set to a globally unique identifier. 1020 3. Return "site". 1022 5.2.2.2. Service Workers 1024 Service Workers are more complicated, as they act as a completely 1025 separate execution context with only tangential relationship to the 1026 Document which registered them. 1028 Requests which simply pass through a Service Worker will be handled 1029 as described above: the request's client will be the Document or 1030 Worker which initiated the request, and its "site for cookies" will 1031 be those defined in Section 5.2.1 and Section 5.2.2.1 1033 Requests which are initiated by the Service Worker itself (via a 1034 direct call to "fetch()", for instance), on the other hand, will have 1035 a client which is a ServiceWorkerGlobalScope. Its "site for cookies" 1036 will be the Service Worker's URI's origin. 1038 Given a ServiceWorkerGlobalScope ("worker"), the following algorithm 1039 returns its "site for cookies": 1041 1. Return "worker"'s origin. 1043 5.3. The Set-Cookie Header 1045 When a user agent receives a Set-Cookie header field in an HTTP 1046 response, the user agent MAY ignore the Set-Cookie header field in 1047 its entirety. For example, the user agent might wish to block 1048 responses to "third-party" requests from setting cookies (see 1049 Section 7.1). 1051 If the user agent does not ignore the Set-Cookie header field in its 1052 entirety, the user agent MUST parse the field-value of the Set-Cookie 1053 header field as a set-cookie-string (defined below). 1055 NOTE: The algorithm below is more permissive than the grammar in 1056 Section 4.1. For example, the algorithm strips leading and trailing 1057 whitespace from the cookie name and value (but maintains internal 1058 whitespace), whereas the grammar in Section 4.1 forbids whitespace in 1059 these positions. User agents use this algorithm so as to 1060 interoperate with servers that do not follow the recommendations in 1061 Section 4. 1063 A user agent MUST use an algorithm equivalent to the following 1064 algorithm to parse a set-cookie-string: 1066 1. If the set-cookie-string contains a %x3B (";") character: 1068 1. The name-value-pair string consists of the characters up to, 1069 but not including, the first %x3B (";"), and the unparsed- 1070 attributes consist of the remainder of the set-cookie-string 1071 (including the %x3B (";") in question). 1073 Otherwise: 1075 1. The name-value-pair string consists of all the characters 1076 contained in the set-cookie-string, and the unparsed- 1077 attributes is the empty string. 1079 2. If the name-value-pair string lacks a %x3D ("=") character, then 1080 the name string is empty, and the value string is the value of 1081 name-value-pair. 1083 Otherwise, the name string consists of the characters up to, but 1084 not including, the first %x3D ("=") character, and the (possibly 1085 empty) value string consists of the characters after the first 1086 %x3D ("=") character. 1088 3. Remove any leading or trailing WSP characters from the name 1089 string and the value string. 1091 4. The cookie-name is the name string, and the cookie-value is the 1092 value string. 1094 The user agent MUST use an algorithm equivalent to the following 1095 algorithm to parse the unparsed-attributes: 1097 1. If the unparsed-attributes string is empty, skip the rest of 1098 these steps. 1100 2. Discard the first character of the unparsed-attributes (which 1101 will be a %x3B (";") character). 1103 3. If the remaining unparsed-attributes contains a %x3B (";") 1104 character: 1106 1. Consume the characters of the unparsed-attributes up to, but 1107 not including, the first %x3B (";") character. 1109 Otherwise: 1111 1. Consume the remainder of the unparsed-attributes. 1113 Let the cookie-av string be the characters consumed in this step. 1115 4. If the cookie-av string contains a %x3D ("=") character: 1117 1. The (possibly empty) attribute-name string consists of the 1118 characters up to, but not including, the first %x3D ("=") 1119 character, and the (possibly empty) attribute-value string 1120 consists of the characters after the first %x3D ("=") 1121 character. 1123 Otherwise: 1125 1. The attribute-name string consists of the entire cookie-av 1126 string, and the attribute-value string is empty. 1128 5. Remove any leading or trailing WSP characters from the attribute- 1129 name string and the attribute-value string. 1131 6. Process the attribute-name and attribute-value according to the 1132 requirements in the following subsections. (Notice that 1133 attributes with unrecognized attribute-names are ignored.) 1135 7. Return to Step 1 of this algorithm. 1137 When the user agent finishes parsing the set-cookie-string, the user 1138 agent is said to "receive a cookie" from the request-uri with name 1139 cookie-name, value cookie-value, and attributes cookie-attribute- 1140 list. (See Section 5.4 for additional requirements triggered by 1141 receiving a cookie.) 1143 5.3.1. The Expires Attribute 1145 If the attribute-name case-insensitively matches the string 1146 "Expires", the user agent MUST process the cookie-av as follows. 1148 1. Let the expiry-time be the result of parsing the attribute-value 1149 as cookie-date (see Section 5.1.1). 1151 2. If the attribute-value failed to parse as a cookie date, ignore 1152 the cookie-av. 1154 3. If the expiry-time is later than the last date the user agent can 1155 represent, the user agent MAY replace the expiry-time with the 1156 last representable date. 1158 4. If the expiry-time is earlier than the earliest date the user 1159 agent can represent, the user agent MAY replace the expiry-time 1160 with the earliest representable date. 1162 5. Append an attribute to the cookie-attribute-list with an 1163 attribute-name of Expires and an attribute-value of expiry-time. 1165 5.3.2. The Max-Age Attribute 1167 If the attribute-name case-insensitively matches the string "Max- 1168 Age", the user agent MUST process the cookie-av as follows. 1170 1. If the first character of the attribute-value is not a DIGIT or a 1171 "-" character, ignore the cookie-av. 1173 2. If the remainder of attribute-value contains a non-DIGIT 1174 character, ignore the cookie-av. 1176 3. Let delta-seconds be the attribute-value converted to an integer. 1178 4. If delta-seconds is less than or equal to zero (0), let expiry- 1179 time be the earliest representable date and time. Otherwise, let 1180 the expiry-time be the current date and time plus delta-seconds 1181 seconds. 1183 5. Append an attribute to the cookie-attribute-list with an 1184 attribute-name of Max-Age and an attribute-value of expiry-time. 1186 5.3.3. The Domain Attribute 1188 If the attribute-name case-insensitively matches the string "Domain", 1189 the user agent MUST process the cookie-av as follows. 1191 1. If the attribute-value is empty, the behavior is undefined. 1192 However, the user agent SHOULD ignore the cookie-av entirely. 1194 2. If the first character of the attribute-value string is %x2E 1195 ("."): 1197 1. Let cookie-domain be the attribute-value without the leading 1198 %x2E (".") character. 1200 Otherwise: 1202 1. Let cookie-domain be the entire attribute-value. 1204 3. Convert the cookie-domain to lower case. 1206 4. Append an attribute to the cookie-attribute-list with an 1207 attribute-name of Domain and an attribute-value of cookie-domain. 1209 5.3.4. The Path Attribute 1211 If the attribute-name case-insensitively matches the string "Path", 1212 the user agent MUST process the cookie-av as follows. 1214 1. If the attribute-value is empty or if the first character of the 1215 attribute-value is not %x2F ("/"): 1217 1. Let cookie-path be the default-path. 1219 Otherwise: 1221 1. Let cookie-path be the attribute-value. 1223 2. Append an attribute to the cookie-attribute-list with an 1224 attribute-name of Path and an attribute-value of cookie-path. 1226 5.3.5. The Secure Attribute 1228 If the attribute-name case-insensitively matches the string "Secure", 1229 the user agent MUST append an attribute to the cookie-attribute-list 1230 with an attribute-name of Secure and an empty attribute-value. 1232 5.3.6. The HttpOnly Attribute 1234 If the attribute-name case-insensitively matches the string 1235 "HttpOnly", the user agent MUST append an attribute to the cookie- 1236 attribute-list with an attribute-name of HttpOnly and an empty 1237 attribute-value. 1239 5.3.7. The SameSite Attribute 1241 If the attribute-name case-insensitively matches the string 1242 "SameSite", the user agent MUST process the cookie-av as follows: 1244 1. Let "enforcement" be "Default". 1246 2. If cookie-av's attribute-value is a case-insensitive match for 1247 "None", set "enforcement" to "None". 1249 3. If cookie-av's attribute-value is a case-insensitive match for 1250 "Strict", set "enforcement" to "Strict". 1252 4. If cookie-av's attribute-value is a case-insensitive match for 1253 "Lax", set "enforcement" to "Lax". 1255 5. Append an attribute to the cookie-attribute-list with an 1256 attribute-name of "SameSite" and an attribute-value of 1257 "enforcement". 1259 Note: This algorithm maps the "None" value, as well as any unknown 1260 value, to the "None" behavior, which is helpful for backwards 1261 compatibility when introducing new variants. 1263 5.3.7.1. "Strict" and "Lax" enforcement 1265 Same-site cookies in "Strict" enforcement mode will not be sent along 1266 with top-level navigations which are triggered from a cross-site 1267 document context. As discussed in Section 8.8.2, this might or might 1268 not be compatible with existing session management systems. In the 1269 interests of providing a drop-in mechanism that mitigates the risk of 1270 CSRF attacks, developers may set the "SameSite" attribute in a "Lax" 1271 enforcement mode that carves out an exception which sends same-site 1272 cookies along with cross-site requests if and only if they are top- 1273 level navigations which use a "safe" (in the [RFC7231] sense) HTTP 1274 method. (Note that a request's method may be changed from POST to 1275 GET for some redirects (see sections 6.4.2 and 6.4.3 of [RFC7231]); 1276 in these cases, a request's "safe"ness is determined based on the 1277 method of the current redirect hop.) 1279 Lax enforcement provides reasonable defense in depth against CSRF 1280 attacks that rely on unsafe HTTP methods (like "POST"), but does not 1281 offer a robust defense against CSRF as a general category of attack: 1283 1. Attackers can still pop up new windows or trigger top-level 1284 navigations in order to create a "same-site" request (as 1285 described in Section 5.2.1), which is only a speedbump along the 1286 road to exploitation. 1288 2. Features like "" [prerendering] can be 1289 exploited to create "same-site" requests without the risk of user 1290 detection. 1292 When possible, developers should use a session management mechanism 1293 such as that described in Section 8.8.2 to mitigate the risk of CSRF 1294 more completely. 1296 5.4. Storage Model 1298 The user agent stores the following fields about each cookie: name, 1299 value, expiry-time, domain, path, creation-time, last-access-time, 1300 persistent-flag, host-only-flag, secure-only-flag, http-only-flag, 1301 and same-site-flag. 1303 When the user agent "receives a cookie" from a request-uri with name 1304 cookie-name, value cookie-value, and attributes cookie-attribute- 1305 list, the user agent MUST process the cookie as follows: 1307 1. A user agent MAY ignore a received cookie in its entirety. For 1308 example, the user agent might wish to block receiving cookies 1309 from "third-party" responses or the user agent might not wish to 1310 store cookies that exceed some size. 1312 2. If cookie-name is empty and cookie-value is empty, abort these 1313 steps and ignore the cookie entirely. 1315 3. Create a new cookie with name cookie-name, value cookie-value. 1316 Set the creation-time and the last-access-time to the current 1317 date and time. 1319 4. If the cookie-attribute-list contains an attribute with an 1320 attribute-name of "Max-Age": 1322 1. Set the cookie's persistent-flag to true. 1324 2. Set the cookie's expiry-time to attribute-value of the last 1325 attribute in the cookie-attribute-list with an attribute- 1326 name of "Max-Age". 1328 Otherwise, if the cookie-attribute-list contains an attribute 1329 with an attribute-name of "Expires" (and does not contain an 1330 attribute with an attribute-name of "Max-Age"): 1332 1. Set the cookie's persistent-flag to true. 1334 2. Set the cookie's expiry-time to attribute-value of the last 1335 attribute in the cookie-attribute-list with an attribute- 1336 name of "Expires". 1338 Otherwise: 1340 1. Set the cookie's persistent-flag to false. 1342 2. Set the cookie's expiry-time to the latest representable 1343 date. 1345 5. If the cookie-attribute-list contains an attribute with an 1346 attribute-name of "Domain": 1348 1. Let the domain-attribute be the attribute-value of the last 1349 attribute in the cookie-attribute-list with an attribute- 1350 name of "Domain". 1352 Otherwise: 1354 1. Let the domain-attribute be the empty string. 1356 6. If the user agent is configured to reject "public suffixes" and 1357 the domain-attribute is a public suffix: 1359 1. If the domain-attribute is identical to the canonicalized 1360 request-host: 1362 1. Let the domain-attribute be the empty string. 1364 Otherwise: 1366 1. Ignore the cookie entirely and abort these steps. 1368 NOTE: This step prevents "attacker.example" from disrupting the 1369 integrity of "site.example" by setting a cookie with a Domain 1370 attribute of "example". 1372 7. If the domain-attribute is non-empty: 1374 1. If the canonicalized request-host does not domain-match the 1375 domain-attribute: 1377 1. Ignore the cookie entirely and abort these steps. 1379 Otherwise: 1381 1. Set the cookie's host-only-flag to false. 1383 2. Set the cookie's domain to the domain-attribute. 1385 Otherwise: 1387 1. Set the cookie's host-only-flag to true. 1389 2. Set the cookie's domain to the canonicalized request-host. 1391 8. If the cookie-attribute-list contains an attribute with an 1392 attribute-name of "Path", set the cookie's path to attribute- 1393 value of the last attribute in the cookie-attribute-list with an 1394 attribute-name of "Path". Otherwise, set the cookie's path to 1395 the default-path of the request-uri. 1397 9. If the cookie-attribute-list contains an attribute with an 1398 attribute-name of "Secure", set the cookie's secure-only-flag to 1399 true. Otherwise, set the cookie's secure-only-flag to false. 1401 10. If the scheme component of the request-uri does not denote a 1402 "secure" protocol (as defined by the user agent), and the 1403 cookie's secure-only-flag is true, then abort these steps and 1404 ignore the cookie entirely. 1406 11. If the cookie-attribute-list contains an attribute with an 1407 attribute-name of "HttpOnly", set the cookie's http-only-flag to 1408 true. Otherwise, set the cookie's http-only-flag to false. 1410 12. If the cookie was received from a "non-HTTP" API and the 1411 cookie's http-only-flag is true, abort these steps and ignore 1412 the cookie entirely. 1414 13. If the cookie's secure-only-flag is false, and the scheme 1415 component of request-uri does not denote a "secure" protocol, 1416 then abort these steps and ignore the cookie entirely if the 1417 cookie store contains one or more cookies that meet all of the 1418 following criteria: 1420 1. Their name matches the name of the newly-created cookie. 1422 2. Their secure-only-flag is true. 1424 3. Their domain domain-matches the domain of the newly-created 1425 cookie, or vice-versa. 1427 4. The path of the newly-created cookie path-matches the path 1428 of the existing cookie. 1430 Note: The path comparison is not symmetric, ensuring only that a 1431 newly-created, non-secure cookie does not overlay an existing 1432 secure cookie, providing some mitigation against cookie-fixing 1433 attacks. That is, given an existing secure cookie named 'a' 1434 with a path of '/login', a non-secure cookie named 'a' could be 1435 set for a path of '/' or '/foo', but not for a path of '/login' 1436 or '/login/en'. 1438 14. If the cookie-attribute-list contains an attribute with an 1439 attribute-name of "SameSite", and an attribute-value of 1440 "Strict", "Lax", or "None", set the cookie's same-site-flag to 1441 the attribute-value of the last attribute in the cookie- 1442 attribute-list with an attribute-name of "SameSite". Otherwise, 1443 set the cookie's same-site-flag to "Default". 1445 15. If the cookie's "same-site-flag" is not "None": 1447 1. If the cookie was received from a "non-HTTP" API, and the 1448 API was called from a browsing context's active document 1449 whose "site for cookies" is not same-site with the top-level 1450 origin, then abort these steps and ignore the newly created 1451 cookie entirely. 1453 2. If the cookie was received from a "same-site" request (as 1454 defined in Section 5.2), skip the remaining substeps and 1455 continue processing the cookie. 1457 3. If the cookie was received from a request which is 1458 navigating a top-level browsing context [HTML] (e.g. if the 1459 request's "reserved client" is either "null" or an 1460 environment whose "target browsing context" is a top-level 1461 browing context), skip the remaining substeps and continue 1462 processing the cookie. 1464 Note: Top-level navigations can create a cookie with any 1465 "SameSite" value, even if the new cookie wouldn't have been 1466 sent along with the request had it already existed prior to 1467 the navigation. 1469 4. Abort these steps and ignore the newly created cookie 1470 entirely. 1472 16. If the cookie's "same-site-flag" is "None", abort these steps 1473 and ignore the cookie entirely unless the cookie's secure-only- 1474 flag is true. 1476 17. If the cookie-name begins with a case-sensitive match for the 1477 string "__Secure-", abort these steps and ignore the cookie 1478 entirely unless the cookie's secure-only-flag is true. 1480 18. If the cookie-name begins with a case-sensitive match for the 1481 string "__Host-", abort these steps and ignore the cookie 1482 entirely unless the cookie meets all the following criteria: 1484 1. The cookie's secure-only-flag is true. 1486 2. The cookie's host-only-flag is true. 1488 3. The cookie-attribute-list contains an attribute with an 1489 attribute-name of "Path", and the cookie's path is "/". 1491 19. If the cookie store contains a cookie with the same name, 1492 domain, host-only-flag, and path as the newly-created cookie: 1494 1. Let old-cookie be the existing cookie with the same name, 1495 domain, host-only-flag, and path as the newly-created 1496 cookie. (Notice that this algorithm maintains the invariant 1497 that there is at most one such cookie.) 1499 2. If the newly-created cookie was received from a "non-HTTP" 1500 API and the old-cookie's http-only-flag is true, abort these 1501 steps and ignore the newly created cookie entirely. 1503 3. Update the creation-time of the newly-created cookie to 1504 match the creation-time of the old-cookie. 1506 4. Remove the old-cookie from the cookie store. 1508 20. Insert the newly-created cookie into the cookie store. 1510 A cookie is "expired" if the cookie has an expiry date in the past. 1512 The user agent MUST evict all expired cookies from the cookie store 1513 if, at any time, an expired cookie exists in the cookie store. 1515 At any time, the user agent MAY "remove excess cookies" from the 1516 cookie store if the number of cookies sharing a domain field exceeds 1517 some implementation-defined upper bound (such as 50 cookies). 1519 At any time, the user agent MAY "remove excess cookies" from the 1520 cookie store if the cookie store exceeds some predetermined upper 1521 bound (such as 3000 cookies). 1523 When the user agent removes excess cookies from the cookie store, the 1524 user agent MUST evict cookies in the following priority order: 1526 1. Expired cookies. 1528 2. Cookies whose secure-only-flag is false, and which share a domain 1529 field with more than a predetermined number of other cookies. 1531 3. Cookies that share a domain field with more than a predetermined 1532 number of other cookies. 1534 4. All cookies. 1536 If two cookies have the same removal priority, the user agent MUST 1537 evict the cookie with the earliest last-access-time first. 1539 When "the current session is over" (as defined by the user agent), 1540 the user agent MUST remove from the cookie store all cookies with the 1541 persistent-flag set to false. 1543 5.5. The Cookie Header 1545 The user agent includes stored cookies in the Cookie HTTP request 1546 header. 1548 When the user agent generates an HTTP request, the user agent MUST 1549 NOT attach more than one Cookie header field. 1551 A user agent MAY omit the Cookie header in its entirety. For 1552 example, the user agent might wish to block sending cookies during 1553 "third-party" requests from setting cookies (see Section 7.1). 1555 If the user agent does attach a Cookie header field to an HTTP 1556 request, the user agent MUST send the cookie-string (defined below) 1557 as the value of the header field. 1559 The user agent MUST use an algorithm equivalent to the following 1560 algorithm to compute the cookie-string from a cookie store and a 1561 request-uri: 1563 1. Let cookie-list be the set of cookies from the cookie store that 1564 meets all of the following requirements: 1566 * Either: 1568 - The cookie's host-only-flag is true and the canonicalized 1569 request-host is identical to the cookie's domain. 1571 Or: 1573 - The cookie's host-only-flag is false and the canonicalized 1574 request-host domain-matches the cookie's domain. 1576 * The request-uri's path path-matches the cookie's path. 1578 * If the cookie's secure-only-flag is true, then the request- 1579 uri's scheme must denote a "secure" protocol (as defined by 1580 the user agent). 1582 NOTE: The notion of a "secure" protocol is not defined by this 1583 document. Typically, user agents consider a protocol secure 1584 if the protocol makes use of transport-layer security, such as 1585 SSL or TLS. For example, most user agents consider "https" to 1586 be a scheme that denotes a secure protocol. 1588 * If the cookie's http-only-flag is true, then exclude the 1589 cookie if the cookie-string is being generated for a "non- 1590 HTTP" API (as defined by the user agent). 1592 * If the cookie's same-site-flag is not "None", and the HTTP 1593 request is cross-site (as defined in Section 5.2) then exclude 1594 the cookie unless all of the following statements hold: 1596 1. The same-site-flag is "Lax" or "Default". 1598 2. The HTTP request's method is "safe". 1600 3. The HTTP request's target browsing context is a top-level 1601 browsing context. 1603 2. The user agent SHOULD sort the cookie-list in the following 1604 order: 1606 * Cookies with longer paths are listed before cookies with 1607 shorter paths. 1609 * Among cookies that have equal-length path fields, cookies with 1610 earlier creation-times are listed before cookies with later 1611 creation-times. 1613 NOTE: Not all user agents sort the cookie-list in this order, but 1614 this order reflects common practice when this document was 1615 written, and, historically, there have been servers that 1616 (erroneously) depended on this order. 1618 3. Update the last-access-time of each cookie in the cookie-list to 1619 the current date and time. 1621 4. Serialize the cookie-list into a cookie-string by processing each 1622 cookie in the cookie-list in order: 1624 1. If the cookies' name is not empty, output the cookie's name 1625 followed by the %x3D ("=") character. 1627 2. If the cookies' value is not empty, output the cookie's 1628 value. 1630 3. If there is an unprocessed cookie in the cookie-list, output 1631 the characters %x3B and %x20 ("; "). 1633 NOTE: Despite its name, the cookie-string is actually a sequence of 1634 octets, not a sequence of characters. To convert the cookie-string 1635 (or components thereof) into a sequence of characters (e.g., for 1636 presentation to the user), the user agent might wish to try using the 1637 UTF-8 character encoding [RFC3629] to decode the octet sequence. 1638 This decoding might fail, however, because not every sequence of 1639 octets is valid UTF-8. 1641 6. Implementation Considerations 1643 6.1. Limits 1645 Practical user agent implementations have limits on the number and 1646 size of cookies that they can store. General-use user agents SHOULD 1647 provide each of the following minimum capabilities: 1649 * At least 4096 bytes per cookie (as measured by the sum of the 1650 length of the cookie's name, value, and attributes). 1652 * At least 50 cookies per domain. 1654 * At least 3000 cookies total. 1656 Servers SHOULD use as few and as small cookies as possible to avoid 1657 reaching these implementation limits and to minimize network 1658 bandwidth due to the Cookie header being included in every request. 1660 Servers SHOULD gracefully degrade if the user agent fails to return 1661 one or more cookies in the Cookie header because the user agent might 1662 evict any cookie at any time on orders from the user. 1664 6.2. Application Programming Interfaces 1666 One reason the Cookie and Set-Cookie headers use such esoteric syntax 1667 is that many platforms (both in servers and user agents) provide a 1668 string-based application programming interface (API) to cookies, 1669 requiring application-layer programmers to generate and parse the 1670 syntax used by the Cookie and Set-Cookie headers, which many 1671 programmers have done incorrectly, resulting in interoperability 1672 problems. 1674 Instead of providing string-based APIs to cookies, platforms would be 1675 well-served by providing more semantic APIs. It is beyond the scope 1676 of this document to recommend specific API designs, but there are 1677 clear benefits to accepting an abstract "Date" object instead of a 1678 serialized date string. 1680 6.3. IDNA Dependency and Migration 1682 IDNA2008 [RFC5890] supersedes IDNA2003 [RFC3490]. However, there are 1683 differences between the two specifications, and thus there can be 1684 differences in processing (e.g., converting) domain name labels that 1685 have been registered under one from those registered under the other. 1686 There will be a transition period of some time during which 1687 IDNA2003-based domain name labels will exist in the wild. User 1688 agents SHOULD implement IDNA2008 [RFC5890] and MAY implement [UTS46] 1689 or [RFC5895] in order to facilitate their IDNA transition. If a user 1690 agent does not implement IDNA2008, the user agent MUST implement 1691 IDNA2003 [RFC3490]. 1693 7. Privacy Considerations 1695 Cookies are often criticized for letting servers track users. For 1696 example, a number of "web analytics" companies use cookies to 1697 recognize when a user returns to a web site or visits another web 1698 site. Although cookies are not the only mechanism servers can use to 1699 track users across HTTP requests, cookies facilitate tracking because 1700 they are persistent across user agent sessions and can be shared 1701 between hosts. 1703 7.1. Third-Party Cookies 1705 Particularly worrisome are so-called "third-party" cookies. In 1706 rendering an HTML document, a user agent often requests resources 1707 from other servers (such as advertising networks). These third-party 1708 servers can use cookies to track the user even if the user never 1709 visits the server directly. For example, if a user visits a site 1710 that contains content from a third party and then later visits 1711 another site that contains content from the same third party, the 1712 third party can track the user between the two sites. 1714 Given this risk to user privacy, some user agents restrict how third- 1715 party cookies behave, and those restrictions vary widly. For 1716 instance, user agents might block third-party cookies entirely by 1717 refusing to send Cookie headers or process Set-Cookie headers during 1718 third-party requests. They might take a less draconian approach by 1719 partitioning cookies based on the first-party context, sending one 1720 set of cookies to a given third party in one first-party context, and 1721 another to the same third party in another. 1723 This document grants user agents wide latitude to experiment with 1724 third-party cookie policies that balance the privacy and 1725 compatibility needs of their users. However, this document does not 1726 endorse any particular third-party cookie policy. 1728 Third-party cookie blocking policies are often ineffective at 1729 achieving their privacy goals if servers attempt to work around their 1730 restrictions to track users. In particular, two collaborating 1731 servers can often track users without using cookies at all by 1732 injecting identifying information into dynamic URLs. 1734 7.2. User Controls 1736 User agents SHOULD provide users with a mechanism for managing the 1737 cookies stored in the cookie store. For example, a user agent might 1738 let users delete all cookies received during a specified time period 1739 or all the cookies related to a particular domain. In addition, many 1740 user agents include a user interface element that lets users examine 1741 the cookies stored in their cookie store. 1743 User agents SHOULD provide users with a mechanism for disabling 1744 cookies. When cookies are disabled, the user agent MUST NOT include 1745 a Cookie header in outbound HTTP requests and the user agent MUST NOT 1746 process Set-Cookie headers in inbound HTTP responses. 1748 Some user agents provide users the option of preventing persistent 1749 storage of cookies across sessions. When configured thusly, user 1750 agents MUST treat all received cookies as if the persistent-flag were 1751 set to false. Some popular user agents expose this functionality via 1752 "private browsing" mode [Aggarwal2010]. 1754 Some user agents provide users with the ability to approve individual 1755 writes to the cookie store. In many common usage scenarios, these 1756 controls generate a large number of prompts. However, some privacy- 1757 conscious users find these controls useful nonetheless. 1759 7.3. Expiration Dates 1761 Although servers can set the expiration date for cookies to the 1762 distant future, most user agents do not actually retain cookies for 1763 multiple decades. Rather than choosing gratuitously long expiration 1764 periods, servers SHOULD promote user privacy by selecting reasonable 1765 cookie expiration periods based on the purpose of the cookie. For 1766 example, a typical session identifier might reasonably be set to 1767 expire in two weeks. 1769 8. Security Considerations 1771 8.1. Overview 1773 Cookies have a number of security pitfalls. This section overviews a 1774 few of the more salient issues. 1776 In particular, cookies encourage developers to rely on ambient 1777 authority for authentication, often becoming vulnerable to attacks 1778 such as cross-site request forgery [CSRF]. Also, when storing 1779 session identifiers in cookies, developers often create session 1780 fixation vulnerabilities. 1782 Transport-layer encryption, such as that employed in HTTPS, is 1783 insufficient to prevent a network attacker from obtaining or altering 1784 a victim's cookies because the cookie protocol itself has various 1785 vulnerabilities (see "Weak Confidentiality" and "Weak Integrity", 1786 below). In addition, by default, cookies do not provide 1787 confidentiality or integrity from network attackers, even when used 1788 in conjunction with HTTPS. 1790 8.2. Ambient Authority 1792 A server that uses cookies to authenticate users can suffer security 1793 vulnerabilities because some user agents let remote parties issue 1794 HTTP requests from the user agent (e.g., via HTTP redirects or HTML 1795 forms). When issuing those requests, user agents attach cookies even 1796 if the remote party does not know the contents of the cookies, 1797 potentially letting the remote party exercise authority at an unwary 1798 server. 1800 Although this security concern goes by a number of names (e.g., 1801 cross-site request forgery, confused deputy), the issue stems from 1802 cookies being a form of ambient authority. Cookies encourage server 1803 operators to separate designation (in the form of URLs) from 1804 authorization (in the form of cookies). Consequently, the user agent 1805 might supply the authorization for a resource designated by the 1806 attacker, possibly causing the server or its clients to undertake 1807 actions designated by the attacker as though they were authorized by 1808 the user. 1810 Instead of using cookies for authorization, server operators might 1811 wish to consider entangling designation and authorization by treating 1812 URLs as capabilities. Instead of storing secrets in cookies, this 1813 approach stores secrets in URLs, requiring the remote entity to 1814 supply the secret itself. Although this approach is not a panacea, 1815 judicious application of these principles can lead to more robust 1816 security. 1818 8.3. Clear Text 1820 Unless sent over a secure channel (such as TLS), the information in 1821 the Cookie and Set-Cookie headers is transmitted in the clear. 1823 1. All sensitive information conveyed in these headers is exposed to 1824 an eavesdropper. 1826 2. A malicious intermediary could alter the headers as they travel 1827 in either direction, with unpredictable results. 1829 3. A malicious client could alter the Cookie header before 1830 transmission, with unpredictable results. 1832 Servers SHOULD encrypt and sign the contents of cookies (using 1833 whatever format the server desires) when transmitting them to the 1834 user agent (even when sending the cookies over a secure channel). 1835 However, encrypting and signing cookie contents does not prevent an 1836 attacker from transplanting a cookie from one user agent to another 1837 or from replaying the cookie at a later time. 1839 In addition to encrypting and signing the contents of every cookie, 1840 servers that require a higher level of security SHOULD use the Cookie 1841 and Set-Cookie headers only over a secure channel. When using 1842 cookies over a secure channel, servers SHOULD set the Secure 1843 attribute (see Section 4.1.2.5) for every cookie. If a server does 1844 not set the Secure attribute, the protection provided by the secure 1845 channel will be largely moot. 1847 For example, consider a webmail server that stores a session 1848 identifier in a cookie and is typically accessed over HTTPS. If the 1849 server does not set the Secure attribute on its cookies, an active 1850 network attacker can intercept any outbound HTTP request from the 1851 user agent and redirect that request to the webmail server over HTTP. 1852 Even if the webmail server is not listening for HTTP connections, the 1853 user agent will still include cookies in the request. The active 1854 network attacker can intercept these cookies, replay them against the 1855 server, and learn the contents of the user's email. If, instead, the 1856 server had set the Secure attribute on its cookies, the user agent 1857 would not have included the cookies in the clear-text request. 1859 8.4. Session Identifiers 1861 Instead of storing session information directly in a cookie (where it 1862 might be exposed to or replayed by an attacker), servers commonly 1863 store a nonce (or "session identifier") in a cookie. When the server 1864 receives an HTTP request with a nonce, the server can look up state 1865 information associated with the cookie using the nonce as a key. 1867 Using session identifier cookies limits the damage an attacker can 1868 cause if the attacker learns the contents of a cookie because the 1869 nonce is useful only for interacting with the server (unlike non- 1870 nonce cookie content, which might itself be sensitive). Furthermore, 1871 using a single nonce prevents an attacker from "splicing" together 1872 cookie content from two interactions with the server, which could 1873 cause the server to behave unexpectedly. 1875 Using session identifiers is not without risk. For example, the 1876 server SHOULD take care to avoid "session fixation" vulnerabilities. 1877 A session fixation attack proceeds in three steps. First, the 1878 attacker transplants a session identifier from his or her user agent 1879 to the victim's user agent. Second, the victim uses that session 1880 identifier to interact with the server, possibly imbuing the session 1881 identifier with the user's credentials or confidential information. 1882 Third, the attacker uses the session identifier to interact with 1883 server directly, possibly obtaining the user's authority or 1884 confidential information. 1886 8.5. Weak Confidentiality 1888 Cookies do not provide isolation by port. If a cookie is readable by 1889 a service running on one port, the cookie is also readable by a 1890 service running on another port of the same server. If a cookie is 1891 writable by a service on one port, the cookie is also writable by a 1892 service running on another port of the same server. For this reason, 1893 servers SHOULD NOT both run mutually distrusting services on 1894 different ports of the same host and use cookies to store security- 1895 sensitive information. 1897 Cookies do not provide isolation by scheme. Although most commonly 1898 used with the http and https schemes, the cookies for a given host 1899 might also be available to other schemes, such as ftp and gopher. 1900 Although this lack of isolation by scheme is most apparent in non- 1901 HTTP APIs that permit access to cookies (e.g., HTML's document.cookie 1902 API), the lack of isolation by scheme is actually present in 1903 requirements for processing cookies themselves (e.g., consider 1904 retrieving a URI with the gopher scheme via HTTP). 1906 Cookies do not always provide isolation by path. Although the 1907 network-level protocol does not send cookies stored for one path to 1908 another, some user agents expose cookies via non-HTTP APIs, such as 1909 HTML's document.cookie API. Because some of these user agents (e.g., 1910 web browsers) do not isolate resources received from different paths, 1911 a resource retrieved from one path might be able to access cookies 1912 stored for another path. 1914 8.6. Weak Integrity 1916 Cookies do not provide integrity guarantees for sibling domains (and 1917 their subdomains). For example, consider foo.site.example and 1918 bar.site.example. The foo.site.example server can set a cookie with 1919 a Domain attribute of "site.example" (possibly overwriting an 1920 existing "site.example" cookie set by bar.site.example), and the user 1921 agent will include that cookie in HTTP requests to bar.site.example. 1922 In the worst case, bar.site.example will be unable to distinguish 1923 this cookie from a cookie it set itself. The foo.site.example server 1924 might be able to leverage this ability to mount an attack against 1925 bar.site.example. 1927 Even though the Set-Cookie header supports the Path attribute, the 1928 Path attribute does not provide any integrity protection because the 1929 user agent will accept an arbitrary Path attribute in a Set-Cookie 1930 header. For example, an HTTP response to a request for 1931 http://site.example/foo/bar can set a cookie with a Path attribute of 1932 "/qux". Consequently, servers SHOULD NOT both run mutually 1933 distrusting services on different paths of the same host and use 1934 cookies to store security-sensitive information. 1936 An active network attacker can also inject cookies into the Cookie 1937 header sent to https://site.example/ by impersonating a response from 1938 http://site.example/ and injecting a Set-Cookie header. The HTTPS 1939 server at site.example will be unable to distinguish these cookies 1940 from cookies that it set itself in an HTTPS response. An active 1941 network attacker might be able to leverage this ability to mount an 1942 attack against site.example even if site.example uses HTTPS 1943 exclusively. 1945 Servers can partially mitigate these attacks by encrypting and 1946 signing the contents of their cookies. However, using cryptography 1947 does not mitigate the issue completely because an attacker can replay 1948 a cookie he or she received from the authentic site.example server in 1949 the user's session, with unpredictable results. 1951 Finally, an attacker might be able to force the user agent to delete 1952 cookies by storing a large number of cookies. Once the user agent 1953 reaches its storage limit, the user agent will be forced to evict 1954 some cookies. Servers SHOULD NOT rely upon user agents retaining 1955 cookies. 1957 8.7. Reliance on DNS 1959 Cookies rely upon the Domain Name System (DNS) for security. If the 1960 DNS is partially or fully compromised, the cookie protocol might fail 1961 to provide the security properties required by applications. 1963 8.8. SameSite Cookies 1964 8.8.1. Defense in depth 1966 "SameSite" cookies offer a robust defense against CSRF attack when 1967 deployed in strict mode, and when supported by the client. It is, 1968 however, prudent to ensure that this designation is not the extent of 1969 a site's defense against CSRF, as same-site navigations and 1970 submissions can certainly be executed in conjunction with other 1971 attack vectors such as cross-site scripting. 1973 Developers are strongly encouraged to deploy the usual server-side 1974 defenses (CSRF tokens, ensuring that "safe" HTTP methods are 1975 idempotent, etc) to mitigate the risk more fully. 1977 Additionally, client-side techniques such as those described in 1978 [app-isolation] may also prove effective against CSRF, and are 1979 certainly worth exploring in combination with "SameSite" cookies. 1981 8.8.2. Top-level Navigations 1983 Setting the "SameSite" attribute in "strict" mode provides robust 1984 defense in depth against CSRF attacks, but has the potential to 1985 confuse users unless sites' developers carefully ensure that their 1986 cookie-based session management systems deal reasonably well with 1987 top-level navigations. 1989 Consider the scenario in which a user reads their email at MegaCorp 1990 Inc's webmail provider "https://site.example/". They might expect 1991 that clicking on an emailed link to "https://projects.example/secret/ 1992 project" would show them the secret project that they're authorized 1993 to see, but if "projects.example" has marked their session cookies as 1994 "SameSite", then this cross-site navigation won't send them along 1995 with the request. "projects.example" will render a 404 error to avoid 1996 leaking secret information, and the user will be quite confused. 1998 Developers can avoid this confusion by adopting a session management 1999 system that relies on not one, but two cookies: one conceptually 2000 granting "read" access, another granting "write" access. The latter 2001 could be marked as "SameSite", and its absence would prompt a 2002 reauthentication step before executing any non-idempotent action. 2003 The former could drop the "SameSite" attribute entirely, or choose 2004 the "Lax" version of enforcement, in order to allow users access to 2005 data via top-level navigation. 2007 8.8.3. Mashups and Widgets 2009 The "SameSite" attribute is inappropriate for some important use- 2010 cases. In particular, note that content intended for embedding in a 2011 cross-site contexts (social networking widgets or commenting 2012 services, for instance) will not have access to same-site cookies. 2013 Cookies may be required for requests triggered in these cross-site 2014 contexts in order to provide seamless functionality that relies on a 2015 user's state. 2017 Likewise, some forms of Single-Sign-On might require cookie-based 2018 authentication in a cross-site context; these mechanisms will not 2019 function as intended with same-site cookies. 2021 8.8.4. Server-controlled 2023 SameSite cookies in and of themselves don't do anything to address 2024 the general privacy concerns outlined in Section 7.1 of [RFC6265]. 2025 The "SameSite" attribute is set by the server, and serves to mitigate 2026 the risk of certain kinds of attacks that the server is worried 2027 about. The user is not involved in this decision. Moreover, a 2028 number of side-channels exist which could allow a server to link 2029 distinct requests even in the absence of cookies (for example, 2030 connection and/or socket pooling between same-site and cross-site 2031 requests). 2033 9. IANA Considerations 2035 9.1. Cookie 2037 The permanent message header field registry (see [RFC3864]) needs to 2038 be updated with the following registration: 2040 Header field name: Cookie 2042 Applicable protocol: http 2044 Status: standard 2046 Author/Change controller: IETF 2048 Specification document: this specification (Section 5.5) 2050 9.2. Set-Cookie 2052 The permanent message header field registry (see [RFC3864]) needs to 2053 be updated with the following registration: 2055 Header field name: Set-Cookie 2057 Applicable protocol: http 2059 Status: standard 2061 Author/Change controller: IETF 2063 Specification document: this specification (Section 5.3) 2065 9.3. Cookie Attribute Registry 2067 The "Cookie Attribute Registry" defines the name space of attribute 2068 used to control cookies' behavior. The registry is maintained at 2069 https://www.iana.org/assignments/cookie-attribute-names 2070 (https://www.iana.org/assignments/cookie-attribute-names). 2072 9.3.1. Procedure 2074 Each registered attribute name is associated with a description, and 2075 a reference detailing how the attribute is to be processed and 2076 stored. 2078 New registrations happen on a "RFC Required" basis (see Section 4.7 2079 of [RFC8126]). The attribute to be registered MUST match the 2080 "extension-av" syntax defined in Section 4.1.1. Note that attribute 2081 names are generally defined in CamelCase, but technically accepted 2082 case-insensitively. 2084 9.3.2. Registration 2086 The "Cookie Attribute Registry" will be updated with the 2087 registrations below: 2089 +==========+==================================+ 2090 | Name | Reference | 2091 +==========+==================================+ 2092 | Domain | Section 4.1.2.3 of this document | 2093 +----------+----------------------------------+ 2094 | Expires | Section 4.1.2.1 of this document | 2095 +----------+----------------------------------+ 2096 | HttpOnly | Section 4.1.2.6 of this document | 2097 +----------+----------------------------------+ 2098 | Max-Age | Section 4.1.2.2 of this document | 2099 +----------+----------------------------------+ 2100 | Path | Section 4.1.2.4 of this document | 2101 +----------+----------------------------------+ 2102 | SameSite | Section 4.1.2.7 of this document | 2103 +----------+----------------------------------+ 2104 | Secure | Section 4.1.2.5 of this document | 2105 +----------+----------------------------------+ 2107 Table 1 2109 10. References 2111 10.1. Normative References 2113 [FETCH] van Kesteren, A., "Fetch", n.d., 2114 . 2116 [HTML] Hickson, I., Pieters, S., van Kesteren, A., Jägenstedt, 2117 P., and D. Denicola, "HTML", n.d., 2118 . 2120 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", 2121 STD 13, RFC 1034, DOI 10.17487/RFC1034, November 1987, 2122 . 2124 [RFC1123] Braden, R., Ed., "Requirements for Internet Hosts - 2125 Application and Support", STD 3, RFC 1123, 2126 DOI 10.17487/RFC1123, October 1989, 2127 . 2129 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2130 Requirement Levels", BCP 14, RFC 2119, 2131 DOI 10.17487/RFC2119, March 1997, 2132 . 2134 [RFC3490] Costello, A., "Internationalizing Domain Names in 2135 Applications (IDNA)", RFC 3490, March 2003, 2136 . See Section 6.3 2137 for an explanation why the normative reference to an 2138 obsoleted specification is needed. 2140 [RFC4790] Newman, C., Duerst, M., and A. Gulbrandsen, "Internet 2141 Application Protocol Collation Registry", RFC 4790, 2142 DOI 10.17487/RFC4790, March 2007, 2143 . 2145 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2146 Specifications: ABNF", STD 68, RFC 5234, 2147 DOI 10.17487/RFC5234, January 2008, 2148 . 2150 [RFC5890] Klensin, J., "Internationalized Domain Names for 2151 Applications (IDNA): Definitions and Document Framework", 2152 RFC 5890, DOI 10.17487/RFC5890, August 2010, 2153 . 2155 [RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, 2156 DOI 10.17487/RFC6454, December 2011, 2157 . 2159 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 2160 Protocol (HTTP/1.1): Message Syntax and Routing", 2161 RFC 7230, DOI 10.17487/RFC7230, June 2014, 2162 . 2164 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 2165 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 2166 DOI 10.17487/RFC7231, June 2014, 2167 . 2169 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2170 Writing an IANA Considerations Section in RFCs", BCP 26, 2171 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2172 . 2174 [SERVICE-WORKERS] 2175 Russell, A., Song, J., and J. Archibald, "Service 2176 Workers", n.d., . 2178 [USASCII] American National Standards Institute, "Coded Character 2179 Set -- 7-bit American Standard Code for Information 2180 Interchange", ANSI X3.4, 1986. 2182 10.2. Informative References 2184 [Aggarwal2010] 2185 Aggarwal, G., Burzstein, E., Jackson, C., and D. Boneh, 2186 "An Analysis of Private Browsing Modes in Modern 2187 Browsers", 2010, 2188 . 2191 [app-isolation] 2192 Chen, E., Bau, J., Reis, C., Barth, A., and C. Jackson, 2193 "App Isolation - Get the Security of Multiple Browsers 2194 with Just One", 2011, 2195 . 2198 [CSRF] Barth, A., Jackson, C., and J. Mitchell, "Robust Defenses 2199 for Cross-Site Request Forgery", 2200 DOI 10.1145/1455770.1455782, ISBN 978-1-59593-810-7, 2201 ACM CCS '08: Proceedings of the 15th ACM conference on 2202 Computer and communications security (pages 75-88), 2203 October 2008, 2204 . 2206 [I-D.ietf-httpbis-cookie-alone] 2207 West, M., "Deprecate modification of 'secure' cookies from 2208 non-secure origins", Work in Progress, Internet-Draft, 2209 draft-ietf-httpbis-cookie-alone-01, 5 September 2016, 2210 . 2213 [I-D.ietf-httpbis-cookie-prefixes] 2214 West, M., "Cookie Prefixes", Work in Progress, Internet- 2215 Draft, draft-ietf-httpbis-cookie-prefixes-00, 23 February 2216 2016, . 2219 [I-D.ietf-httpbis-cookie-same-site] 2220 West, M. and M. Goodwin, "Same-Site Cookies", Work in 2221 Progress, Internet-Draft, draft-ietf-httpbis-cookie-same- 2222 site-00, 20 June 2016, . 2225 [prerendering] 2226 Bentzel, C., "Chrome Prerendering", n.d., 2227 . 2230 [PSL] "Public Suffix List", n.d., 2231 . 2233 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 2234 DOI 10.17487/RFC2818, May 2000, 2235 . 2237 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2238 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2239 2003, . 2241 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 2242 Procedures for Message Header Fields", BCP 90, RFC 3864, 2243 DOI 10.17487/RFC3864, September 2004, 2244 . 2246 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 2247 Resource Identifier (URI): Generic Syntax", STD 66, 2248 RFC 3986, DOI 10.17487/RFC3986, January 2005, 2249 . 2251 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 2252 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 2253 . 2255 [RFC5895] Resnick, P. and P. Hoffman, "Mapping Characters for 2256 Internationalized Domain Names in Applications (IDNA) 2257 2008", RFC 5895, DOI 10.17487/RFC5895, September 2010, 2258 . 2260 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 2261 DOI 10.17487/RFC6265, April 2011, 2262 . 2264 [RFC7034] Ross, D. and T. Gondrom, "HTTP Header Field X-Frame- 2265 Options", RFC 7034, DOI 10.17487/RFC7034, October 2013, 2266 . 2268 [UTS46] Davis, M. and M. Suignard, "Unicode IDNA Compatibility 2269 Processing", UNICODE Unicode Technical Standards # 46, 2270 June 2016, . 2272 Appendix A. Changes 2274 A.1. draft-ietf-httpbis-rfc6265bis-00 2276 * Port [RFC6265] to Markdown. No (intentional) normative changes. 2278 A.2. draft-ietf-httpbis-rfc6265bis-01 2280 * Fixes to formatting caused by mistakes in the initial port to 2281 Markdown: 2283 - https://github.com/httpwg/http-extensions/issues/243 2284 (https://github.com/httpwg/http-extensions/issues/243) 2286 - https://github.com/httpwg/http-extensions/issues/246 2287 (https://github.com/httpwg/http-extensions/issues/246) 2289 * Addresses errata 3444 by updating the "path-value" and "extension- 2290 av" grammar, errata 4148 by updating the "day-of-month", "year", 2291 and "time" grammar, and errata 3663 by adding the requested note. 2292 https://www.rfc-editor.org/errata_search.php?rfc=6265 2293 (https://www.rfc-editor.org/errata_search.php?rfc=6265) 2295 * Dropped "Cookie2" and "Set-Cookie2" from the IANA Considerations 2296 section: https://github.com/httpwg/http-extensions/issues/247 2297 (https://github.com/httpwg/http-extensions/issues/247) 2299 * Merged the recommendations from [I-D.ietf-httpbis-cookie-alone], 2300 removing the ability for a non-secure origin to set cookies with a 2301 'secure' flag, and to overwrite cookies whose 'secure' flag is 2302 true. 2304 * Merged the recommendations from 2305 [I-D.ietf-httpbis-cookie-prefixes], adding "__Secure-" and 2306 "__Host-" cookie name prefix processing instructions. 2308 A.3. draft-ietf-httpbis-rfc6265bis-02 2310 * Merged the recommendations from 2311 [I-D.ietf-httpbis-cookie-same-site], adding support for the 2312 "SameSite" attribute. 2314 * Closed a number of editorial bugs: 2316 - Clarified address bar behavior for SameSite cookies: 2317 https://github.com/httpwg/http-extensions/issues/201 2318 (https://github.com/httpwg/http-extensions/issues/201) 2320 - Added the word "Cookies" to the document's name: 2321 https://github.com/httpwg/http-extensions/issues/204 2322 (https://github.com/httpwg/http-extensions/issues/204) 2324 - Clarified that the "__Host-" prefix requires an explicit "Path" 2325 attribute: https://github.com/httpwg/http-extensions/issues/222 2326 (https://github.com/httpwg/http-extensions/issues/222) 2328 - Expanded the options for dealing with third-party cookies to 2329 include a brief mention of partitioning based on first-party: 2330 https://github.com/httpwg/http-extensions/issues/248 2331 (https://github.com/httpwg/http-extensions/issues/248) 2333 - Noted that double-quotes in cookie values are part of the 2334 value, and are not stripped: https://github.com/httpwg/http- 2335 extensions/issues/295 (https://github.com/httpwg/http- 2336 extensions/issues/295) 2338 - Fixed the "site for cookies" algorithm to return something that 2339 makes sense: https://github.com/httpwg/http-extensions/ 2340 issues/302 (https://github.com/httpwg/http-extensions/ 2341 issues/302) 2343 A.4. draft-ietf-httpbis-rfc6265bis-03 2345 * Clarified handling of invalid SameSite values: 2346 https://github.com/httpwg/http-extensions/issues/389 2347 (https://github.com/httpwg/http-extensions/issues/389) 2349 * Reflect widespread implementation practice of including a cookie's 2350 "host-only-flag" when calculating its uniqueness: 2351 https://github.com/httpwg/http-extensions/issues/199 2352 (https://github.com/httpwg/http-extensions/issues/199) 2354 * Introduced an explicit "None" value for the SameSite attribute: 2355 https://github.com/httpwg/http-extensions/issues/788 2356 (https://github.com/httpwg/http-extensions/issues/788) 2358 A.5. draft-ietf-httpbis-rfc6265bis-04 2360 * Allow "SameSite" cookies to be set for all top-level navigations. 2361 https://github.com/httpwg/http-extensions/issues/594 2362 (https://github.com/httpwg/http-extensions/issues/594) 2364 * Treat "Set-Cookie: token" as creating the cookie "("", "token")": 2365 https://github.com/httpwg/http-extensions/issues/159 2366 (https://github.com/httpwg/http-extensions/issues/159) 2368 * Reject cookies with neither name nor value (e.g. "Set-Cookie: =" 2369 and "Set-Cookie:": https://github.com/httpwg/http-extensions/ 2370 issues/159 (https://github.com/httpwg/http-extensions/issues/159) 2372 * Clarified behavior of multiple "SameSite" attributes in a cookie 2373 string: https://github.com/httpwg/http-extensions/issues/901 2374 (https://github.com/httpwg/http-extensions/issues/901) 2376 A.6. draft-ietf-httpbis-rfc6265bis-05 2378 * Typos and editorial fixes: https://github.com/httpwg/http- 2379 extensions/pull/1035 (https://github.com/httpwg/http-extensions/ 2380 pull/1035), https://github.com/httpwg/http-extensions/pull/1038 2381 (https://github.com/httpwg/http-extensions/pull/1038), 2382 https://github.com/httpwg/http-extensions/pull/1040 2383 (https://github.com/httpwg/http-extensions/pull/1040), 2384 https://github.com/httpwg/http-extensions/pull/1047 2385 (https://github.com/httpwg/http-extensions/pull/1047). 2387 A.7. draft-ietf-httpbis-rfc6265bis-06 2389 * Editorial fixes: https://github.com/httpwg/http-extensions/ 2390 issues/1059 (https://github.com/httpwg/http-extensions/ 2391 issues/1059), https://github.com/httpwg/http-extensions/ 2392 issues/1158 (https://github.com/httpwg/http-extensions/ 2393 issues/1158). 2395 * Created a registry for cookie attribute names: 2396 https://github.com/httpwg/http-extensions/pull/1060 2397 (https://github.com/httpwg/http-extensions/pull/1060). 2399 * Tweaks to ABNF for "cookie-pair" and the "Cookie" header 2400 production: https://github.com/httpwg/http-extensions/issues/1074 2401 (https://github.com/httpwg/http-extensions/issues/1074), 2402 https://github.com/httpwg/http-extensions/issues/1119 2403 (https://github.com/httpwg/http-extensions/issues/1119). 2405 * Fixed serialization for nameless/valueless cookies: 2406 https://github.com/httpwg/http-extensions/pull/1143 2407 (https://github.com/httpwg/http-extensions/pull/1143). 2409 * Converted a normative reference to Mozilla's Public Suffix List 2410 [PSL] into an informative reference: https://github.com/httpwg/ 2411 http-extensions/issues/1159 (https://github.com/httpwg/http- 2412 extensions/issues/1159). 2414 A.8. draft-ietf-httpbis-rfc6265bis-07 2415 * Moved instruction to ignore cookies with empty cookie-name and 2416 cookie-value from Section 5.3 to Section 5.4 to ensure that they 2417 apply to cookies created without parsing a cookie string: 2418 https://github.com/httpwg/http-extensions/issues/1234 2419 (https://github.com/httpwg/http-extensions/issues/1234). 2421 * Add a default enforcement value to the "same-site-flag", 2422 equivalent to "SameSite=Lax": https://github.com/httpwg/http- 2423 extensions/pull/1325 (https://github.com/httpwg/http-extensions/ 2424 pull/1325). 2426 * Require a Secure attribute for "SameSite=None": 2427 https://github.com/httpwg/http-extensions/pull/1323 2428 (https://github.com/httpwg/http-extensions/pull/1323). 2430 * Consider scheme when running the same-site algorithm: 2431 https://github.com/httpwg/http-extensions/pull/1324 2432 (https://github.com/httpwg/http-extensions/pull/1324). 2434 Acknowledgements 2436 RFC 6265 was written by Adam Barth. This document is a minor update 2437 of RFC 6265, adding small features, and aligning the specification 2438 with the reality of today's deployments. Here, we're standing upon 2439 the shoulders of a giant since the majority of the text is still 2440 Adam's. 2442 Authors' Addresses 2444 Mike West (editor) 2445 Google, Inc 2447 Email: mkwst@google.com 2448 URI: https://mikewest.org/ 2450 John Wilander (editor) 2451 Apple, Inc 2453 Email: wilander@apple.com