idnits 2.17.1 draft-yasskin-http-origin-signed-responses-02.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 11 instances of too long lines in the document, the longest one being 35 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 (January 26, 2018) is 2283 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 1505 -- Looks like a reference, but probably isn't: '2' on line 1507 -- Looks like a reference, but probably isn't: '3' on line 1509 -- Looks like a reference, but probably isn't: '4' on line 1512 -- Looks like a reference, but probably isn't: '5' on line 1514 -- Looks like a reference, but probably isn't: '100' on line 493 == Missing Reference: '-1' is mentioned on line 495, but not defined -- Looks like a reference, but probably isn't: '6' on line 1516 -- Looks like a reference, but probably isn't: '7' on line 1518 -- Looks like a reference, but probably isn't: '8' on line 1520 -- Looks like a reference, but probably isn't: '9' on line 1522 -- Looks like a reference, but probably isn't: '10' on line 1584 -- Looks like a reference, but probably isn't: '11' on line 1598 -- Looks like a reference, but probably isn't: '12' on line 1613 -- Looks like a reference, but probably isn't: '13' on line 1635 -- Looks like a reference, but probably isn't: '14' on line 1636 -- Looks like a reference, but probably isn't: '15' on line 1652 -- Looks like a reference, but probably isn't: '16' on line 1764 -- Looks like a reference, but probably isn't: '17' on line 1808 -- Looks like a reference, but probably isn't: '18' on line 1816 == Unused Reference: 'HTML' is defined on line 1360, but no explicit reference was found in the text -- Possible downref: Non-RFC (?) normative reference: ref. 'FETCH' -- Possible downref: Non-RFC (?) normative reference: ref. 'HTML' == Outdated reference: A later version (-08) exists of draft-ietf-cbor-cddl-00 == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-header-structure-02 == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-23 == Outdated reference: A later version (-03) exists of draft-thomson-http-mice-02 -- Possible downref: Non-RFC (?) normative reference: ref. 'POSIX' ** Obsolete normative reference: RFC 3230 (Obsoleted by RFC 9530) ** 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 == Outdated reference: A later version (-12) exists of draft-cavage-http-signatures-09 == Outdated reference: A later version (-06) exists of draft-ietf-httpbis-http2-secondary-certs-00 == Outdated reference: A later version (-02) exists of draft-yasskin-webpackage-use-cases-00 Summary: 10 errors (**), 0 flaws (~~), 10 warnings (==), 24 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 January 26, 2018 5 Expires: July 30, 2018 7 Signed HTTP Exchanges 8 draft-yasskin-http-origin-signed-responses-02 10 Abstract 12 This document specifies how a server can send an HTTP request/ 13 response pair, known as an exchange, with signatures that vouch for 14 that exchange's authenticity. These signatures can be verified 15 against an origin's certificate to establish that the exchange is 16 authoritative for an origin even if it was transferred over a 17 connection that isn't. The signatures can also be used in other ways 18 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 July 30, 2018. 49 Copyright Notice 51 Copyright (c) 2018 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 . . . . . . . . . . . . . . . . . . . . . . . . 3 67 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 68 3. Signing an exchange . . . . . . . . . . . . . . . . . . . . . 5 69 3.1. The Signed-Headers Header . . . . . . . . . . . . . . . . 5 70 3.2. The Signature Header . . . . . . . . . . . . . . . . . . 6 71 3.2.1. Examples . . . . . . . . . . . . . . . . . . . . . . 7 72 3.2.2. Open Questions . . . . . . . . . . . . . . . . . . . 8 73 3.3. Significant headers of an exchange . . . . . . . . . . . 9 74 3.3.1. Open Questions . . . . . . . . . . . . . . . . . . . 9 75 3.4. CBOR representation of exchange headers . . . . . . . . . 9 76 3.4.1. Example . . . . . . . . . . . . . . . . . . . . . . . 10 77 3.5. Canonical CBOR serialization . . . . . . . . . . . . . . 10 78 3.6. Signature validity . . . . . . . . . . . . . . . . . . . 11 79 3.6.1. Open Questions . . . . . . . . . . . . . . . . . . . 15 80 3.7. Updating signature validity . . . . . . . . . . . . . . . 15 81 3.7.1. Examples . . . . . . . . . . . . . . . . . . . . . . 16 82 3.8. The Accept-Signature header . . . . . . . . . . . . . . . 18 83 3.8.1. Integrity labels . . . . . . . . . . . . . . . . . . 19 84 3.8.2. Key type labels . . . . . . . . . . . . . . . . . . . 19 85 3.8.3. Key value labels . . . . . . . . . . . . . . . . . . 19 86 3.8.4. Examples . . . . . . . . . . . . . . . . . . . . . . 20 87 3.8.5. Open Questions . . . . . . . . . . . . . . . . . . . 20 88 4. HTTP/2 extension for cross-origin Server Push . . . . . . . . 21 89 4.1. Indicating support for cross-origin Server Push . . . . . 21 90 4.2. NO_TRUSTED_EXCHANGE_SIGNATURE error code . . . . . . . . 21 91 4.2.1. Open Questions . . . . . . . . . . . . . . . . . . . 22 92 4.3. Validating a cross-origin Push . . . . . . . . . . . . . 22 93 4.3.1. Validating a certificate chain for an authority . . . 22 94 4.3.2. Open Questions . . . . . . . . . . . . . . . . . . . 23 95 5. application/http-exchange+cbor format for HTTP/1 96 compatibility . . . . . . . . . . . . . . . . . . . . . . . . 23 98 5.1. Example . . . . . . . . . . . . . . . . . . . . . . . . . 25 99 5.2. Open Questions . . . . . . . . . . . . . . . . . . . . . 25 100 6. Security considerations . . . . . . . . . . . . . . . . . . . 25 101 6.1. Confidential data . . . . . . . . . . . . . . . . . . . . 25 102 6.2. Off-path attackers . . . . . . . . . . . . . . . . . . . 25 103 6.3. Downgrades . . . . . . . . . . . . . . . . . . . . . . . 26 104 6.4. Signing oracles are permanent . . . . . . . . . . . . . . 26 105 6.5. Unsigned headers . . . . . . . . . . . . . . . . . . . . 26 106 6.6. application/http-exchange+cbor . . . . . . . . . . . . . 27 107 7. Privacy considerations . . . . . . . . . . . . . . . . . . . 27 108 8. IANA considerations . . . . . . . . . . . . . . . . . . . . . 27 109 8.1. Signature Header Field Registration . . . . . . . . . . . 28 110 8.2. HTTP/2 Settings . . . . . . . . . . . . . . . . . . . . . 28 111 8.3. HTTP/2 Error code . . . . . . . . . . . . . . . . . . . . 28 112 8.4. Internet Media Type application/http-exchange+cbor . . . 28 113 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 29 114 9.1. Normative References . . . . . . . . . . . . . . . . . . 29 115 9.2. Informative References . . . . . . . . . . . . . . . . . 31 116 9.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 33 117 Appendix A. Use cases . . . . . . . . . . . . . . . . . . . . . 33 118 A.1. PUSHed subresources . . . . . . . . . . . . . . . . . . . 33 119 A.2. Explicit use of a content distributor for subresources . 34 120 A.3. Subresource Integrity . . . . . . . . . . . . . . . . . . 35 121 A.4. Binary Transparency . . . . . . . . . . . . . . . . . . . 35 122 A.5. Static Analysis . . . . . . . . . . . . . . . . . . . . . 35 123 A.6. Offline websites . . . . . . . . . . . . . . . . . . . . 36 124 Appendix B. Requirements . . . . . . . . . . . . . . . . . . . . 36 125 B.1. Proof of origin . . . . . . . . . . . . . . . . . . . . . 36 126 B.1.1. Certificate constraints . . . . . . . . . . . . . . . 36 127 B.1.2. Signature constraints . . . . . . . . . . . . . . . . 37 128 B.1.3. Retrieving the certificate . . . . . . . . . . . . . 37 129 B.2. How much to sign . . . . . . . . . . . . . . . . . . . . 37 130 B.2.1. Conveying the signed headers . . . . . . . . . . . . 38 131 B.3. Response lifespan . . . . . . . . . . . . . . . . . . . . 39 132 B.3.1. Certificate revocation . . . . . . . . . . . . . . . 39 133 B.3.2. Response downgrade attacks . . . . . . . . . . . . . 39 134 Appendix C. Determining validity using cache control . . . . . . 40 135 C.1. Example of updating cache control . . . . . . . . . . . . 40 136 C.2. Downsides of updating cache control . . . . . . . . . . . 41 137 Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 42 138 Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 42 139 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 42 141 1. Introduction 143 Signed HTTP exchanges provide a way to prove the authenticity of a 144 resource in cases where the transport layer isn't sufficient. This 145 can be used in several ways: 147 o When signed by a certificate ([RFC5280]) that's trusted for an 148 origin, an exchange can be treated as authoritative for that 149 origin, even if it was transferred over a connection that isn't 150 authoritative (Section 9.1 of [RFC7230]) for that origin. See 151 Appendix A.1 and Appendix A.2. 153 o A top-level resource can use a public key to identify an expected 154 author for particular subresources, a system known as Subresource 155 Integrity ([SRI]). An exchange's signature provides the matching 156 proof of authorship. See Appendix A.3. 158 o A signature can vouch for the exchange in some way, for example 159 that it appears in a transparency log or that static analysis 160 indicates that it omits certain attacks. See Appendix A.4 and 161 Appendix A.5. 163 Subsequent work toward the use cases in 164 [I-D.yasskin-webpackage-use-cases] will provide a way to group signed 165 exchanges into bundles that can be transmitted and stored together, 166 but single signed exchanges are useful enough to standardize on their 167 own. 169 2. Terminology 171 Author The entity that controls the server for a particular origin 172 [RFC6454]. The author can get a CA to issue certificates for 173 their private keys and can run a TLS server for their origin. 175 Exchange (noun) An HTTP request/response pair. This can either be a 176 request from a client and the matching response from a server or 177 the request in a PUSH_PROMISE and its matching response stream. 178 Defined by Section 8 of [RFC7540]. 180 Intermediate An entity that fetches signed HTTP exchanges from an 181 author or another intermediate and forwards them to another 182 intermediate or a client. 184 Client An entity that uses a signed HTTP exchange and needs to be 185 able to prove that the author vouched for it as coming from its 186 claimed origin. 188 Unix time Defined by [POSIX] section 4.16 [3]. 190 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 191 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 192 "OPTIONAL" in this document are to be interpreted as described in BCP 193 14 [RFC2119] [RFC8174] when, and only when, they appear in all 194 capitals, as shown here. 196 3. Signing an exchange 198 As a response to an HTTP request or as a Server Push (Section 8.2 of 199 [RFC7540]) the server MAY include a "Signed-Headers" header field 200 (Section 3.1) identifying significant (Section 3.3) header fields and 201 a "Signature" header field (Section 3.2) holding a list of one or 202 more parameterised signatures that vouch for the content of the 203 response. 205 The client categorizes each signature as "valid" or "invalid" by 206 validating that signature with its certificate or public key and 207 other metadata against the significant headers and content 208 (Section 3.6). This validity then informs higher-level protocols. 210 Each signature is parameterised with information to let a client 211 fetch assurance that a signed exchange is still valid, in the face of 212 revoked certificates and newly-discovered vulnerabilities. This 213 assurance can be bundled back into the signed exchange and forwarded 214 to another client, which won't have to re-fetch this validity 215 information for some period of time. 217 3.1. The Signed-Headers Header 219 The "Signed-Headers" header field identifies an ordered list of 220 response header fields to include in a signature. The request URL 221 and response status are included unconditionally. This allows a TLS- 222 terminating intermediate to reorder headers without breaking the 223 signature. This _can_ also allow the intermediate to add headers 224 that will be ignored by some higher-level protocols, but Section 3.6 225 provides a hook to let other higher-level protocols reject such 226 insecure headers. 228 This header field appears once instead of being incorporated into the 229 signatures' parameters because the significant header fields need to 230 be consistent across all signatures of an exchange, to avoid forcing 231 higher-level protocols to merge the header field lists of valid 232 signatures. 234 See Appendix B.2 for a discussion of why only the URL from the 235 request is included and not other request headers. 237 "Signed-Headers" is a Structured Header as defined by 238 [I-D.ietf-httpbis-header-structure]. Its value MUST be a list 239 (Section 4.8 of [I-D.ietf-httpbis-header-structure]) of lowercase 240 strings (Section 4.2 of [I-D.ietf-httpbis-header-structure]) naming 241 HTTP response header fields. Pseudo-header field names 242 (Section 8.1.2.1 of [RFC7540]) MUST NOT appear in this list. 244 Higher-level protocols SHOULD place requirements on the minimum set 245 of headers to include in the "Signed-Headers" header field. 247 3.2. The Signature Header 249 The "Signature" header field conveys a list of signatures for an 250 exchange, each one accompanied by information about how to determine 251 the authority of and refresh that signature. Each signature directly 252 signs the significant headers of the exchange and identifies one of 253 those headers that enforces the integrity of the exchange's payload. 255 The "Signature" header is a Structured Header as defined by 256 [I-D.ietf-httpbis-header-structure]. Its value MUST be a list 257 (Section 4.8 of [I-D.ietf-httpbis-header-structure]) of parameterised 258 labels (Section 4.4 of [I-D.ietf-httpbis-header-structure]). 260 Each parameterised label MUST have parameters named "sig", 261 "integrity", "validityUrl", "date", and "expires". Each 262 parameterised label MUST also have either "certUrl" and "certSha256" 263 parameters or an "ed25519Key" parameter. This specification gives no 264 meaning to the label itself, which can be used as a human-readable 265 identifier for the signature (see Section 3.2.2, Paragraph 1). The 266 present parameters MUST have the following values: 268 "sig" Binary content (Section 4.5 of 269 [I-D.ietf-httpbis-header-structure]) holding the signature of most 270 of these parameters and the significant headers of the exchange 271 (Section 3.3). 273 "integrity" A string (Section 4.2 of 274 [I-D.ietf-httpbis-header-structure]) containing the lowercase name 275 of the response header field that guards the response payload's 276 integrity. 278 "certUrl" A string (Section 4.2 of 279 [I-D.ietf-httpbis-header-structure]) containing a valid URL string 280 [4]. 282 "certSha256" Binary content (Section 4.5 of 283 [I-D.ietf-httpbis-header-structure]) holding the SHA-256 hash of 284 the first certificate found at "certUrl". 286 "ed25519Key" Binary content (Section 4.5 of 287 [I-D.ietf-httpbis-header-structure]) holding an Ed25519 public key 288 ([RFC8032]). 290 "validityUrl" A string (Section 4.2 of 291 [I-D.ietf-httpbis-header-structure]) containing a valid URL string 292 [5]. 294 "date" and "expires" An unsigned integer (Section 4.1 of 295 [I-D.ietf-httpbis-header-structure]) representing a Unix time. 297 The "certUrl" parameter is _not_ signed, so intermediates can update 298 it with a pointer to a cached version. 300 3.2.1. Examples 302 The following header is included in the response for an exchange with 303 effective request URI "https://example.com/resource.html". Newlines 304 are added for readability. 306 Signature: 307 sig1; 308 sig=*MEUCIQDXlI2gN3RNBlgFiuRNFpZXcDIaUpX6HIEwcZEc0cZYLAIga9DsVOMM+g5YpwEBdGW3sS+bvnmAJJiSMwhuBdqp5UY; 309 integrity="mi"; 310 validityUrl="https://example.com/resource.validity.1511128380"; 311 certUrl="https://example.com/oldcerts"; 312 certSha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI; 313 date=1511128380; expires=1511733180, 314 sig2; 315 sig=*MEQCIGjZRqTRf9iKNkGFyzRMTFgwf/BrY2ZNIP/dykhUV0aYAiBTXg+8wujoT4n/W+cNgb7pGqQvIUGYZ8u8HZJ5YH26Qg; 316 integrity="mi"; 317 validityUrl="https://example.com/resource.validity.1511128380"; 318 certUrl="https://example.com/newcerts"; 319 certSha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw; 320 date=1511128380; expires=1511733180, 321 srisig; 322 sig=*lGZVaJJM5f2oGczFlLmBdKTDL+QADza4BgeO494ggACYJOvrof6uh5OJCcwKrk7DK+LBch0jssDYPp5CLc1SDA 323 integrity="mi"; 324 validityUrl="https://example.com/resource.validity.1511128380"; 325 ed25519Key=*zsSevyFsxyZHiUluVBDd4eypdRLTqyWRVOJuuKUz+A8 326 date=1511128380; expires=1511733180, 327 thirdpartysig; 328 sig=*MEYCIQCNxJzn6Rh2fNxsobktir8TkiaJYQFhWTuWI1i4PewQaQIhAMs2TVjc4rTshDtXbgQEOwgj2mRXALhfXPztXgPupii+; 329 integrity="mi"; 330 validityUrl="https://thirdparty.example.com/resource.validity.1511161860"; 331 certUrl="https://thirdparty.example.com/certs"; 332 certSha256=*UeOwUPkvxlGRTyvHcsMUN0A2oNsZbU8EUvg8A9ZAnNc; 333 date=1511133060; expires=1511478660, 335 There are 4 signatures: 2 from different secp256r1 certificates 336 within "https://example.com/", one using a raw ed25519 public key 337 that's also controlled by "example.com", and a fourth using a 338 secp256r1 certificate owned by "thirdparty.example.com". 340 All 4 signatures rely on the "MI" response header to guard the 341 integrity of the response payload. This isn't strictly required-- 342 some signatures could use "MI" while others use "Digest"--but there's 343 not much benefit to mixing them. 345 The signatures include a "validityUrl" that includes the first time 346 the resource was seen. This allows multiple versions of a resource 347 at the same URL to be updated with new signatures, which allows 348 clients to avoid transferring extra data while the old versions don't 349 have known security bugs. 351 The certificates at "https://example.com/oldcerts" and 352 "https://example.com/newcerts" have "subjectAltName"s of 353 "example.com", meaning that if they and their signatures validate, 354 the exchange can be trusted as having an origin of 355 "https://example.com/". The author might be using two certificates 356 because their readers have disjoint sets of roots in their trust 357 stores. 359 The author signed with all three certificates at the same time, so 360 they share a validity range: 7 days starting at 2017-11-19 21:53 UTC. 362 The author then requested an additional signature from 363 "thirdparty.example.com", which did some validation or processing and 364 then signed the resource at 2017-11-19 23:11 UTC. 365 "thirdparty.example.com" only grants 4-day signatures, so clients 366 will need to re-validate more often. 368 3.2.2. Open Questions 370 [I-D.ietf-httpbis-header-structure] provides a way to parameterise 371 labels but not other supported types like binary content. If the 372 "Signature" header field is notionally a list of parameterised 373 signatures, maybe we should add a "parameterised binary content" 374 type. 376 Should the certUrl and validityUrl be lists so that intermediates can 377 offer a cache without losing the original URLs? Putting lists in 378 dictionary fields is more complex than 379 [I-D.ietf-httpbis-header-structure] allows, so they're single items 380 for now. 382 3.3. Significant headers of an exchange 384 The significant headers of an exchange are: 386 o The method (Section 4 of [RFC7231]) and effective request URI 387 (Section 5.5 of [RFC7230]) of the request. 389 o The response status code (Section 6 of [RFC7231]) and the response 390 header fields whose names are listed in that exchange's "Signed- 391 Headers" header field (Section 3.1), in the order they appear in 392 that header field. If a response header field name from "Signed- 393 Headers" does not appear in the exchange's response header fields, 394 the exchange has no significant headers. 396 If the exchange's "Signed-Headers" header field is not present, 397 doesn't parse as a Structured Header 398 ([I-D.ietf-httpbis-header-structure]) or doesn't follow the 399 constraints on its value described in Section 3.1, the exchange has 400 no significant headers. 402 3.3.1. Open Questions 404 Do the significant headers of an exchange need to include the 405 "Signed-Headers" header field itself? 407 3.4. CBOR representation of exchange headers 409 To sign an exchange's headers, they need to be serialized into a byte 410 string. Since intermediaries and distributors (Appendix A.2) might 411 rearrange, add, or just reserialize headers, we can't use the literal 412 bytes of the headers as this serialization. Instead, this section 413 defines a CBOR representation that can be embedded into other CBOR, 414 canonically serialized (Section 3.5), and then signed. 416 The CBOR representation of an exchange "exchange"'s headers is the 417 CBOR ([RFC7049]) array with the following content: 419 1. The map mapping: 421 * The byte string ':method' to the byte string containing 422 "exchange"'s request's method. 424 * The byte string ':url' to the byte string containing 425 "exchange"'s request's effective request URI. 427 2. The map mapping: 429 * the byte string ':status' to the byte string containing 430 "exchange"'s response's 3-digit status code, and 432 * for each response header field in "exchange", the header 433 field's name as a byte string to the header field's value as a 434 byte string. 436 3.4.1. Example 438 Given the HTTP exchange: 440 GET https://example.com/ HTTP/1.1 441 Accept: */* 443 HTTP/1.1 200 444 Content-Type: text/html 445 Digest: SHA-256=20addcf7368837f616d549f035bf6784ea6d4bf4817a3736cd2fc7a763897fe3 446 Signed-Headers: "content-type", "digest" 448 449 450 ... 452 The cbor representation consists of the following item, represented 453 using the extended diagnostic notation from [I-D.ietf-cbor-cddl] 454 appendix G: 456 [ 457 { 458 ':url': 'https://example.com/' 459 ':method': 'GET', 460 }, 461 { 462 'digest': 'SHA-256=20addcf7368837f616d549f035bf6784ea6d4bf4817a3736cd2fc7a763897fe3', 463 ':status': '200', 464 'content-type': 'text/html' 465 } 466 ] 468 3.5. Canonical CBOR serialization 470 Within this specification, the canonical serialization of a CBOR item 471 uses the following rules derived from Section 3.9 of [RFC7049] with 472 erratum 4964 applied: 474 o Integers and the lengths of arrays, maps, and strings MUST use the 475 smallest possible encoding. 477 o Items MUST NOT be encoded with indefinite length. 479 o The keys in every map MUST be sorted in the bytewise lexicographic 480 order of their canonical encodings. For example, the following 481 keys are correctly sorted: 483 1. 10, encoded as 0A. 485 2. 100, encoded as 18 64. 487 3. -1, encoded as 20. 489 4. "z", encoded as 61 7A. 491 5. "aa", encoded as 62 61 61. 493 6. [100], encoded as 81 18 64. 495 7. [-1], encoded as 81 20. 497 8. false, encoded as F4. 499 Note: this specification does not use floating point, tags, or other 500 more complex data types, so it doesn't need rules to canonicalize 501 those. 503 3.6. Signature validity 505 The client MUST parse the "Signature" header field as the list of 506 parameterised values (Section 4.8.1 of 507 [I-D.ietf-httpbis-header-structure]) described in Section 3.2. If an 508 error is thrown during this parsing or any of the requirements 509 described there aren't satisfied, the exchange has no valid 510 signatures. Otherwise, each member of this list represents a 511 signature with parameters. 513 The client MUST use the following algorithm to determine whether each 514 signature with parameters is invalid or potentially-valid. 515 Potentially-valid results include: 517 o The signed headers of the exchange so that higher-level protocols 518 can avoid relying on unsigned headers, and 520 o Either a certificate chain or a public key so that a higher-level 521 protocol can determine whether it's actually valid. 523 This algorithm accepts a "forceFetch" flag that avoids the cache when 524 fetching URLs. A client that determines that a potentially-valid 525 certificate chain is actually invalid due to an expired OCSP response 526 MAY retry with "forceFetch" set to retrieve an updated OCSP from the 527 original server. 529 This algorithm also accepts an "allResponseHeaders" flag, which 530 insists that there are no non-significant response header fields in 531 the exchange. 533 1. Let "originalExchange" be the signature's exchange. 535 2. Let "headers" be the significant headers (Section 3.3) of 536 "originalExchange". If "originalExchange" has no significant 537 headers, then return "invalid". 539 3. Let "payload" be the payload body (Section 3.3 of [RFC7230]) of 540 "originalExchange". Note that the payload body is the message 541 body with any transfer encodings removed. 543 4. If "allResponseHeaders" is set and the response header fields in 544 "originalExchange" are not equal to the response header fields 545 in "headers", then return "invalid". 547 5. Let: 549 * "signature" be the signature (binary content in the 550 parameterised label's "sig" parameter). 552 * "integrity" be the signature's "integrity" parameter. 554 * "validityUrl" be the signature's "validityUrl" parameter. 556 * "certUrl" be the signature's "certUrl" parameter, if any. 558 * "certSha256" be the signature's "certSha256" parameter, if 559 any. 561 * "ed25519Key" be the signature's "ed25519Key" parameter, if 562 any. 564 * "date" be the signature's "date" parameter, interpreted as a 565 Unix time. 567 * "expires" be the signature's "expires" parameter, interpreted 568 as a Unix time. 570 6. If "integrity" names a header field that is not present in 571 "headers" or which the client cannot use to check the integrity 572 of "payload" (for example, the header field is new and hasn't 573 been implemented yet), then return "invalid". Clients MUST 574 implement at least the "Digest" ([RFC3230]) and "MI" 575 ([I-D.thomson-http-mice]) header fields. 577 7. If "integrity" is "digest", and the "Digest" header field in 578 "headers" contains no digest-algorithms 579 (https://www.iana.org/assignments/http-dig-alg/http-dig- 580 alg.xhtml [6]) stronger than "SHA", then return "invalid". 582 8. Set "publicKey" and "signing-alg" depending on which key fields 583 are present: 585 1. If "certUrl" is present: 587 1. Let "certificate-chain" be the result of fetching 588 ([FETCH]) "certUrl" and parsing it as a TLS 1.3 589 Certificate message (Section 4.4.2 of 590 [I-D.ietf-tls-tls13]) containing X.509v3 certificates. 591 If "forceFetch" is _not_ set, the fetch can be fulfilled 592 from a cache using normal HTTP semantics [RFC7234]. If 593 this fetch or parse fails, return "invalid". 595 Parsing notes: 1. This does not include the 4-byte 596 header that would appear in a Handshake message. 1. 597 Since this fetch is not in response to a 598 CertificateRequest, the certificate_request_context MUST 599 be empty, and a non-empty value MUST cause the parse to 600 fail. 602 2. Let "main-certificate" be the first certificate in 603 "certificate-chain". 605 3. If the SHA-256 hash of "main-certificate"'s "cert_data" 606 is not equal to "certSha256", return "invalid". Note 607 that this intentionally differs from TLS 1.3, which 608 signs the entire certificate chain in its Certificate 609 Verify (Section 4.4.3 of [I-D.ietf-tls-tls13]), in order 610 to allow updating the stapled OCSP response without 611 updating signatures at the same time. 613 4. Set "publicKey" to "main-certificate"'s public key 615 5. The client MUST define a partial function from public 616 key types to signing algorithms, and this function must 617 at the minimum include the following mappings: 619 RSA, 2048 bits: rsa_pss_sha256 as defined in 620 Section 4.2.3 of [I-D.ietf-tls-tls13]. 622 EC, with the secp256r1 curve: ecdsa_secp256r1_sha256 as 623 defined in Section 4.2.3 of [I-D.ietf-tls-tls13]. 625 EC, with the secp384r1 curve: ecdsa_secp384r1_sha384 as 626 defined in Section 4.2.3 of [I-D.ietf-tls-tls13]. 628 Set "signing-alg" to the result of applying this 629 function to type of "main-certificate"'s public key. If 630 the function is undefined on this input, return 631 "invalid". 633 2. If "ed25519Key" is present, set "publicKey" to "ed25519Key" 634 and "signing-alg" to ed25519, as defined by [RFC8032] 636 9. If "expires" is more than 7 days (604800 seconds) after "date", 637 return "invalid". 639 10. If the current time is before "date" or after "expires", return 640 "invalid". 642 11. Let "message" be the concatenation of the following byte 643 strings. This matches the [I-D.ietf-tls-tls13] format to avoid 644 cross-protocol attacks when TLS certificates are used to sign 645 manifests. 647 1. A string that consists of octet 32 (0x20) repeated 64 times. 649 2. A context string: the ASCII encoding of "HTTP Exchange". 651 3. A single 0 byte which serves as a separator. 653 4. The bytes of the canonical CBOR serialization (Section 3.5) 654 of a CBOR map mapping: 656 1. If "certSha256" is set: 658 1. The text string "certSha256" to the byte string 659 value of "certSha256". 661 2. The text string "validityUrl" to the byte string value 662 of "validityUrl". 664 3. The text string "date" to the integer value of "date". 666 4. The text string "expires" to the integer value of 667 "expires". 669 5. The text string "headers" to the CBOR representation 670 (Section 3.4) of "exchange"'s headers. 672 12. If "signature" is "message"'s signature by "main-certificate"'s 673 public key using "signing-alg", return "potentially-valid" with 674 "exchange" and whichever is present of "certificate-chain" or 675 "ed25519Key". Otherwise, return "invalid". 677 Note that the above algorithm can determine that an exchange's 678 headers are potentially-valid before the exchange's payload is 679 received. Similarly, if "integrity" identifies a header field like 680 "MI" ([I-D.thomson-http-mice]) that can incrementally validate the 681 payload, early parts of the payload can be determined to be 682 potentially-valid before later parts of the payload. Higher-level 683 protocols MAY process parts of the exchange that have been determined 684 to be potentially-valid as soon as that determination is made but 685 MUST NOT process parts of the exchange that are not yet potentially- 686 valid. Similarly, as the higher-level protocol determines that parts 687 of the exchange are actually valid, the client MAY process those 688 parts of the exchange and MUST wait to process other parts of the 689 exchange until they too are determined to be valid. 691 3.6.1. Open Questions 693 Should we ban RSA keys to avoid their vulnerability to Bleichenbacher 694 attacks? 696 3.7. Updating signature validity 698 Both OCSP responses and signatures are designed to expire a short 699 time after they're signed, so that revoked certificates and signed 700 exchanges with known vulnerabilities are distrusted promptly. 702 This specification provides no way to update OCSP responses by 703 themselves. Instead, clients need to re-fetch the "certUrl" 704 (Section 3.6, Paragraph 4) to get a chain including a newer OCSP 705 response. 707 The "validityUrl" parameter (Paragraph 6) of the signatures provides 708 a way to fetch new signatures or learn where to fetch a complete 709 updated exchange. 711 Each version of a signed exchange SHOULD have its own validity URLs, 712 since each version needs different signatures and becomes obsolete at 713 different times. 715 The resource at a "validityUrl" is "validity data", a CBOR map 716 matching the following CDDL ([I-D.ietf-cbor-cddl]): 718 validity = { 719 ? signatures: [ + bytes ] 720 ? update: { 721 ? size: uint, 722 } 723 ] 725 The elements of the "signatures" array are parameterised labels 726 (Section 4.4 of [I-D.ietf-httpbis-header-structure]) meant to replace 727 the signatures within the "Signature" header field pointing to this 728 validity data. If the signed exchange contains a bug severe enough 729 that clients need to stop using the content, the "signatures" array 730 MUST NOT be present. 732 If the the "update" map is present, that indicates that a new version 733 of the signed exchange is available at its effective request URI 734 (Section 5.5 of [RFC7230]) and can give an estimate of the size of 735 the updated exchange ("update.size"). If the signed exchange is 736 currently the most recent version, the "update" SHOULD NOT be 737 present. 739 If both the "signatures" and "update" fields are present, clients can 740 use the estimated size to decide whether to update the whole resource 741 or just its signatures. 743 3.7.1. Examples 745 For example, say a signed exchange whose URL is "https://example.com/ 746 resource" has the following "Signature" header field (with line 747 breaks included and irrelevant fields omitted for ease of reading). 749 Signature: 750 sig1; 751 sig=*MEUCIQ...; 752 ... 753 validityUrl="https://example.com/resource.validity.1511157180"; 754 certUrl="https://example.com/oldcerts"; 755 date=1511128380; expires=1511733180, 756 sig2; 757 sig=*MEQCIG...; 758 ... 759 validityUrl="https://example.com/resource.validity.1511157180"; 760 certUrl="https://example.com/newcerts"; 761 date=1511128380; expires=1511733180, 762 thirdpartysig; 763 sig=*MEYCIQ...; 764 ... 765 validityUrl="https://thirdparty.example.com/resource.validity.1511161860"; 766 certUrl="https://thirdparty.example.com/certs"; 767 date=1511478660; expires=1511824260 769 At 2017-11-27 11:02 UTC, "sig1" and "sig2" have expired, but 770 "thirdpartysig" doesn't exipire until 23:11 that night, so the client 771 needs to fetch "https://example.com/resource.validity.1511157180" 772 (the "validityUrl" of "sig1" and "sig2") to update those signatures. 773 This URL might contain: 775 { 776 "signatures": [ 777 'sig1; ' 778 'sig=*MEQCIC/I9Q+7BZFP6cSDsWx43pBAL0ujTbON/+7RwKVk+ba5AiB3FSFLZqpzmDJ0NumNwN04pqgJZE99fcK86UjkPbj4jw; ' 779 'validityUrl="https://example.com/resource.validity.1511157180"; ' 780 'integrity="mi"; ' 781 'certUrl="https://example.com/newcerts"; ' 782 'certSha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw; ' 783 'date=1511733180; expires=1512337980' 784 ], 785 "update": { 786 "size": 5557452 787 } 788 } 790 This indicates that the client could fetch a newer version at 791 "https://example.com/resource" (the original URL of the exchange), or 792 that the validity period of the old version can be extended by 793 replacing the first two of the original signatures (the ones with a 794 validityUrl of "https://example.com/resource.validity.1511157180") 795 with the single new signature provided. (This might happen at the 796 end of a migration to a new root certificate.) The signatures of the 797 updated signed exchange would be: 799 Signature: 800 sig1; 801 sig=*MEQCIC...; 802 ... 803 validityUrl="https://example.com/resource.validity.1511157180"; 804 certUrl="https://example.com/newcerts"; 805 date=1511733180; expires=1512337980, 806 thirdpartysig; 807 sig=*MEYCIQ...; 808 ... 809 validityUrl="https://thirdparty.example.com/resource.validity.1511161860"; 810 certUrl="https://thirdparty.example.com/certs"; 811 date=1511478660; expires=1511824260 813 "https://example.com/resource.validity.1511157180" could also expand 814 the set of signatures if its "signatures" array contained more than 2 815 elements. 817 3.8. The Accept-Signature header 819 "Signature" header fields cost on the order of 300 bytes for ECDSA 820 signatures, so servers might prefer to avoid sending them to clients 821 that don't intend to use them. A client can send the "Accept- 822 Signature" header field to indicate that it does intend to take 823 advantage of any available signatures and to indicate what kinds of 824 signatures it supports. 826 When a server receives an "Accept-Signature" header field in a client 827 request, it SHOULD reply with any available "Signature" header fields 828 for its response that the "Accept-Signature" header field indicates 829 the client supports. However, if the "Accept-Signature" value 830 violates a requirement in this section, the server MUST behave as if 831 it hadn't received any "Accept-Signature" header at all. 833 The "Accept-Signature" header field is a Structured Header as defined 834 by [I-D.ietf-httpbis-header-structure]. Its value MUST be a list 835 (Section 4.8 of [I-D.ietf-httpbis-header-structure]) of parameterised 836 labels (Section 4.4 of [I-D.ietf-httpbis-header-structure]). The 837 order of labels in the "Accept-Signature" list is not significant. 838 Labels, ignoring any initial "-" character, MUST NOT be duplicated. 840 Each label in the "Accept-Signature" header field's value indicates 841 that a feature of the "Signature" header field (Section 3.2) is 842 supported. If the label begins with a "-" character, it instead 843 indicates that the feature named by the rest of the label is not 844 supported. Unknown labels and parameters MUST be ignored because new 845 labels and new parameters on existing labels may be defined by future 846 specifications. 848 3.8.1. Integrity labels 850 Labels starting with "digest/" indicate that the client supports the 851 "Digest" header field ([RFC3230]) with the digest-algorithm from the 852 https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml [7] 853 registry named in lower-case by the rest of the label. For example, 854 "digest/sha-512" indicates support for the SHA-512 digest algorithm, 855 and "-digest/sha-256" indicates non-support for the SHA-256 digest 856 algorithm. 858 Labels starting with "mi/" indicate that the client supports the "MI" 859 header field ([I-D.thomson-http-mice]) with the parameter from the 860 HTTP MI Parameter Registry registry named in lower-case by the rest 861 of the label. For example, "mi/mi-blake2" indicates support for 862 Merkle integrity with the as-yet-unspecified mi-blake2 parameter, and 863 "-digest/mi-sha256" indicates non-support for Merkle integrity with 864 the mi-sha256 content encoding. 866 If the "Accept-Signature" header field is present, servers SHOULD 867 assume support for "digest/sha-256" and "mi/mi-sha256" unless the 868 header field states otherwise. 870 3.8.2. Key type labels 872 Labels starting with "rsa/" indicate that the client supports 873 certificates holding RSA public keys with a number of bits indicated 874 by the digits after the "/". 876 Labels starting with "ecdsa/" indicate that the client supports 877 certificates holding ECDSA public keys on the curve named in lower- 878 case by the rest of the label. 880 If the "Accept-Signature" header field is present, servers SHOULD 881 assume support for "rsa/2048", "ecdsa/secp256r1", and "ecdsa/ 882 secp384r1" unless the header field states otherwise. 884 3.8.3. Key value labels 886 The "ed25519key" label has parameters indicating the public keys that 887 will be used to validate the returned signature. Each parameter's 888 name is re-interpreted as binary content (Section 4.5 of 889 [I-D.ietf-httpbis-header-structure]) encoding a prefix of the public 890 key. For example, if the client will validate signatures using the 891 public key whose base64 encoding is 892 "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo", valid "Accept- 893 Signature" header fields include: 895 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo 896 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg 897 Accept-Signature: ..., ed25519key; *11qYAQ 898 Accept-Signature: ..., ed25519key; * 900 but not 902 Accept-Signature: ..., ed25519key; *11qYA 904 because 5 bytes isn't a valid length for encoded base64, and not 906 Accept-Signature: ..., ed25519key; 11qYAQ 908 because it doesn't start with the "*" that indicates binary content. 910 Note that "ed25519key; *" is an empty prefix, which matches all 911 public keys, so it's useful in subresource integrity (Appendix A.3) 912 cases like "" where the public 913 key isn't known until the matching "