idnits 2.17.1 draft-yasskin-http-origin-signed-responses-06.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 (July 08, 2019) is 1744 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 2158 -- Looks like a reference, but probably isn't: '2' on line 2160 -- Looks like a reference, but probably isn't: '3' on line 2162 -- Looks like a reference, but probably isn't: '4' on line 2164 -- Looks like a reference, but probably isn't: '5' on line 2166 -- Looks like a reference, but probably isn't: '100' on line 510 == Missing Reference: '-1' is mentioned on line 512, but not defined -- Looks like a reference, but probably isn't: '6' on line 2169 -- Looks like a reference, but probably isn't: '7' on line 2171 -- Looks like a reference, but probably isn't: '8' on line 2173 -- Looks like a reference, but probably isn't: '9' on line 2175 -- Looks like a reference, but probably isn't: '10' on line 2177 -- Looks like a reference, but probably isn't: '11' on line 2237 -- Looks like a reference, but probably isn't: '12' on line 2251 -- Looks like a reference, but probably isn't: '13' on line 2266 -- Looks like a reference, but probably isn't: '14' on line 2288 -- Looks like a reference, but probably isn't: '15' on line 2289 -- Looks like a reference, but probably isn't: '16' on line 2305 -- Looks like a reference, but probably isn't: '17' on line 2444 -- Looks like a reference, but probably isn't: '18' on line 2452 -- Possible downref: Non-RFC (?) normative reference: ref. 'FETCH' == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-header-structure-10 == 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 (-12) exists of draft-cavage-http-signatures-11 == Outdated reference: A later version (-19) exists of draft-ietf-httpbis-cache-04 == Outdated reference: A later version (-06) exists of draft-ietf-httpbis-http2-secondary-certs-04 == Outdated reference: A later version (-03) exists of draft-yasskin-httpbis-origin-signed-exchanges-impl-02 == Outdated reference: A later version (-02) exists of draft-yasskin-webpackage-use-cases-01 -- 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 (~~), 9 warnings (==), 28 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 July 08, 2019 5 Expires: January 9, 2020 7 Signed HTTP Exchanges 8 draft-yasskin-http-origin-signed-responses-06 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 January 9, 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 8. IANA considerations . . . . . . . . . . . . . . . . . . . . . 38 119 8.1. Signature Header Field Registration . . . . . . . . . . . 38 120 8.2. Accept-Signature Header Field Registration . . . . . . . 38 121 8.3. Signed-Headers Header Field Registration . . . . . . . . 39 122 8.4. HTTP/2 Settings . . . . . . . . . . . . . . . . . . . . . 39 123 8.5. HTTP/2 Error code . . . . . . . . . . . . . . . . . . . . 39 124 8.6. Internet Media Type application/signed-exchange . . . . . 39 125 8.7. Internet Media Type application/cert-chain+cbor . . . . . 41 126 8.8. The cansignhttpexchanges CAA Parameter . . . . . . . . . 42 127 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 42 128 9.1. Normative References . . . . . . . . . . . . . . . . . . 42 129 9.2. Informative References . . . . . . . . . . . . . . . . . 44 130 9.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 47 131 Appendix A. Use cases . . . . . . . . . . . . . . . . . . . . . 48 132 A.1. PUSHed subresources . . . . . . . . . . . . . . . . . . . 48 133 A.2. Explicit use of a content distributor for subresources . 48 134 A.3. Subresource Integrity . . . . . . . . . . . . . . . . . . 49 135 A.4. Binary Transparency . . . . . . . . . . . . . . . . . . . 49 136 A.5. Static Analysis . . . . . . . . . . . . . . . . . . . . . 50 137 A.6. Offline websites . . . . . . . . . . . . . . . . . . . . 50 138 Appendix B. Requirements . . . . . . . . . . . . . . . . . . . . 50 139 B.1. Proof of origin . . . . . . . . . . . . . . . . . . . . . 50 140 B.1.1. Certificate constraints . . . . . . . . . . . . . . . 50 141 B.1.2. Signature constraints . . . . . . . . . . . . . . . . 51 142 B.1.3. Retrieving the certificate . . . . . . . . . . . . . 51 143 B.2. How much to sign . . . . . . . . . . . . . . . . . . . . 52 144 B.2.1. Conveying the signed headers . . . . . . . . . . . . 52 146 B.3. Response lifespan . . . . . . . . . . . . . . . . . . . . 53 147 B.3.1. Certificate revocation . . . . . . . . . . . . . . . 53 148 B.3.2. Response downgrade attacks . . . . . . . . . . . . . 53 149 B.4. Low implementation complexity . . . . . . . . . . . . . . 54 150 B.4.1. Limited choices . . . . . . . . . . . . . . . . . . . 54 151 B.4.2. Bounded-buffering integrity checking . . . . . . . . 54 152 Appendix C. Determining validity using cache control . . . . . . 54 153 C.1. Example of updating cache control . . . . . . . . . . . . 55 154 C.2. Downsides of updating cache control . . . . . . . . . . . 56 155 Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 56 156 Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 59 157 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 59 159 1. Introduction 161 Signed HTTP exchanges provide a way to prove the authenticity of a 162 resource in cases where the transport layer isn't sufficient. This 163 can be used in several ways: 165 o When signed by a certificate ([RFC5280]) that's trusted for an 166 origin, an exchange can be treated as authoritative for that 167 origin, even if it was transferred over a connection that isn't 168 authoritative (Section 9.1 of [RFC7230]) for that origin. See 169 Appendix A.1 and Appendix A.2. 171 o A top-level resource can use a public key to identify an expected 172 publisher for particular subresources, a system known as 173 Subresource Integrity ([SRI]). An exchange's signature provides 174 the matching proof of authorship. See Appendix A.3. 176 o A signature can vouch for the exchange in some way, for example 177 that it appears in a transparency log or that static analysis 178 indicates that it omits certain attacks. See Appendix A.4 and 179 Appendix A.5. 181 Subsequent work toward the use cases in 182 [I-D.yasskin-webpackage-use-cases] will provide a way to group signed 183 exchanges into bundles that can be transmitted and stored together, 184 but single signed exchanges are useful enough to standardize on their 185 own. 187 2. Terminology 189 Absolute URL A string for which the URL parser [3] ([URL]), when run 190 without a base URL, returns a URL rather than a failure, and for 191 which that URL has a null fragment. This is similar to the 192 absolute-URL string [4] concept defined by ([URL]) but might not 193 include exactly the same strings. 195 Author The entity that wrote the content in a particular resource. 196 This specification deals with publishers rather than authors. 198 Publisher The entity that controls the server for a particular 199 origin [RFC6454]. The publisher can get a CA to issue 200 certificates for their private keys and can run a TLS server for 201 their origin. 203 Exchange (noun) An HTTP request URL, content negotiation 204 information, and an HTTP response. This can be encoded into a 205 request message from a client with its matching response from a 206 server, into the request in a PUSH_PROMISE with its matching 207 response stream, or into the dedicated format in Section 5.3, 208 which uses [I-D.ietf-httpbis-variants] to encode the content 209 negotiation information. This is not quite the same meaning as 210 defined by Section 8 of [RFC7540], which assumes the content 211 negotiation information is embedded into HTTP request headers. 213 Intermediate An entity that fetches signed HTTP exchanges from a 214 publisher or another intermediate and forwards them to another 215 intermediate or a client. 217 Client An entity that uses a signed HTTP exchange and needs to be 218 able to prove that the publisher vouched for it as coming from its 219 claimed origin. 221 Unix time Defined by [POSIX] section 4.16 [5]. 223 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 224 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 225 "OPTIONAL" in this document are to be interpreted as described in BCP 226 14 [RFC2119] [RFC8174] when, and only when, they appear in all 227 capitals, as shown here. 229 3. Signing an exchange 231 In the response of an HTTP exchange the server MAY include a 232 "Signature" header field (Section 3.1) holding a list of one or more 233 parameterised signatures that vouch for the content of the exchange. 234 Exactly which content the signature vouches for can depend on how the 235 exchange is transferred (Section 5). 237 The client categorizes each signature as "valid" or "invalid" by 238 validating that signature with its certificate or public key and 239 other metadata against the exchange's URL, response headers, and 240 content (Section 3.5). This validity then informs higher-level 241 protocols. 243 Each signature is parameterised with information to let a client 244 fetch assurance that a signed exchange is still valid, in the face of 245 revoked certificates and newly-discovered vulnerabilities. This 246 assurance can be bundled back into the signed exchange and forwarded 247 to another client, which won't have to re-fetch this validity 248 information for some period of time. 250 3.1. The Signature Header 252 The "Signature" header field conveys a list of signatures for an 253 exchange, each one accompanied by information about how to determine 254 the authority of and refresh that signature. Each signature directly 255 signs the exchange's URL and response headers and identifies one of 256 those headers that enforces the integrity of the exchange's payload. 258 The "Signature" header is a Structured Header as defined by 259 [I-D.ietf-httpbis-header-structure]. Its value MUST be a 260 parameterised list (Section 3.4 of 261 [I-D.ietf-httpbis-header-structure]). Its ABNF is: 263 Signature = sh-param-list 265 Each parameterised identifier in the list MUST have parameters named 266 "sig", "integrity", "validity-url", "date", and "expires". Each 267 parameterised identifier MUST also have either "cert-url" and "cert- 268 sha256" parameters or an "ed25519key" parameter. This specification 269 gives no meaning to the identifier itself, which can be used as a 270 human-readable identifier for the signature (however, this is likely 271 to change soon; see Section 3.1.2, Paragraph 1). The present 272 parameters MUST have the following values: 274 "sig" Byte sequence (Section 3.10 of 275 [I-D.ietf-httpbis-header-structure]) holding the signature of most 276 of these parameters and the exchange's URL and response headers. 278 "integrity" A string (Section 3.8 of 279 [I-D.ietf-httpbis-header-structure]) containing a "/"-separated 280 sequence of names starting with the lowercase name of the response 281 header field that guards the response payload's integrity. The 282 meaning of subsequent names depends on the response header field, 283 but for the "digest" header field, the single following name is 284 the name of the digest algorithm that guards the payload's 285 integrity. 287 "cert-url" A string (Section 3.8 of 288 [I-D.ietf-httpbis-header-structure]) containing an absolute URL 289 (Section 2) with a scheme of "https" or "data". 291 "cert-sha256" Byte sequence (Section 3.10 of 292 [I-D.ietf-httpbis-header-structure]) holding the SHA-256 hash of 293 the first certificate found at "cert-url". 295 "ed25519key" Byte sequence (Section 3.10 of 296 [I-D.ietf-httpbis-header-structure]) holding an Ed25519 public key 297 ([RFC8032]). 299 "validity-url" A string (Section 3.8 of 300 [I-D.ietf-httpbis-header-structure]) containing an absolute URL 301 (Section 2) with a scheme of "https". 303 "date" and "expires" An integer (Section 3.6 of 304 [I-D.ietf-httpbis-header-structure]) representing a Unix time. 306 The "cert-url" parameter is _not_ signed, so intermediates can update 307 it with a pointer to a cached version. 309 3.1.1. Examples 311 The following header is included in the response for an exchange with 312 effective request URI "https://example.com/resource.html". Newlines 313 are added for readability. 315 Signature: 316 sig1; 317 sig=*MEUCIQDXlI2gN3RNBlgFiuRNFpZXcDIaUpX6HIEwcZEc0cZYLAIga9DsVOMM+g5YpwEBdGW3sS+bvnmAJJiSMwhuBdqp5UY=*; 318 integrity="digest/mi-sha256"; 319 validity-url="https://example.com/resource.validity.1511128380"; 320 cert-url="https://example.com/oldcerts"; 321 cert-sha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI=*; 322 date=1511128380; expires=1511733180, 323 sig2; 324 sig=*MEQCIGjZRqTRf9iKNkGFyzRMTFgwf/BrY2ZNIP/dykhUV0aYAiBTXg+8wujoT4n/W+cNgb7pGqQvIUGYZ8u8HZJ5YH26Qg=*; 325 integrity="digest/mi-sha256"; 326 validity-url="https://example.com/resource.validity.1511128380"; 327 cert-url="https://example.com/newcerts"; 328 cert-sha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw=*; 329 date=1511128380; expires=1511733180, 330 srisig; 331 sig=*lGZVaJJM5f2oGczFlLmBdKTDL+QADza4BgeO494ggACYJOvrof6uh5OJCcwKrk7DK+LBch0jssDYPp5CLc1SDA=* 332 integrity="digest/mi-sha256"; 333 validity-url="https://example.com/resource.validity.1511128380"; 334 ed25519key=*zsSevyFsxyZHiUluVBDd4eypdRLTqyWRVOJuuKUz+A8=* 335 date=1511128380; expires=1511733180, 336 thirdpartysig; 337 sig=*MEYCIQCNxJzn6Rh2fNxsobktir8TkiaJYQFhWTuWI1i4PewQaQIhAMs2TVjc4rTshDtXbgQEOwgj2mRXALhfXPztXgPupii+=*; 338 integrity="digest/mi-sha256"; 339 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 340 cert-url="https://thirdparty.example.com/certs"; 341 cert-sha256=*UeOwUPkvxlGRTyvHcsMUN0A2oNsZbU8EUvg8A9ZAnNc=*; 342 date=1511133060; expires=1511478660, 344 There are 4 signatures: 2 from different secp256r1 certificates 345 within "https://example.com/", one using a raw ed25519 public key 346 that's also controlled by "example.com", and a fourth using a 347 secp256r1 certificate owned by "thirdparty.example.com". 349 All 4 signatures rely on the "Digest" response header with the mi- 350 sha256 digest algorithm to guard the integrity of the response 351 payload. 353 The signatures include a "validity-url" that includes the first time 354 the resource was seen. This allows multiple versions of a resource 355 at the same URL to be updated with new signatures, which allows 356 clients to avoid transferring extra data while the old versions don't 357 have known security bugs. 359 The certificates at "https://example.com/oldcerts" and 360 "https://example.com/newcerts" have "subjectAltName"s of 361 "example.com", meaning that if they and their signatures validate, 362 the exchange can be trusted as having an origin of 363 "https://example.com/". The publisher might be using two 364 certificates because their readers have disjoint sets of roots in 365 their trust stores. 367 The publisher signed with all three certificates at the same time, so 368 they share a validity range: 7 days starting at 2017-11-19 21:53 UTC. 370 The publisher then requested an additional signature from 371 "thirdparty.example.com", which did some validation or processing and 372 then signed the resource at 2017-11-19 23:11 UTC. 373 "thirdparty.example.com" only grants 4-day signatures, so clients 374 will need to re-validate more often. 376 3.1.2. Open Questions 378 The next revision of [I-D.ietf-httpbis-header-structure] will provide 379 a way to parameterise byte sequences, at which point the signature 380 itself is likely to become the main list item. 382 Should the cert-url and validity-url be lists so that intermediates 383 can offer a cache without losing the original URLs? Putting lists in 384 dictionary fields is more complex than 385 [I-D.ietf-httpbis-header-structure] allows, so they're single items 386 for now. 388 3.2. CBOR representation of exchange response headers 390 To sign an exchange's response headers, they need to be serialized 391 into a byte string. Since intermediaries and distributors 392 (Appendix A.2) might rearrange, add, or just reserialize headers, we 393 can't use the literal bytes of the headers as this serialization. 394 Instead, this section defines a CBOR representation that can be 395 embedded into other CBOR, canonically serialized (Section 3.4), and 396 then signed. 398 The CBOR representation of a set of response metadata and headers is 399 the CBOR ([RFC7049]) map with the following mappings: 401 o The byte string ':status' to the byte string containing the 402 response's 3-digit status code, and 404 o For each response header field, the header field's lowercase name 405 as a byte string to the header field's value as a byte string. 407 3.2.1. Example 409 Given the HTTP exchange: 411 GET / HTTP/1.1 412 Host: example.com 413 Accept: */* 415 HTTP/1.1 200 416 Content-Type: text/html 417 Digest: mi-sha256=dcRDgR2GM35DluAV13PzgnG6+pvQwPywfFvAu1UeFrs= 418 Signed-Headers: "content-type", "digest" 420 421 422 ... 424 The cbor representation consists of the following item, represented 425 using the extended diagnostic notation from [CDDL] appendix G: 427 { 428 'digest': 'mi-sha256=dcRDgR2GM35DluAV13PzgnG6+pvQwPywfFvAu1UeFrs=', 429 ':status': '200', 430 'content-type': 'text/html' 431 } 433 3.3. Loading a certificate chain 435 The resource at a signature's "cert-url" MUST have the "application/ 436 cert-chain+cbor" content type, MUST be canonically-encoded CBOR 437 (Section 3.4), and MUST match the following CDDL: 439 cert-chain = [ 440 "📜⛓", ; U+1F4DC U+26D3 441 + augmented-certificate 442 ] 443 augmented-certificate = { 444 cert: bytes, 445 ? ocsp: bytes, 446 ? sct: bytes, 447 * tstr => any, 448 } 450 The first map (second item) in the CBOR array is treated as the end- 451 entity certificate, and the client will attempt to build a path 452 ([RFC5280]) to it from a trusted root using the other certificates in 453 the chain. 455 1. Each "cert" value MUST be a DER-encoded X.509v3 certificate 456 ([RFC5280]). Other key/value pairs in the same array item define 457 properties of this certificate. 459 2. The first certificate's "ocsp" value MUST be a complete, DER- 460 encoded OCSP response for that certificate (using the ASN.1 type 461 "OCSPResponse" defined in [RFC6960]). Subsequent certificates 462 MUST NOT have an "ocsp" value. 464 3. Each certificate's "sct" value if any MUST be a 465 "SignedCertificateTimestampList" for that certificate as defined 466 by Section 3.3 of [RFC6962]. 468 Loading a "cert-url" takes a "forceFetch" flag. The client MUST: 470 1. Let "raw-chain" be the result of fetching ([FETCH]) "cert-url". 471 If "forceFetch" is _not_ set, the fetch can be fulfilled from a 472 cache using normal HTTP semantics [RFC7234]. If this fetch 473 fails, return "invalid". 475 2. Let "certificate-chain" be the array of certificates and 476 properties produced by parsing "raw-chain" using the CDDL above. 477 If any of the requirements above aren't satisfied, return 478 "invalid". Note that this validation requirement might be 479 impractical to completely achieve due to certificate validation 480 implementations that don't enforce DER encoding or other standard 481 constraints. 483 3. Return "certificate-chain". 485 3.4. Canonical CBOR serialization 487 Within this specification, the canonical serialization of a CBOR item 488 uses the following rules derived from Section 3.9 of [RFC7049] with 489 erratum 4964 applied: 491 o Integers and the lengths of arrays, maps, and strings MUST use the 492 smallest possible encoding. 494 o Items MUST NOT be encoded with indefinite length. 496 o The keys in every map MUST be sorted in the bytewise lexicographic 497 order of their canonical encodings. For example, the following 498 keys are correctly sorted: 500 1. 10, encoded as 0A. 502 2. 100, encoded as 18 64. 504 3. -1, encoded as 20. 506 4. "z", encoded as 61 7A. 508 5. "aa", encoded as 62 61 61. 510 6. [100], encoded as 81 18 64. 512 7. [-1], encoded as 81 20. 514 8. false, encoded as F4. 516 Note: this specification does not use floating point, tags, or other 517 more complex data types, so it doesn't need rules to canonicalize 518 those. 520 3.5. Signature validity 522 The client MUST parse the "Signature" header field as the 523 parameterised list (Section 4.2.5 of 524 [I-D.ietf-httpbis-header-structure]) described in Section 3.1. If an 525 error is thrown during this parsing or any of the requirements 526 described there aren't satisfied, the exchange has no valid 527 signatures. Otherwise, each member of this list represents a 528 signature with parameters. 530 The client MUST use the following algorithm to determine whether each 531 signature with parameters is invalid or potentially-valid for an 532 exchange's 534 o "requestUrl", a byte sequence that can be parsed into the 535 exchange's effective request URI (Section 5.5 of [RFC7230]), 537 o "responseHeaders", a byte sequence holding the canonical 538 serialization (Section 3.4) of the CBOR representation 539 (Section 3.2) of the exchange's response metadata and headers, and 541 o "payload", a stream of bytes constituting the exchange's payload 542 body (Section 3.3 of [RFC7230]). Note that the payload body is 543 the message body with any transfer encodings removed. 545 Potentially-valid results include: 547 o The signed headers of the exchange so that higher-level protocols 548 can avoid relying on unsigned headers, and 550 o Either a certificate chain or a public key so that a higher-level 551 protocol can determine whether it's actually valid. 553 This algorithm accepts a "forceFetch" flag that avoids the cache when 554 fetching URLs. A client that determines that a potentially-valid 555 certificate chain is actually invalid due to an expired OCSP response 556 MAY retry with "forceFetch" set to retrieve an updated OCSP from the 557 original server. 559 1. Let: 561 * "signature" be the signature (byte sequence in the 562 parameterised identifier's "sig" parameter). 564 * "integrity" be the signature's "integrity" parameter. 566 * "validity-url" be the signature's "validity-url" parameter. 568 * "cert-url" be the signature's "cert-url" parameter, if any. 570 * "cert-sha256" be the signature's "cert-sha256" parameter, if 571 any. 573 * "ed25519key" be the signature's "ed25519key" parameter, if 574 any. 576 * "date" be the signature's "date" parameter, interpreted as a 577 Unix time. 579 * "expires" be the signature's "expires" parameter, interpreted 580 as a Unix time. 582 2. Set "publicKey" and "signing-alg" depending on which key fields 583 are present: 585 1. If "cert-url" is present: 587 1. Let "certificate-chain" be the result of loading the 588 certificate chain at "cert-url" passing the "forceFetch" 589 flag (Section 3.3). If this returns "invalid", return 590 "invalid". 592 2. Let "main-certificate" be the first certificate in 593 "certificate-chain". 595 3. Set "publicKey" to "main-certificate"'s public key. 597 4. If "publicKey" is an RSA key, return "invalid". 599 5. If "publicKey" is a key using the secp256r1 elliptic 600 curve, set "signing-alg" to ecdsa_secp256r1_sha256 as 601 defined in Section 4.2.3 of [RFC8446]. 603 6. Otherwise, either return "invalid" or set "signing-alg" 604 to a non-legacy signing algorithm defined by TLS 1.3 or 605 later ([RFC8446]). This choice MUST depend only on 606 "publicKey"'s type and not on any other context. 608 2. If "ed25519key" is present, set "publicKey" to "ed25519key" 609 and "signing-alg" to ed25519, as defined by [RFC8032] 611 3. If "expires" is more than 7 days (604800 seconds) after "date", 612 return "invalid". 614 4. If the current time is before "date" or after "expires", return 615 "invalid". 617 5. Let "message" be the concatenation of the following byte 618 strings. This matches the [RFC8446] format to avoid cross- 619 protocol attacks if anyone uses the same key in a TLS 620 certificate and an exchange-signing certificate. 622 1. A string that consists of octet 32 (0x20) repeated 64 times. 624 2. A context string: the ASCII encoding of "HTTP Exchange 1". 626 Note: RFC EDITOR PLEASE DELETE THIS NOTE; The implementation 627 of the final RFC MUST use this context string, but 628 implementations of drafts MUST NOT use it and MUST use 629 another draft-specific string beginning with "HTTP Exchange 630 1 " instead. This ensures that signers can predict how 631 their signatures will be used. 633 3. A single 0 byte which serves as a separator. 635 4. If "cert-sha256" is set, a byte holding the value 32 636 followed by the 32 bytes of the value of "cert-sha256". 637 Otherwise a 0 byte. 639 5. The 8-byte big-endian encoding of the length in bytes of 640 "validity-url", followed by the bytes of "validity-url". 642 6. The 8-byte big-endian encoding of "date". 644 7. The 8-byte big-endian encoding of "expires". 646 8. The 8-byte big-endian encoding of the length in bytes of 647 "requestUrl", followed by the bytes of "requestUrl". 649 9. The 8-byte big-endian encoding of the length in bytes of 650 "responseHeaders", followed by the bytes of 651 "responseHeaders". 653 6. If "cert-url" is present and the SHA-256 hash of "main- 654 certificate"'s "cert_data" is not equal to "cert-sha256" (whose 655 presence was checked when the "Signature" header field was 656 parsed), return "invalid". 658 Note that this intentionally differs from TLS 1.3, which signs 659 the entire certificate chain in its Certificate Verify 660 (Section 4.4.3 of [RFC8446]), in order to allow updating the 661 stapled OCSP response without updating signatures at the same 662 time. 664 7. If "signature" is not a valid signature of "message" by 665 "publicKey" using "signing-alg", return "invalid". 667 8. If "headers", interpreted according to Section 3.2, does not 668 contain a "Content-Type" response header field (Section 3.1.1.5 669 of [RFC7231]), return "invalid". 671 Clients MUST interpret the signed payload as this specified 672 media type instead of trying to sniff a media type from the 673 bytes of the payload, for example by attaching an "X-Content- 674 Type-Options: nosniff" header field ([FETCH]) to the extracted 675 response. 677 9. If "integrity" names a header field and parameter that is not 678 present in "responseHeaders" or which the client cannot use to 679 check the integrity of "payload" (for example, the header field 680 is new and hasn't been implemented yet), then return "invalid". 681 If the selected header field provides integrity guarantees 682 weaker than SHA-256, return "invalid". If validating integrity 683 using the selected header field requires the client to process 684 records larger than 16384 bytes, return "invalid". Clients MUST 685 implement at least the "Digest" header field with its "mi- 686 sha256" digest algorithm (Section 3 of [I-D.thomson-http-mice]). 688 Note: RFC EDITOR PLEASE DELETE THIS NOTE; Implementations of 689 drafts of this RFC MUST recognize the draft spelling of the 690 content encoding and digest algorithm specified by 691 [I-D.thomson-http-mice] until that draft is published as an RFC. 692 For example, implementations of draft-thomson-http-mice-03 would 693 use "mi-sha256-03" and MUST NOT use "mi-sha256" itself. This 694 ensures that final implementations don't need to handle 695 compatibility with implementations of early drafts of that 696 content encoding. 698 If "payload" doesn't match the integrity information in the 699 header described by "integrity", return "invalid". 701 10. Return "potentially-valid" with whichever is present of 702 "certificate-chain" or "ed25519key". 704 Note that the above algorithm can determine that an exchange's 705 headers are potentially-valid before the exchange's payload is 706 received. Similarly, if "integrity" identifies a header field and 707 parameter like "Digest:mi-sha256" ([I-D.thomson-http-mice]) that can 708 incrementally validate the payload, early parts of the payload can be 709 determined to be potentially-valid before later parts of the payload. 710 Higher-level protocols MAY process parts of the exchange that have 711 been determined to be potentially-valid as soon as that determination 712 is made but MUST NOT process parts of the exchange that are not yet 713 potentially-valid. Similarly, as the higher-level protocol 714 determines that parts of the exchange are actually valid, the client 715 MAY process those parts of the exchange and MUST wait to process 716 other parts of the exchange until they too are determined to be 717 valid. 719 3.5.1. Open Questions 721 Should the signed message use the TLS format (with an initial 64 722 spaces) even though these certificates can't be used in TLS servers? 724 3.6. Updating signature validity 726 Both OCSP responses and signatures are designed to expire a short 727 time after they're signed, so that revoked certificates and signed 728 exchanges with known vulnerabilities are distrusted promptly. 730 This specification provides no way to update OCSP responses by 731 themselves. Instead, clients need to re-fetch the "cert-url" 732 (Section 3.5, Paragraph 6) to get a chain including a newer OCSP 733 response. 735 The "validity-url" parameter (Paragraph 6) of the signatures provides 736 a way to fetch new signatures or learn where to fetch a complete 737 updated exchange. 739 Each version of a signed exchange SHOULD have its own validity URLs, 740 since each version needs different signatures and becomes obsolete at 741 different times. 743 The resource at a "validity-url" is "validity data", a CBOR map 744 matching the following CDDL ([CDDL]): 746 validity = { 747 ? signatures: [ + bytes ] 748 ? update: { 749 ? size: uint, 750 } 751 ] 753 The elements of the "signatures" array are parameterised identifiers 754 (Section 4.2.6 of [I-D.ietf-httpbis-header-structure]) meant to 755 replace the signatures within the "Signature" header field pointing 756 to this validity data. If the signed exchange contains a bug severe 757 enough that clients need to stop using the content, the "signatures" 758 array MUST NOT be present. 760 If the the "update" map is present, that indicates that a new version 761 of the signed exchange is available at its effective request URI 762 (Section 5.5 of [RFC7230]) and can give an estimate of the size of 763 the updated exchange ("update.size"). If the signed exchange is 764 currently the most recent version, the "update" SHOULD NOT be 765 present. 767 If both the "signatures" and "update" fields are present, clients can 768 use the estimated size to decide whether to update the whole resource 769 or just its signatures. 771 3.6.1. Examples 773 For example, say a signed exchange whose URL is "https://example.com/ 774 resource" has the following "Signature" header field (with line 775 breaks included and irrelevant fields omitted for ease of reading). 777 Signature: 778 sig1; 779 sig=*MEUCIQ...*; 780 ... 781 validity-url="https://example.com/resource.validity.1511157180"; 782 cert-url="https://example.com/oldcerts"; 783 date=1511128380; expires=1511733180, 784 sig2; 785 sig=*MEQCIG...*; 786 ... 787 validity-url="https://example.com/resource.validity.1511157180"; 788 cert-url="https://example.com/newcerts"; 789 date=1511128380; expires=1511733180, 790 thirdpartysig; 791 sig=*MEYCIQ...*; 792 ... 793 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 794 cert-url="https://thirdparty.example.com/certs"; 795 date=1511478660; expires=1511824260 797 At 2017-11-27 11:02 UTC, "sig1" and "sig2" have expired, but 798 "thirdpartysig" doesn't exipire until 23:11 that night, so the client 799 needs to fetch "https://example.com/resource.validity.1511157180" 800 (the "validity-url" of "sig1" and "sig2") if it wishes to update 801 those signatures. This URL might contain: 803 { 804 "signatures": [ 805 'sig1; ' 806 'sig=*MEQCIC/I9Q+7BZFP6cSDsWx43pBAL0ujTbON/+7RwKVk+ba5AiB3FSFLZqpzmDJ0NumNwN04pqgJZE99fcK86UjkPbj4jw==*; ' 807 'validity-url="https://example.com/resource.validity.1511157180"; ' 808 'integrity="digest/mi-sha256"; ' 809 'cert-url="https://example.com/newcerts"; ' 810 'cert-sha256=*J/lEm9kNRODdCmINbvitpvdYKNQ+YgBj99DlYp4fEXw=*; ' 811 'date=1511733180; expires=1512337980' 812 ], 813 "update": { 814 "size": 5557452 815 } 816 } 818 This indicates that the client could fetch a newer version at 819 "https://example.com/resource" (the original URL of the exchange), or 820 that the validity period of the old version can be extended by 821 replacing the first two of the original signatures (the ones with a 822 validity-url of "https://example.com/resource.validity.1511157180") 823 with the single new signature provided. (This might happen at the 824 end of a migration to a new root certificate.) The signatures of the 825 updated signed exchange would be: 827 Signature: 828 sig1; 829 sig=*MEQCIC...*; 830 ... 831 validity-url="https://example.com/resource.validity.1511157180"; 832 cert-url="https://example.com/newcerts"; 833 date=1511733180; expires=1512337980, 834 thirdpartysig; 835 sig=*MEYCIQ...*; 836 ... 837 validity-url="https://thirdparty.example.com/resource.validity.1511161860"; 838 cert-url="https://thirdparty.example.com/certs"; 839 date=1511478660; expires=1511824260 841 "https://example.com/resource.validity.1511157180" could also expand 842 the set of signatures if its "signatures" array contained more than 2 843 elements. 845 3.7. The Accept-Signature header 847 "Signature" header fields cost on the order of 300 bytes for ECDSA 848 signatures, so servers might prefer to avoid sending them to clients 849 that don't intend to use them. A client can send the "Accept- 850 Signature" header field to indicate that it does intend to take 851 advantage of any available signatures and to indicate what kinds of 852 signatures it supports. 854 When a server receives an "Accept-Signature" header field in a client 855 request, it SHOULD reply with any available "Signature" header fields 856 for its response that the "Accept-Signature" header field indicates 857 the client supports. However, if the "Accept-Signature" value 858 violates a requirement in this section, the server MUST behave as if 859 it hadn't received any "Accept-Signature" header at all. 861 The "Accept-Signature" header field is a Structured Header as defined 862 by [I-D.ietf-httpbis-header-structure]. Its value MUST be a 863 parameterised list (Section 3.4 of 864 [I-D.ietf-httpbis-header-structure]). Its ABNF is: 866 Accept-Signature = sh-param-list 868 The order of identifiers in the "Accept-Signature" list is not 869 significant. Identifiers, ignoring any initial "-" character, MUST 870 NOT be duplicated. 872 Each identifier in the "Accept-Signature" header field's value 873 indicates that a feature of the "Signature" header field 874 (Section 3.1) is supported. If the identifier begins with a "-" 875 character, it instead indicates that the feature named by the rest of 876 the identifier is not supported. Unknown identifiers and parameters 877 MUST be ignored because new identifiers and new parameters on 878 existing identifiers may be defined by future specifications. 880 3.7.1. Integrity identifiers 882 Identifiers starting with "digest/" indicate that the client supports 883 the "Digest" header field ([RFC3230]) with the parameter from the 884 HTTP Digest Algorithm Values Registry [6] registry named in lower- 885 case by the rest of the identifier. For example, "digest/mi-blake2" 886 indicates support for Merkle integrity with the as-yet-unspecified 887 mi-blake2 parameter, and "-digest/mi-sha256" indicates non-support 888 for Merkle integrity with the mi-sha256 content encoding. 890 If the "Accept-Signature" header field is present, servers SHOULD 891 assume support for "digest/mi-sha256" unless the header field states 892 otherwise. 894 3.7.2. Key type identifiers 896 Identifiers starting with "ecdsa/" indicate that the client supports 897 certificates holding ECDSA public keys on the curve named in lower- 898 case by the rest of the identifier. 900 If the "Accept-Signature" header field is present, servers SHOULD 901 assume support for "ecdsa/secp256r1" unless the header field states 902 otherwise. 904 3.7.3. Key value identifiers 906 The "ed25519key" identifier has parameters indicating the public keys 907 that will be used to validate the returned signature. Each 908 parameter's name is re-interpreted as a byte sequence (Section 3.10 909 of [I-D.ietf-httpbis-header-structure]) encoding a prefix of the 910 public key. For example, if the client will validate signatures 911 using the public key whose base64 encoding is 912 "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=", valid "Accept- 913 Signature" header fields include: 915 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=* 916 Accept-Signature: ..., ed25519key; *11qYAYKxCrfVS/7TyWQHOg==* 917 Accept-Signature: ..., ed25519key; *11qYAQ==* 918 Accept-Signature: ..., ed25519key; ** 919 but not 921 Accept-Signature: ..., ed25519key; *11qYA===* 923 because 5 bytes isn't a valid length for encoded base64, and not 925 Accept-Signature: ..., ed25519key; 11qYAQ 927 because it doesn't start or end with the "*"s that indicate a byte 928 sequence. 930 Note that "ed25519key; **" is an empty prefix, which matches all 931 public keys, so it's useful in subresource integrity (Appendix A.3) 932 cases like "" where the public 933 key isn't known until the matching "