idnits 2.17.1 draft-yasskin-http-origin-signed-responses-08.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 10 instances of too long lines in the document, the longest one being 38 characters in excess of 72. ** The abstract seems to contain references ([2], [1]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (November 04, 2019) is 1633 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 2219 -- Looks like a reference, but probably isn't: '2' on line 2221 -- Looks like a reference, but probably isn't: '3' on line 2223 -- Looks like a reference, but probably isn't: '4' on line 2225 -- Looks like a reference, but probably isn't: '5' on line 2227 -- Looks like a reference, but probably isn't: '100' on line 511 == Missing Reference: '-1' is mentioned on line 513, but not defined -- Looks like a reference, but probably isn't: '6' on line 2230 -- Looks like a reference, but probably isn't: '7' on line 2232 -- Looks like a reference, but probably isn't: '8' on line 2234 -- Looks like a reference, but probably isn't: '9' on line 2236 -- Looks like a reference, but probably isn't: '10' on line 2238 -- Looks like a reference, but probably isn't: '11' on line 2240 -- Looks like a reference, but probably isn't: '12' on line 2300 -- Looks like a reference, but probably isn't: '13' on line 2314 -- Looks like a reference, but probably isn't: '14' on line 2329 -- Looks like a reference, but probably isn't: '15' on line 2351 -- Looks like a reference, but probably isn't: '16' on line 2352 -- Looks like a reference, but probably isn't: '17' on line 2368 -- Looks like a reference, but probably isn't: '18' on line 2507 -- Looks like a reference, but probably isn't: '19' on line 2515 -- Possible downref: Non-RFC (?) normative reference: ref. 'FETCH' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-header-structure-14 == Outdated reference: A later version (-06) exists of draft-ietf-httpbis-variants-05 -- Possible downref: Normative reference to a draft: ref. 'I-D.ietf-httpbis-variants' -- Possible downref: Non-RFC (?) normative reference: ref. 'POSIX' ** Obsolete normative reference: RFC 3230 (Obsoleted by RFC 9530) ** Obsolete normative reference: RFC 6844 (Obsoleted by RFC 8659) ** Obsolete normative reference: RFC 6962 (Obsoleted by RFC 9162) ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7234 (Obsoleted by RFC 9111) ** Obsolete normative reference: RFC 7540 (Obsoleted by RFC 9113) ** Downref: Normative reference to an Informational RFC: RFC 8032 -- Possible downref: Non-RFC (?) normative reference: ref. 'URL' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-cache-05 == Outdated reference: A later version (-06) exists of draft-ietf-httpbis-http2-secondary-certs-05 == Outdated reference: A later version (-02) exists of draft-yasskin-wpack-use-cases-00 -- Obsolete informational reference (is this intentional?): RFC 2965 (Obsoleted by RFC 6265) -- Obsolete informational reference (is this intentional?): RFC 7235 (Obsoleted by RFC 9110) -- Obsolete informational reference (is this intentional?): RFC 7615 (Obsoleted by RFC 9110) Summary: 11 errors (**), 0 flaws (~~), 7 warnings (==), 29 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Yasskin 3 Internet-Draft Google 4 Intended status: Standards Track November 04, 2019 5 Expires: May 7, 2020 7 Signed HTTP Exchanges 8 draft-yasskin-http-origin-signed-responses-08 10 Abstract 12 This document specifies how a server can send an HTTP exchange--a 13 request URL, content negotiation information, and a response--with 14 signatures that vouch for that exchange's authenticity. These 15 signatures can be verified against an origin's certificate to 16 establish that the exchange is authoritative for an origin even if it 17 was transferred over a connection that isn't. The signatures can 18 also be used in other ways described in the appendices. 20 These signatures contain countermeasures against downgrade and 21 protocol-confusion attacks. 23 Note to Readers 25 Discussion of this draft takes place on the HTTP working group 26 mailing list (ietf-http-wg@w3.org), which is archived at 27 https://lists.w3.org/Archives/Public/ietf-http-wg/ [1]. 29 The source code and issues list for this draft can be found in 30 https://github.com/WICG/webpackage [2]. 32 Status of This Memo 34 This Internet-Draft is submitted in full conformance with the 35 provisions of BCP 78 and BCP 79. 37 Internet-Drafts are working documents of the Internet Engineering 38 Task Force (IETF). Note that other groups may also distribute 39 working documents as Internet-Drafts. The list of current Internet- 40 Drafts is at https://datatracker.ietf.org/drafts/current/. 42 Internet-Drafts are draft documents valid for a maximum of six months 43 and may be updated, replaced, or obsoleted by other documents at any 44 time. It is inappropriate to use Internet-Drafts as reference 45 material or to cite them other than as "work in progress." 47 This Internet-Draft will expire on May 7, 2020. 49 Copyright Notice 51 Copyright (c) 2019 IETF Trust and the persons identified as the 52 document authors. All rights reserved. 54 This document is subject to BCP 78 and the IETF Trust's Legal 55 Provisions Relating to IETF Documents 56 (https://trustee.ietf.org/license-info) in effect on the date of 57 publication of this document. Please review these documents 58 carefully, as they describe your rights and restrictions with respect 59 to this document. Code Components extracted from this document must 60 include Simplified BSD License text as described in Section 4.e of 61 the Trust Legal Provisions and are provided without warranty as 62 described in the Simplified BSD License. 64 Table of Contents 66 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 67 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 68 3. Signing an exchange . . . . . . . . . . . . . . . . . . . . . 5 69 3.1. The Signature Header . . . . . . . . . . . . . . . . . . 6 70 3.1.1. Examples . . . . . . . . . . . . . . . . . . . . . . 7 71 3.1.2. Open Questions . . . . . . . . . . . . . . . . . . . 9 72 3.2. CBOR representation of exchange response headers . . . . 9 73 3.2.1. Example . . . . . . . . . . . . . . . . . . . . . . . 10 74 3.3. Loading a certificate chain . . . . . . . . . . . . . . . 10 75 3.4. Canonical CBOR serialization . . . . . . . . . . . . . . 11 76 3.5. Signature validity . . . . . . . . . . . . . . . . . . . 12 77 3.5.1. Open Questions . . . . . . . . . . . . . . . . . . . 16 78 3.6. Updating signature validity . . . . . . . . . . . . . . . 16 79 3.6.1. Examples . . . . . . . . . . . . . . . . . . . . . . 17 80 3.7. The Accept-Signature header . . . . . . . . . . . . . . . 19 81 3.7.1. Integrity identifiers . . . . . . . . . . . . . . . . 20 82 3.7.2. Key type identifiers . . . . . . . . . . . . . . . . 20 83 3.7.3. Key value identifiers . . . . . . . . . . . . . . . . 20 84 3.7.4. Examples . . . . . . . . . . . . . . . . . . . . . . 21 85 3.7.5. Open Questions . . . . . . . . . . . . . . . . . . . 21 86 4. Cross-origin trust . . . . . . . . . . . . . . . . . . . . . 22 87 4.1. Uncached header fields . . . . . . . . . . . . . . . . . 23 88 4.1.1. Stateful header fields . . . . . . . . . . . . . . . 24 89 4.2. Certificate Requirements . . . . . . . . . . . . . . . . 25 90 4.2.1. Extensions to the CAA Record: cansignhttpexchanges 91 Parameter . . . . . . . . . . . . . . . . . . . . . . 26 92 5. Transferring a signed exchange . . . . . . . . . . . . . . . 26 93 5.1. Same-origin response . . . . . . . . . . . . . . . . . . 26 94 5.1.1. Serialized headers for a same-origin response . . . . 27 95 5.1.2. The Signed-Headers Header . . . . . . . . . . . . . . 27 96 5.2. HTTP/2 extension for cross-origin Server Push . . . . . . 28 97 5.2.1. Indicating support for cross-origin Server Push . . . 28 98 5.2.2. NO_TRUSTED_EXCHANGE_SIGNATURE error code . . . . . . 29 99 5.2.3. Validating a cross-origin Push . . . . . . . . . . . 29 100 5.3. application/signed-exchange format . . . . . . . . . . . 30 101 5.3.1. Cross-origin trust in application/signed-exchange . . 31 102 5.3.2. Example . . . . . . . . . . . . . . . . . . . . . . . 31 103 5.3.3. Open Questions . . . . . . . . . . . . . . . . . . . 32 104 6. Security considerations . . . . . . . . . . . . . . . . . . . 32 105 6.1. Over-signing . . . . . . . . . . . . . . . . . . . . . . 32 106 6.1.1. Session fixation . . . . . . . . . . . . . . . . . . 32 107 6.1.2. Misleading content . . . . . . . . . . . . . . . . . 33 108 6.2. Off-path attackers . . . . . . . . . . . . . . . . . . . 33 109 6.2.1. Mis-issued certificates . . . . . . . . . . . . . . . 33 110 6.2.2. Stolen private keys . . . . . . . . . . . . . . . . . 34 111 6.3. Downgrades . . . . . . . . . . . . . . . . . . . . . . . 34 112 6.4. Signing oracles are permanent . . . . . . . . . . . . . . 35 113 6.5. Unsigned headers . . . . . . . . . . . . . . . . . . . . 35 114 6.6. application/signed-exchange . . . . . . . . . . . . . . . 35 115 6.7. Key re-use with TLS . . . . . . . . . . . . . . . . . . . 36 116 6.8. Content sniffing . . . . . . . . . . . . . . . . . . . . 36 117 7. Privacy considerations . . . . . . . . . . . . . . . . . . . 37 118 7.1. Visibility of resource requests . . . . . . . . . . . . . 37 119 7.2. User ID transfer . . . . . . . . . . . . . . . . . . . . 38 120 8. IANA considerations . . . . . . . . . . . . . . . . . . . . . 39 121 8.1. Signature Header Field Registration . . . . . . . . . . . 39 122 8.2. Accept-Signature Header Field Registration . . . . . . . 39 123 8.3. Signed-Headers Header Field Registration . . . . . . . . 39 124 8.4. HTTP/2 Settings . . . . . . . . . . . . . . . . . . . . . 40 125 8.5. HTTP/2 Error code . . . . . . . . . . . . . . . . . . . . 40 126 8.6. Internet Media Type application/signed-exchange . . . . . 40 127 8.7. Internet Media Type application/cert-chain+cbor . . . . . 42 128 8.8. The cansignhttpexchanges CAA Parameter . . . . . . . . . 43 129 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 43 130 9.1. Normative References . . . . . . . . . . . . . . . . . . 43 131 9.2. Informative References . . . . . . . . . . . . . . . . . 45 132 9.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 48 133 Appendix A. Use cases . . . . . . . . . . . . . . . . . . . . . 49 134 A.1. PUSHed subresources . . . . . . . . . . . . . . . . . . . 49 135 A.2. Explicit use of a content distributor for subresources . 49 136 A.3. Subresource Integrity . . . . . . . . . . . . . . . . . . 50 137 A.4. Binary Transparency . . . . . . . . . . . . . . . . . . . 50 138 A.5. Static Analysis . . . . . . . . . . . . . . . . . . . . . 51 139 A.6. Offline websites . . . . . . . . . . . . . . . . . . . . 51 140 Appendix B. Requirements . . . . . . . . . . . . . . . . . . . . 51 141 B.1. Proof of origin . . . . . . . . . . . . . . . . . . . . . 51 142 B.1.1. Certificate constraints . . . . . . . . . . . . . . . 51 143 B.1.2. Signature constraints . . . . . . . . . . . . . . . . 52 144 B.1.3. Retrieving the certificate . . . . . . . . . . . . . 52 146 B.2. How much to sign . . . . . . . . . . . . . . . . . . . . 53 147 B.2.1. Conveying the signed headers . . . . . . . . . . . . 53 148 B.3. Response lifespan . . . . . . . . . . . . . . . . . . . . 54 149 B.3.1. Certificate revocation . . . . . . . . . . . . . . . 54 150 B.3.2. Response downgrade attacks . . . . . . . . . . . . . 54 151 B.4. Low implementation complexity . . . . . . . . . . . . . . 55 152 B.4.1. Limited choices . . . . . . . . . . . . . . . . . . . 55 153 B.4.2. Bounded-buffering integrity checking . . . . . . . . 55 154 Appendix C. Determining validity using cache control . . . . . . 56 155 C.1. Example of updating cache control . . . . . . . . . . . . 56 156 C.2. Downsides of updating cache control . . . . . . . . . . . 57 157 Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 57 158 Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 60 159 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 60 161 1. Introduction 163 Signed HTTP exchanges provide a way to prove the authenticity of a 164 resource in cases where the transport layer isn't sufficient. This 165 can be used in several ways: 167 o When signed by a certificate ([RFC5280]) that's trusted for an 168 origin, an exchange can be treated as authoritative for that 169 origin, even if it was transferred over a connection that isn't 170 authoritative (Section 9.1 of [RFC7230]) for that origin. See 171 Appendix A.1 and Appendix A.2. 173 o A top-level resource can use a public key to identify an expected 174 publisher for particular subresources, a system known as 175 Subresource Integrity ([SRI]). An exchange's signature provides 176 the matching proof of authorship. See Appendix A.3. 178 o A signature can vouch for the exchange in some way, for example 179 that it appears in a transparency log or that static analysis 180 indicates that it omits certain attacks. See Appendix A.4 and 181 Appendix A.5. 183 Subsequent work toward the use cases in [I-D.yasskin-wpack-use-cases] 184 will provide a way to group signed exchanges into bundles that can be 185 transmitted and stored together, but single signed exchanges are 186 useful enough to standardize on their own. 188 2. Terminology 190 Absolute URL A string for which the URL parser [3] ([URL]), when run 191 without a base URL, returns a URL rather than a failure, and for 192 which that URL has a null fragment. This is similar to the 193 absolute-URL string [4] concept defined by ([URL]) but might not 194 include exactly the same strings. 196 Author The entity that wrote the content in a particular resource. 197 This specification deals with publishers rather than authors. 199 Publisher The entity that controls the server for a particular 200 origin [RFC6454]. The publisher can get a CA to issue 201 certificates for their private keys and can run a TLS server for 202 their origin. 204 Exchange (noun) An HTTP request URL, content negotiation 205 information, and an HTTP response. This can be encoded into a 206 request message from a client with its matching response from a 207 server, into the request in a PUSH_PROMISE with its matching 208 response stream, or into the dedicated format in Section 5.3, 209 which uses [I-D.ietf-httpbis-variants] to encode the content 210 negotiation information. This is not quite the same meaning as 211 defined by Section 8 of [RFC7540], which assumes the content 212 negotiation information is embedded into HTTP request headers. 214 Intermediate An entity that fetches signed HTTP exchanges from a 215 publisher or another intermediate and forwards them to another 216 intermediate or a client. 218 Client An entity that uses a signed HTTP exchange and needs to be 219 able to prove that the publisher vouched for it as coming from its 220 claimed origin. 222 Unix time Defined by [POSIX] section 4.16 [5]. 224 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 225 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 226 "OPTIONAL" in this document are to be interpreted as described in BCP 227 14 [RFC2119] [RFC8174] when, and only when, they appear in all 228 capitals, as shown here. 230 3. Signing an exchange 232 In the response of an HTTP exchange the server MAY include a 233 "Signature" header field (Section 3.1) holding a list of one or more 234 parameterised signatures that vouch for the content of the exchange. 235 Exactly which content the signature vouches for can depend on how the 236 exchange is transferred (Section 5). 238 The client categorizes each signature as "valid" or "invalid" by 239 validating that signature with its certificate or public key and 240 other metadata against the exchange's URL, response headers, and 241 content (Section 3.5). This validity then informs higher-level 242 protocols. 244 Each signature is parameterised with information to let a client 245 fetch assurance that a signed exchange is still valid, in the face of 246 revoked certificates and newly-discovered vulnerabilities. This 247 assurance can be bundled back into the signed exchange and forwarded 248 to another client, which won't have to re-fetch this validity 249 information for some period of time. 251 3.1. The Signature Header 253 The "Signature" header field conveys a list of signatures for an 254 exchange, each one accompanied by information about how to determine 255 the authority of and refresh that signature. Each signature directly 256 signs the exchange's URL and response headers and identifies one of 257 those headers that enforces the integrity of the exchange's payload. 259 The "Signature" header is a Structured Header as defined by 260 [I-D.ietf-httpbis-header-structure]. Its value MUST be a 261 parameterised list (Section 3.4 of 262 [I-D.ietf-httpbis-header-structure]). Its ABNF is: 264 Signature = sh-param-list 266 Each parameterised identifier in the list MUST have parameters named 267 "sig", "integrity", "validity-url", "date", and "expires". Each 268 parameterised identifier MUST also have either "cert-url" and "cert- 269 sha256" parameters or an "ed25519key" parameter. This specification 270 gives no meaning to the identifier itself, which can be used as a 271 human-readable identifier for the signature (however, this is likely 272 to change soon; see Section 3.1.2, Paragraph 1). The present 273 parameters MUST have the following values: 275 "sig" Byte sequence (Section 3.10 of 276 [I-D.ietf-httpbis-header-structure]) holding the signature of most 277 of these parameters and the exchange's URL and response headers. 279 "integrity" A string (Section 3.8 of 280 [I-D.ietf-httpbis-header-structure]) containing a "/"-separated 281 sequence of names starting with the lowercase name of the response 282 header field that guards the response payload's integrity. The 283 meaning of subsequent names depends on the response header field, 284 but for the "digest" header field, the single following name is 285 the name of the digest algorithm that guards the payload's 286 integrity. 288 "cert-url" A string (Section 3.8 of 289 [I-D.ietf-httpbis-header-structure]) containing an absolute URL 290 (Section 2) with a scheme of "https" or "data". 292 "cert-sha256" Byte sequence (Section 3.10 of 293 [I-D.ietf-httpbis-header-structure]) holding the SHA-256 hash of 294 the first certificate found at "cert-url". 296 "ed25519key" Byte sequence (Section 3.10 of 297 [I-D.ietf-httpbis-header-structure]) holding an Ed25519 public key 298 ([RFC8032]). 300 "validity-url" A string (Section 3.8 of 301 [I-D.ietf-httpbis-header-structure]) containing an absolute URL 302 (Section 2) with a scheme of "https". 304 "date" and "expires" An integer (Section 3.6 of 305 [I-D.ietf-httpbis-header-structure]) representing a Unix time. 307 The "cert-url" parameter is _not_ signed, so intermediates can update 308 it with a pointer to a cached version. 310 3.1.1. Examples 312 The following header is included in the response for an exchange with 313 effective request URI "https://example.com/resource.html". Newlines 314 are added for readability. 316 Signature: 317 sig1; 318 sig=*MEUCIQDXlI2gN3RNBlgFiuRNFpZXcDIaUpX6HIEwcZEc0cZYLAIga9DsVOMM+g5YpwEBdGW3sS+bvnmAJJiSMwhuBdqp5UY=*; 319 integrity="digest/mi-sha256"; 320 validity-url="https://example.com/resource.validity.1511128380"; 321 cert-url="https://example.com/oldcerts"; 322 cert-sha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI=*; 323 date=1511128380; expires=1511733180, 324 sig2; 325 sig=*MEQCIGjZRqTRf9iKNkGFyzRMTFgwf/BrY2ZNIP/dykhUV0aYAiBTXg+8wujoT4n/W+cNgb7pGqQvIUGYZ8u8HZJ5YH26Qg==*; 326 integrity="digest/mi-sha256"; 327 validity-url="https://example.com/resource.validity.1511128380"; 328 cert-url="https://example.com/newcerts"; 329 cert-sha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw=*; 330 date=1511128380; expires=1511733180, 331 srisig; 332 sig=*lGZVaJJM5f2oGczFlLmBdKTDL+QADza4BgeO494ggACYJOvrof6uh5OJCcwKrk7DK+LBch0jssDYPp5CLc1SDA==*; 333 integrity="digest/mi-sha256"; 334 validity-url="https://example.com/resource.validity.1511128380"; 335 ed25519key=*zsSevyFsxyZHiUluVBDd4eypdRLTqyWRVOJuuKUz+A8=* 336 date=1511128380; expires=1511733180, 337 thirdpartysig; 338 sig=*MEYCIQCNxJzn6Rh2fNxsobktir8TkiaJYQFhWTuWI1i4PewQaQIhAMs2TVjc4rTshDtXbgQEOwgj2mRXALhfXPztXgPupii+*; 339 integrity="digest/mi-sha256"; 340 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 341 cert-url="https://thirdparty.example.com/certs"; 342 cert-sha256=*UeOwUPkvxlGRTyvHcsMUN0A2oNsZbU8EUvg8A9ZAnNc=*; 343 date=1511133060; expires=1511478660, 345 There are 4 signatures: 2 from different secp256r1 certificates 346 within "https://example.com/", one using a raw ed25519 public key 347 that's also controlled by "example.com", and a fourth using a 348 secp256r1 certificate owned by "thirdparty.example.com". 350 All 4 signatures rely on the "Digest" response header with the mi- 351 sha256 digest algorithm to guard the integrity of the response 352 payload. 354 The signatures include a "validity-url" that includes the first time 355 the resource was seen. This allows multiple versions of a resource 356 at the same URL to be updated with new signatures, which allows 357 clients to avoid transferring extra data while the old versions don't 358 have known security bugs. 360 The certificates at "https://example.com/oldcerts" and 361 "https://example.com/newcerts" have "subjectAltName"s of 362 "example.com", meaning that if they and their signatures validate, 363 the exchange can be trusted as having an origin of 364 "https://example.com/". The publisher might be using two 365 certificates because their readers have disjoint sets of roots in 366 their trust stores. 368 The publisher signed with all three certificates at the same time, so 369 they share a validity range: 7 days starting at 2017-11-19 21:53 UTC. 371 The publisher then requested an additional signature from 372 "thirdparty.example.com", which did some validation or processing and 373 then signed the resource at 2017-11-19 23:11 UTC. 374 "thirdparty.example.com" only grants 4-day signatures, so clients 375 will need to re-validate more often. 377 3.1.2. Open Questions 379 The next revision of [I-D.ietf-httpbis-header-structure] will provide 380 a way to parameterise byte sequences, at which point the signature 381 itself is likely to become the main list item. 383 Should the cert-url and validity-url be lists so that intermediates 384 can offer a cache without losing the original URLs? Putting lists in 385 dictionary fields is more complex than 386 [I-D.ietf-httpbis-header-structure] allows, so they're single items 387 for now. 389 3.2. CBOR representation of exchange response headers 391 To sign an exchange's response headers, they need to be serialized 392 into a byte string. Since intermediaries and distributors 393 (Appendix A.2) might rearrange, add, or just reserialize headers, we 394 can't use the literal bytes of the headers as this serialization. 395 Instead, this section defines a CBOR representation that can be 396 embedded into other CBOR, canonically serialized (Section 3.4), and 397 then signed. 399 The CBOR representation of a set of response metadata and headers is 400 the CBOR ([RFC7049]) map with the following mappings: 402 o The byte string ':status' to the byte string containing the 403 response's 3-digit status code, and 405 o For each response header field, the header field's lowercase name 406 as a byte string to the header field's value as a byte string. 408 3.2.1. Example 410 Given the HTTP exchange: 412 GET / HTTP/1.1 413 Host: example.com 414 Accept: */* 416 HTTP/1.1 200 417 Content-Type: text/html 418 Digest: mi-sha256=dcRDgR2GM35DluAV13PzgnG6+pvQwPywfFvAu1UeFrs= 419 Signed-Headers: "content-type", "digest" 421 422 423 ... 425 The cbor representation consists of the following item, represented 426 using the extended diagnostic notation from [CDDL] appendix G: 428 { 429 'digest': 'mi-sha256=dcRDgR2GM35DluAV13PzgnG6+pvQwPywfFvAu1UeFrs=', 430 ':status': '200', 431 'content-type': 'text/html' 432 } 434 3.3. Loading a certificate chain 436 The resource at a signature's "cert-url" MUST have the "application/ 437 cert-chain+cbor" content type, MUST be canonically-encoded CBOR 438 (Section 3.4), and MUST match the following CDDL: 440 cert-chain = [ 441 "📜⛓", ; U+1F4DC U+26D3 442 + augmented-certificate 443 ] 444 augmented-certificate = { 445 cert: bytes, 446 ? ocsp: bytes, 447 ? sct: bytes, 448 * tstr => any, 449 } 451 The first map (second item) in the CBOR array is treated as the end- 452 entity certificate, and the client will attempt to build a path 453 ([RFC5280]) to it from a trusted root using the other certificates in 454 the chain. 456 1. Each "cert" value MUST be a DER-encoded X.509v3 certificate 457 ([RFC5280]). Other key/value pairs in the same array item define 458 properties of this certificate. 460 2. The first certificate's "ocsp" value MUST be a complete, DER- 461 encoded OCSP response for that certificate (using the ASN.1 type 462 "OCSPResponse" defined in [RFC6960]). Subsequent certificates 463 MUST NOT have an "ocsp" value. 465 3. Each certificate's "sct" value if any MUST be a 466 "SignedCertificateTimestampList" for that certificate as defined 467 by Section 3.3 of [RFC6962]. 469 Loading a "cert-url" takes a "forceFetch" flag. The client MUST: 471 1. Let "raw-chain" be the result of fetching ([FETCH]) "cert-url". 472 If "forceFetch" is _not_ set, the fetch can be fulfilled from a 473 cache using normal HTTP semantics [RFC7234]. If this fetch 474 fails, return "invalid". 476 2. Let "certificate-chain" be the array of certificates and 477 properties produced by parsing "raw-chain" using the CDDL above. 478 If any of the requirements above aren't satisfied, return 479 "invalid". Note that this validation requirement might be 480 impractical to completely achieve due to certificate validation 481 implementations that don't enforce DER encoding or other standard 482 constraints. 484 3. Return "certificate-chain". 486 3.4. Canonical CBOR serialization 488 Within this specification, the canonical serialization of a CBOR item 489 uses the following rules derived from Section 3.9 of [RFC7049] with 490 erratum 4964 applied: 492 o Integers and the lengths of arrays, maps, and strings MUST use the 493 smallest possible encoding. 495 o Items MUST NOT be encoded with indefinite length. 497 o The keys in every map MUST be sorted in the bytewise lexicographic 498 order of their canonical encodings. For example, the following 499 keys are correctly sorted: 501 1. 10, encoded as 0A. 503 2. 100, encoded as 18 64. 505 3. -1, encoded as 20. 507 4. "z", encoded as 61 7A. 509 5. "aa", encoded as 62 61 61. 511 6. [100], encoded as 81 18 64. 513 7. [-1], encoded as 81 20. 515 8. false, encoded as F4. 517 Note: this specification does not use floating point, tags, or other 518 more complex data types, so it doesn't need rules to canonicalize 519 those. 521 3.5. Signature validity 523 The client MUST parse the "Signature" header field as the 524 parameterised list (Section 4.2.5 of 525 [I-D.ietf-httpbis-header-structure]) described in Section 3.1. If an 526 error is thrown during this parsing or any of the requirements 527 described there aren't satisfied, the exchange has no valid 528 signatures. Otherwise, each member of this list represents a 529 signature with parameters. 531 The client MUST use the following algorithm to determine whether each 532 signature with parameters is invalid or potentially-valid for an 533 exchange's 535 o "requestUrl", a byte sequence that can be parsed into the 536 exchange's effective request URI (Section 5.5 of [RFC7230]), 538 o "responseHeaders", a byte sequence holding the canonical 539 serialization (Section 3.4) of the CBOR representation 540 (Section 3.2) of the exchange's response metadata and headers, and 542 o "payload", a stream of bytes constituting the exchange's payload 543 body (Section 3.3 of [RFC7230]). Note that the payload body is 544 the message body with any transfer encodings removed. 546 Potentially-valid results include: 548 o The signed headers of the exchange so that higher-level protocols 549 can avoid relying on unsigned headers, and 551 o Either a certificate chain or a public key so that a higher-level 552 protocol can determine whether it's actually valid. 554 This algorithm accepts a "forceFetch" flag that avoids the cache when 555 fetching URLs. A client that determines that a potentially-valid 556 certificate chain is actually invalid due to an expired OCSP response 557 MAY retry with "forceFetch" set to retrieve an updated OCSP from the 558 original server. 560 1. Let: 562 * "signature" be the signature (byte sequence in the 563 parameterised identifier's "sig" parameter). 565 * "integrity" be the signature's "integrity" parameter. 567 * "validity-url" be the signature's "validity-url" parameter. 569 * "cert-url" be the signature's "cert-url" parameter, if any. 571 * "cert-sha256" be the signature's "cert-sha256" parameter, if 572 any. 574 * "ed25519key" be the signature's "ed25519key" parameter, if 575 any. 577 * "date" be the signature's "date" parameter, interpreted as a 578 Unix time. 580 * "expires" be the signature's "expires" parameter, interpreted 581 as a Unix time. 583 2. Set "publicKey" and "signing-alg" depending on which key fields 584 are present: 586 1. If "cert-url" is present: 588 1. Let "certificate-chain" be the result of loading the 589 certificate chain at "cert-url" passing the "forceFetch" 590 flag (Section 3.3). If this returns "invalid", return 591 "invalid". 593 2. Let "main-certificate" be the first certificate in 594 "certificate-chain". 596 3. Set "publicKey" to "main-certificate"'s public key. 598 4. If "publicKey" is an RSA key, return "invalid". 600 5. If "publicKey" is a key using the secp256r1 elliptic 601 curve, set "signing-alg" to ecdsa_secp256r1_sha256 as 602 defined in Section 4.2.3 of [RFC8446]. 604 6. Otherwise, either return "invalid" or set "signing-alg" 605 to a non-legacy signing algorithm defined by TLS 1.3 or 606 later ([RFC8446]). This choice MUST depend only on 607 "publicKey"'s type and not on any other context. 609 2. If "ed25519key" is present, set "publicKey" to "ed25519key" 610 and "signing-alg" to ed25519, as defined by [RFC8032] 612 3. If "expires" is more than 7 days (604800 seconds) after "date", 613 return "invalid". 615 4. If the current time is before "date" or after "expires", return 616 "invalid". 618 5. Let "message" be the concatenation of the following byte 619 strings. This matches the [RFC8446] format to avoid cross- 620 protocol attacks if anyone uses the same key in a TLS 621 certificate and an exchange-signing certificate. 623 1. A string that consists of octet 32 (0x20) repeated 64 times. 625 2. A context string: the ASCII encoding of "HTTP Exchange 1". 627 Note: RFC EDITOR PLEASE DELETE THIS NOTE; The implementation 628 of the final RFC MUST use this context string, but 629 implementations of drafts MUST NOT use it and MUST use 630 another draft-specific string beginning with "HTTP Exchange 631 1 " instead. This ensures that signers can predict how 632 their signatures will be used. 634 3. A single 0 byte which serves as a separator. 636 4. If "cert-sha256" is set, a byte holding the value 32 637 followed by the 32 bytes of the value of "cert-sha256". 638 Otherwise a 0 byte. 640 5. The 8-byte big-endian encoding of the length in bytes of 641 "validity-url", followed by the bytes of "validity-url". 643 6. The 8-byte big-endian encoding of "date". 645 7. The 8-byte big-endian encoding of "expires". 647 8. The 8-byte big-endian encoding of the length in bytes of 648 "requestUrl", followed by the bytes of "requestUrl". 650 9. The 8-byte big-endian encoding of the length in bytes of 651 "responseHeaders", followed by the bytes of 652 "responseHeaders". 654 6. If "cert-url" is present and the SHA-256 hash of "main- 655 certificate"'s "cert_data" is not equal to "cert-sha256" (whose 656 presence was checked when the "Signature" header field was 657 parsed), return "invalid". 659 Note that this intentionally differs from TLS 1.3, which signs 660 the entire certificate chain in its Certificate Verify 661 (Section 4.4.3 of [RFC8446]), in order to allow updating the 662 stapled OCSP response without updating signatures at the same 663 time. 665 7. If "signature" is not a valid signature of "message" by 666 "publicKey" using "signing-alg", return "invalid". 668 8. If "headers", interpreted according to Section 3.2, does not 669 contain a "Content-Type" response header field (Section 3.1.1.5 670 of [RFC7231]), return "invalid". 672 Clients MUST interpret the signed payload as this specified 673 media type instead of trying to sniff a media type from the 674 bytes of the payload, for example by attaching an "X-Content- 675 Type-Options: nosniff" header field ([FETCH]) to the extracted 676 response. 678 9. If "integrity" names a header field and parameter that is not 679 present in "responseHeaders" or which the client cannot use to 680 check the integrity of "payload" (for example, the header field 681 is new and hasn't been implemented yet), then return "invalid". 682 If the selected header field provides integrity guarantees 683 weaker than SHA-256, return "invalid". If validating integrity 684 using the selected header field requires the client to process 685 records larger than 16384 bytes, return "invalid". Clients MUST 686 implement at least the "Digest" header field with its "mi- 687 sha256" digest algorithm (Section 3 of [I-D.thomson-http-mice]). 689 Note: RFC EDITOR PLEASE DELETE THIS NOTE; Implementations of 690 drafts of this RFC MUST recognize the draft spelling of the 691 content encoding and digest algorithm specified by 692 [I-D.thomson-http-mice] until that draft is published as an RFC. 693 For example, implementations of draft-thomson-http-mice-03 would 694 use "mi-sha256-03" and MUST NOT use "mi-sha256" itself. This 695 ensures that final implementations don't need to handle 696 compatibility with implementations of early drafts of that 697 content encoding. 699 If "payload" doesn't match the integrity information in the 700 header described by "integrity", return "invalid". 702 10. Return "potentially-valid" with whichever is present of 703 "certificate-chain" or "ed25519key". 705 Note that the above algorithm can determine that an exchange's 706 headers are potentially-valid before the exchange's payload is 707 received. Similarly, if "integrity" identifies a header field and 708 parameter like "Digest:mi-sha256" ([I-D.thomson-http-mice]) that can 709 incrementally validate the payload, early parts of the payload can be 710 determined to be potentially-valid before later parts of the payload. 711 Higher-level protocols MAY process parts of the exchange that have 712 been determined to be potentially-valid as soon as that determination 713 is made but MUST NOT process parts of the exchange that are not yet 714 potentially-valid. Similarly, as the higher-level protocol 715 determines that parts of the exchange are actually valid, the client 716 MAY process those parts of the exchange and MUST wait to process 717 other parts of the exchange until they too are determined to be 718 valid. 720 3.5.1. Open Questions 722 Should the signed message use the TLS format (with an initial 64 723 spaces) even though these certificates can't be used in TLS servers? 725 3.6. Updating signature validity 727 Both OCSP responses and signatures are designed to expire a short 728 time after they're signed, so that revoked certificates and signed 729 exchanges with known vulnerabilities are distrusted promptly. 731 This specification provides no way to update OCSP responses by 732 themselves. Instead, clients need to re-fetch the "cert-url" 733 (Section 3.5, Paragraph 6) to get a chain including a newer OCSP 734 response. 736 The "validity-url" parameter (Paragraph 6) of the signatures provides 737 a way to fetch new signatures or learn where to fetch a complete 738 updated exchange. 740 Each version of a signed exchange SHOULD have its own validity URLs, 741 since each version needs different signatures and becomes obsolete at 742 different times. 744 The resource at a "validity-url" is "validity data", a CBOR map 745 matching the following CDDL ([CDDL]): 747 validity = { 748 ? signatures: [ + bytes ] 749 ? update: { 750 ? size: uint, 751 } 752 ] 754 The elements of the "signatures" array are parameterised identifiers 755 (Section 4.2.6 of [I-D.ietf-httpbis-header-structure]) meant to 756 replace the signatures within the "Signature" header field pointing 757 to this validity data. If the signed exchange contains a bug severe 758 enough that clients need to stop using the content, the "signatures" 759 array MUST NOT be present. 761 If the the "update" map is present, that indicates that a new version 762 of the signed exchange is available at its effective request URI 763 (Section 5.5 of [RFC7230]) and can give an estimate of the size of 764 the updated exchange ("update.size"). If the signed exchange is 765 currently the most recent version, the "update" SHOULD NOT be 766 present. 768 If both the "signatures" and "update" fields are present, clients can 769 use the estimated size to decide whether to update the whole resource 770 or just its signatures. 772 3.6.1. Examples 774 For example, say a signed exchange whose URL is "https://example.com/ 775 resource" has the following "Signature" header field (with line 776 breaks included and irrelevant fields omitted for ease of reading). 778 Signature: 779 sig1; 780 sig=*MEUCIQ...*; 781 ... 782 validity-url="https://example.com/resource.validity.1511157180"; 783 cert-url="https://example.com/oldcerts"; 784 date=1511128380; expires=1511733180, 785 sig2; 786 sig=*MEQCIG...*; 787 ... 788 validity-url="https://example.com/resource.validity.1511157180"; 789 cert-url="https://example.com/newcerts"; 790 date=1511128380; expires=1511733180, 791 thirdpartysig; 792 sig=*MEYCIQ...*; 793 ... 794 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 795 cert-url="https://thirdparty.example.com/certs"; 796 date=1511478660; expires=1511824260 798 At 2017-11-27 11:02 UTC, "sig1" and "sig2" have expired, but 799 "thirdpartysig" doesn't exipire until 23:11 that night, so the client 800 needs to fetch "https://example.com/resource.validity.1511157180" 801 (the "validity-url" of "sig1" and "sig2") if it wishes to update 802 those signatures. This URL might contain: 804 { 805 "signatures": [ 806 'sig1; ' 807 'sig=*MEQCIC/I9Q+7BZFP6cSDsWx43pBAL0ujTbON/+7RwKVk+ba5AiB3FSFLZqpzmDJ0NumNwN04pqgJZE99fcK86UjkPbj4jw==*; ' 808 'validity-url="https://example.com/resource.validity.1511157180"; ' 809 'integrity="digest/mi-sha256"; ' 810 'cert-url="https://example.com/newcerts"; ' 811 'cert-sha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw=*; ' 812 'date=1511733180; expires=1512337980' 813 ], 814 "update": { 815 "size": 5557452 816 } 817 } 819 This indicates that the client could fetch a newer version at 820 "https://example.com/resource" (the original URL of the exchange), or 821 that the validity period of the old version can be extended by 822 replacing the first two of the original signatures (the ones with a 823 validity-url of "https://example.com/resource.validity.1511157180") 824 with the single new signature provided. (This might happen at the 825 end of a migration to a new root certificate.) The signatures of the 826 updated signed exchange would be: 828 Signature: 829 sig1; 830 sig=*MEQCIC...*; 831 ... 832 validity-url="https://example.com/resource.validity.1511157180"; 833 cert-url="https://example.com/newcerts"; 834 date=1511733180; expires=1512337980, 835 thirdpartysig; 836 sig=*MEYCIQ...*; 837 ... 838 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 839 cert-url="https://thirdparty.example.com/certs"; 840 date=1511478660; expires=1511824260 842 "https://example.com/resource.validity.1511157180" could also expand 843 the set of signatures if its "signatures" array contained more than 2 844 elements. 846 3.7. The Accept-Signature header 848 "Signature" header fields cost on the order of 300 bytes for ECDSA 849 signatures, so servers might prefer to avoid sending them to clients 850 that don't intend to use them. A client can send the "Accept- 851 Signature" header field to indicate that it does intend to take 852 advantage of any available signatures and to indicate what kinds of 853 signatures it supports. 855 When a server receives an "Accept-Signature" header field in a client 856 request, it SHOULD reply with any available "Signature" header fields 857 for its response that the "Accept-Signature" header field indicates 858 the client supports. However, if the "Accept-Signature" value 859 violates a requirement in this section, the server MUST behave as if 860 it hadn't received any "Accept-Signature" header at all. 862 The "Accept-Signature" header field is a Structured Header as defined 863 by [I-D.ietf-httpbis-header-structure]. Its value MUST be a 864 parameterised list (Section 3.4 of 865 [I-D.ietf-httpbis-header-structure]). Its ABNF is: 867 Accept-Signature = sh-param-list 869 The order of identifiers in the "Accept-Signature" list is not 870 significant. Identifiers, ignoring any initial "-" character, MUST 871 NOT be duplicated. 873 Each identifier in the "Accept-Signature" header field's value 874 indicates that a feature of the "Signature" header field 875 (Section 3.1) is supported. If the identifier begins with a "-" 876 character, it instead indicates that the feature named by the rest of 877 the identifier is not supported. Unknown identifiers and parameters 878 MUST be ignored because new identifiers and new parameters on 879 existing identifiers may be defined by future specifications. 881 3.7.1. Integrity identifiers 883 Identifiers starting with "digest/" indicate that the client supports 884 the "Digest" header field ([RFC3230]) with the parameter from the 885 HTTP Digest Algorithm Values Registry [6] registry named in lower- 886 case by the rest of the identifier. For example, "digest/mi-blake2" 887 indicates support for Merkle integrity with the as-yet-unspecified 888 mi-blake2 parameter, and "-digest/mi-sha256" indicates non-support 889 for Merkle integrity with the mi-sha256 content encoding. 891 If the "Accept-Signature" header field is present, servers SHOULD 892 assume support for "digest/mi-sha256" unless the header field states 893 otherwise. 895 3.7.2. Key type identifiers 897 Identifiers starting with "ecdsa/" indicate that the client supports 898 certificates holding ECDSA public keys on the curve named in lower- 899 case by the rest of the identifier. 901 If the "Accept-Signature" header field is present, servers SHOULD 902 assume support for "ecdsa/secp256r1" unless the header field states 903 otherwise. 905 3.7.3. Key value identifiers 907 The "ed25519key" identifier has parameters indicating the public keys 908 that will be used to validate the returned signature. Each 909 parameter's name is re-interpreted as a byte sequence (Section 3.10 910 of [I-D.ietf-httpbis-header-structure]) encoding a prefix of the 911 public key. For example, if the client will validate signatures 912 using the public key whose base64 encoding is 913 "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=", valid "Accept- 914 Signature" header fields include: 916 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=* 917 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg==* 918 Accept-Signature: ..., ed25519key; *11qYAQ==* 919 Accept-Signature: ..., ed25519key; ** 920 but not 922 Accept-Signature: ..., ed25519key; *11qYA===* 924 because 5 bytes isn't a valid length for encoded base64, and not 926 Accept-Signature: ..., ed25519key; 11qYAQ 928 because it doesn't start or end with the "*"s that indicate a byte 929 sequence. 931 Note that "ed25519key; **" is an empty prefix, which matches all 932 public keys, so it's useful in subresource integrity (Appendix A.3) 933 cases like "" where the public 934 key isn't known until the matching "