http | J. Yasskin |
Internet-Draft | |
Intended status: Standards Track | December 05, 2017 |
Expires: June 8, 2018 |
Origin-signed HTTP Responses
draft-yasskin-http-origin-signed-responses-01
This document explores how a server can send particular responses that are authoritative for an origin, when the server itself is not authoritative for that origin. For now, the appendices containing use cases and requirements should be treated as more confident than the proposal itself.
Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at https://lists.w3.org/Archives/Public/ietf-http-wg/.
The source code and issues list for this draft can be found in https://github.com/WICG/webpackage.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on June 8, 2018.
Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
When I presented Web Packaging to DISPATCH, folks thought it would make sense to split it into a way to sign individual HTTP responses as coming from a particular origin, and separately a way to bundle a collection of HTTP responses. This document explores the constraints on any method of signing HTTP responses and sketches a possible solution to the constraints.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
As a response to an HTTP request or as a Server Push ([RFC7540], section 8.2) the server MAY include a Signed-Headers header field (Section 3.1) identifying significant header fields and a Signature header field (Section 3.2) holding a list of one or more parameterised signatures that vouch for the content of the response.
The client categorizes each signature as “valid” or “invalid” by validating that signature with its certificate or public key and other metadata against the significant headers and content (Section 3.6). This validity then informs higher-level protocols.
Each signature is parameterised with information to let a client fetch assurance that a signed exchange is still valid, in the face of revoked certificates and newly-discovered vulnerabilities. This assurance can be bundled back into the signed exchange and forwarded to another client, which won’t have to re-fetch this validity information for some period of time.
The Signed-Headers header field identifies an ordered list of response header fields to include in a signature. The request URL and response status are included unconditionally. This allows a TLS-terminating intermediate to reorder headers without breaking the signature. This can also allow the intermediate to add headers that will be ignored by some higher-level protocols, but Section 3.6 provides a hook to let other higher-level protocols reject such insecure headers.
This header field appears once instead of being incorporated into the signatures’ parameters because the significant header fields need to be consistent across all signatures of an exchange, to avoid forcing higher-level protocols to merge the header field lists of valid signatures.
See Appendix B.2 for a discussion of why only the URL from the request is included and not other request headers.
Signed-Headers is a Structured Header as defined by [I-D.ietf-httpbis-header-structure]. Its value MUST be a list ([I-D.ietf-httpbis-header-structure], section 4.8) of lowercase strings ([I-D.ietf-httpbis-header-structure], section 4.2) naming HTTP response header fields. Pseudo-header field names ([RFC7540], section 8.1.2.1) MUST not appear in this list.
Higher-level protocols SHOULD place requirements on the minimum set of headers to include in the Signed-Headers header field.
The Signature header field conveys a list of signatures for an exchange, each one accompanied by information about how to determine the authority of and refresh that signature.
The Signature header is a Structured Header as defined by [I-D.ietf-httpbis-header-structure]. Its value MUST be a list ([I-D.ietf-httpbis-header-structure], section 4.8) of parameterised labels ([I-D.ietf-httpbis-header-structure], section 4.4).
Each parameterised label MUST have parameters named “sig”, “validityUrl”, “date”, and “expires”, and either “certUrl” and “certSha256” parameters or an “ed25519Key” parameter. This specification gives no meaning to the label itself, which can be used as a human-readable identifier for the signature (see Section 3.2.1, Paragraph 1). The present parameters MUST have the following values:
The “certUrl” and “validityUrl” parameters are not signed, so intermediates can update them with pointers to cached versions.
[I-D.ietf-httpbis-header-structure] provides a way to parameterise labels but not other supported types like binary content. If the Signature header field is notionally a list of parameterised signatures, maybe we should add a “parameterised binary content” type.
Should the certUrl and validityUrl be lists so that intermediates can offer a cache without losing the original URLs? Putting lists in dictionary fields is more complex than [I-D.ietf-httpbis-header-structure] allows, so they’re single items for now.
Should “validityUrl” be signed or optionally signed so that an exchange’s author can prevent an intermediate from removing it, which would prevent clients from sharing the exchange among themselves without going back to the intermeidate?
The significant parts of an exchange are:
If the exchange’s Signed-Headers header field is not present, doesn’t parse as a Structured Header ([I-D.ietf-httpbis-header-structure]) or doesn’t follow the constraints on its value described in Section 3.1, the exchange has no significant parts.
Do the significant parts of an exchange need to include the Signed-Headers header field itself?
To sign an exchange, it needs to be serialized into a byte string. Since intermediaries and distributors might rearrange, add, or just reserialize headers, and this can change the HPACK encoding, we can’t use the literal bytes of the header frames as this serialization. Instead, this section defines a CBOR representation that can be embedded into other CBOR, canonically serialized (Section 3.5), and then signed.
The CBOR representation of an exchange is the result of the following algorithm:
Followed by the appended items from, for each response header field in
exchange, in order:Given the HTTP exchange:
GET https://example.com/ HTTP/1.1 accept = */* HTTP/1.1 200 content-type = text/html signed-headers = "content-type" <!doctype html> <html> ...
The cbor representation consists of the following item, represented using the extended diagnostic notation from [I-D.ietf-cbor-cddl] appendix G:
[ "request", [ ':method', 'GET', ':url', 'https://example.com/' ], "response", [ ':status', '200', 'content-type', 'text/html' ], "payload", '<!doctype html>\n<html>...' ]
Within this specification, the canonical serialization of a CBOR item uses the following rules derived from section 3.9 of [RFC7049]:
Note: this specification does not use CBOR maps, so the map ordering rules aren’t necessary. This specification also doesn’t use floating point, tags, or other more complex data types, so it doesn’t need rules to canonicalize those either.
The client MUST parse the Signature header field as the list of parameterised values described in Section 3.2 ([I-D.ietf-httpbis-header-structure], section 4.8.1). If an error is thrown during this parsing, the exchange has no valid signatures. Otherwise, each member of this list represents a signature with parameters.
The client MUST use the following algorithm to determine whether each signature with parameters is invalid or potentially-valid. Potentially-valid results include:
This algorithm accepts a forceFetch flag that avoids the cache when fetching URLs. A client that determines that a potentially-valid certificate chain is actually invalid due to expired OCSP responses MAY retry with forceFetch set to retrieve updated OCSPs from the original server.
This algorithm also accepts an allResponseHeaders flag, which insists that there are no non-significant response header fields in the exchange.
Set
signing-alg to the result of applying this function to type of main-certificate’s public key. If the function is undefined on this input, return “invalid”.[RFC7540] section 8.2 includes the rule:
If the Server Push contains a signed exchange for which the server is not authoritative, instead of treating it as a stream error, the client MAY search for a signature for which the following algorithm returns “valid”. If such a signature is found, the client MAY treat the server as authoritative for this particular exchange and store the exchange as described by [RFC7540]. If not, the client MUST treat the exchange as a stream error as described by [RFC7540].
TLS 1.3 signs the entire certificate chain, but doing that here would preclude updating the OCSP signatures without replacing all signatures using that chain at the same time. What attack do I allow by hashing only the end-entity certificate?
Including the entire exchange in the signed data forces a client to download the whole thing before trusting any of it. [I-D.thomson-http-mice] is designed to let us check the validity of just the MI header up front and then incrementally check blocks of the payload as they arrive. What’s the best way to integrate that? Maybe add a flag to the Signature header field or its signatures saying that the payload is guarded by some other header field, so isn’t included in the significant parts (Section 3.3).
Both OCSP responses and signatures are designed to expire a short time after they’re signed, so that revoked certificates and signed exchanges with known vulnerabilities are distrusted promptly.
This specification provides no way to update OCSP responses by themselves. Instead, clients need to re-fetch the “certUrl” to get a chain including newer OCSPs.
The “validityUrl” parameter of the signatures provides a way to fetch new signatures or learn where to fetch a complete updated package.
Each version of a signed exchange SHOULD have its own validity URLs, since each version needs different signatures and becomes obsolete at different times.
The resource at a “validityUrl” is “validity data”, a CBOR map matching the following CDDL ([I-D.ietf-cbor-cddl]):
validity = { ? signatures: [ + bytes ] ? update: { url: text, ? size: uint, } ]
The elements of the signatures array are header field values meant to replace the signatures within the Signature header field pointing to this validity data. If the signed exchange contains a bug severe enough that clients need to stop using the content, the signatures array MUST NOT be present.
The update map gives a location to update the entire signed exchange and an estimate of the size of the resource at that URL. If the signed exchange is currently the most recent version, the update SHOULD NOT be present.
If both the signatures and update fields are present, clients can use the estimated size to decide whether to update the whole resource or just its signatures.
For example, if a signed exchange has the following Signature header field (written as multiple fields for convenience):
Signature: sig1; sig=*MEUCIQDXlI2gN3RNBlgFiuRNFpZXcDIaUpX6HIEwcZEc0cZYLAIga9DsVOMM+g5YpwEBdGW3sS+bvnmAJJiSMwhuBdqp5UY; validityUrl="https://example.com/resource.validity"; certUrl="https://example.com/certs"; certSha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI; date=1511128380; expires=1511560380 Signature: sig2; sig=*MEQCIGjZRqTRf9iKNkGFyzRMTFgwf/BrY2ZNIP/dykhUV0aYAiBTXg+8wujoT4n/W+cNgb7pGqQvIUGYZ8u8HZJ5YH26Qg; validityUrl="https://example.com/resource.validity"; certUrl="https://example.com/certs"; certSha256=*kQAA8u33cZRTy7RHMO4+dv57baZL48SYA2PqmYvPPbg; date=1511301183; expires=1511905983 Signature: sig3; sig=*MEYCIQCNxJzn6Rh2fNxsobktir8TkiaJYQFhWTuWI1i4PewQaQIhAMs2TVjc4rTshDtXbgQEOwgj2mRXALhfXPztXgPupii+; validityUrl="https://thirdparty.example.com/resource.validity"; certUrl="https://thirdparty.example.com/certs"; certSha256=*UeOwUPkvxlGRTyvHcsMUN0A2oNsZbU8EUvg8A9ZAnNc; date=1511301183; expires=1511905983
https://example.com/resource.validity might contain:
{ "signatures": [ 'sig4; ' 'sig=*MEQCIC/I9Q+7BZFP6cSDsWx43pBAL0ujTbON/+7RwKVk+ba5AiB3FSFLZqpzmDJ0NumNwN04pqgJZE99fcK86UjkPbj4jw; ' 'validityUrl="https://example.com/resource.validity"; ' 'certUrl="https://example.com/certs"; ' 'certSha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI; ' 'date=1511467200; expires=1511985600' ], "update": { "url": "https://example.com/resource", "size": 5557452 } }
This indicates that the first two of the original signatures (the ones with a validityUrl of “https://example.com/resource.validity”) can be replaced with a single new signature. The signatures of the updated signed exchange would be:
Signature: sig4; sig=*MEQCIC/I9Q+7BZFP6cSDsWx43pBAL0ujTbON/+7RwKVk+ba5AiB3FSFLZqpzmDJ0NumNwN04pqgJZE99fcK86UjkPbj4jw; validityUrl="https://example.com/resource.validity"; certUrl="https://example.com/certs"; certSha256=*W7uB969dFW3Mb5ZefPS9Tq5ZbH5iSmOILpjv2qEArmI; date=1511467200; expires=1511985600 Signature: sig3; sig=*MEYCIQCNxJzn6Rh2fNxsobktir8TkiaJYQFhWTuWI1i4PewQaQIhAMs2TVjc4rTshDtXbgQEOwgj2mRXALhfXPztXgPupii+; validityUrl="https://thirdparty.example.com/resource.validity"; certUrl="https://thirdparty.example.com/certs"; certSha256=*UeOwUPkvxlGRTyvHcsMUN0A2oNsZbU8EUvg8A9ZAnNc; date=1511301183; expires=1511905983
https://example.com/resource.validity could also expand the set of signatures if its signatures array contained more than 2 elements.
Authors MUST NOT include confidential information in a signed response that an untrusted intermediate could forward, since the response is only signed and not encrypted. Intermediates can read the content.
Relaxing the requirement to consult DNS when determining authority for an origin means that an attacker who possesses a valid certificate no longer needs to be on-path to redirect traffic to them; instead of modifying DNS, they need only convince the user to visit another Web site in order to serve responses signed as the target. This consideration and mitigations for it are shared by [I-D.ietf-httpbis-origin-frame].
Signing a bad response can affect more users than simply serving a bad response, since a served response will only affect users who make a request while the bad version is live, while an attacker can forward a signed response until its signature expires. Authors should consider shorter signature expiration times than they use for cache expiration times.
An attacker with temporary access to a signing oracle can sign “still valid” assertions with arbitrary timestamps and expiration times. As a result, when a signing oracle is removed, the keys it provided access to SHOULD be revoked so that, even if the attacker used them to sign future-dated package validity assertions, the key’s OCSP assertions will expire, causing the package as a whole to become untrusted.
The use of a single Signed-Headers header field prevents us from signing aspects of the request other than its effective request URI ([RFC7230], section 5.5). For example, if an author signs both Content-Encoding: br and Content-Encoding: gzip variants of a response, what’s the impact if an attacker serves the brotli one for a request with Accept-Encoding: gzip?
The simple form of Signed-Headers also prevents us from signing less than the full request URL. The SRI use case (Appendix A.3) may benefit from being able to leave the authority less constrained.
Section 3.6 can succeed when some delivered headers aren’t included in the signed set. This accommodates current TLS-terminating intermediates and may be useful for SRI (Appendix A.3), but is risky for trusting cross-origin responses (Appendix A.1, Appendix A.2, and Appendix A.4). Section 3.6.1 requires all headers to be included in the signature before trusting cross-origin pushed resources, at Ryan Sleevi’s recommendation.
Normally, when a client fetches https://o1.com/resource.js, o1.com learns that the client is interested in the resource. If o1.com signs resource.js, o2.com serves it as https://o2.com/o1resource.js, and the client fetches it from there, then o2.com learns that the client is interested, and if the client executes the Javascript, that could also report the client’s interest back to o1.com.
Often, o2.com already knew about the client’s interest, because it’s the entity that directed the client to o1resource.js, but there may be cases where this leaks extra information.
For non-executable resource types, a signed response can improve the privacy situation by hiding the client’s interest from the original author.
TODO: possibly register the validityUrl format.
[I-D.burke-content-signature] | Burke, B., "HTTP Header for digital signatures", Internet-Draft draft-burke-content-signature-00, March 2011. |
[I-D.cavage-http-signatures] | Cavage, M. and M. Sporny, "Signing HTTP Messages", Internet-Draft draft-cavage-http-signatures-09, November 2017. |
[I-D.ietf-httpbis-origin-frame] | Nottingham, M. and E. Nygren, "The ORIGIN HTTP/2 Frame", Internet-Draft draft-ietf-httpbis-origin-frame-04, August 2017. |
[I-D.thomson-http-content-signature] | Thomson, M., "Content-Signature Header Field for HTTP", Internet-Draft draft-thomson-http-content-signature-00, July 2015. |
[I-D.thomson-http-mice] | Thomson, M., "Merkle Integrity Content Encoding", Internet-Draft draft-thomson-http-mice-02, October 2016. |
[I-D.vkrasnov-h2-compression-dictionaries] | Krasnov, V., "Compression Dictionaries for HTTP/2", Internet-Draft draft-vkrasnov-h2-compression-dictionaries-02, March 2017. |
[I-D.yasskin-dispatch-web-packaging] | Yasskin, J., "Web Packaging", Internet-Draft draft-yasskin-dispatch-web-packaging-00, June 2017. |
[RFC2437] | Kaliski, B. and J. Staddon, "PKCS #1: RSA Cryptography Specifications Version 2.0", RFC 2437, DOI 10.17487/RFC2437, October 1998. |
[RFC6066] | Eastlake 3rd, D., "Transport Layer Security (TLS) Extensions: Extension Definitions", RFC 6066, DOI 10.17487/RFC6066, January 2011. |
[RFC6454] | Barth, A., "The Web Origin Concept", RFC 6454, DOI 10.17487/RFC6454, December 2011. |
[RFC7541] | Peon, R. and H. Ruellan, "HPACK: Header Compression for HTTP/2", RFC 7541, DOI 10.17487/RFC7541, May 2015. |
[SRI] | Akhawe, D., Braun, F., Marier, F. and J. Weinberger, "Subresource Integrity", World Wide Web Consortium Recommendation REC-SRI-20160623, June 2016. |
To reduce round trips, a server might use HTTP/2 PUSH to inject a subresource from another server into the client’s cache. If anything about the subresource is expired or can’t be verified, the client would fetch it from the original server.
For example, if https://example.com/index.html includes
<script src="https://jquery.com/jquery-1.2.3.min.js">
Then to avoid the need to look up and connect to jquery.com in the critical path, example.com might PUSH that resource ([RFC7540], section 8.2), signed by jquery.com.
In order to speed up loading but still maintain control over its content, an HTML page in a particular origin O.com could tell clients to load its subresources from an intermediate content distributor that’s not authoritative, but require that those resources be signed by O.com so that the distributor couldn’t modify the resources. This is more constrained than the common CDN case where O.com has a CNAME granting the CDN the right to serve arbitrary content as O.com.
<img logicalsrc="https://O.com/img.png" physicalsrc="https://distributor.com/O.com/img.png">
To make it easier to configure the right distributor for a given request, computation of the physicalsrc could be encapsulated in a custom element:
<dist-img src="https://O.com/img.png"></dist-img>
where the <dist-img> implementation generates an appropriate <img> based on, for example, a <meta name="dist-base"> tag elsewhere in the page.
This could be used for some of the same purposes as SRI (Appendix A.3).
Note that the current proposal doesn’t support this use case because there’s no way aside from a Server Push to override the physical request URL.
The W3C WebAppSec group is investigating using signatures in [SRI]. They need a way to transmit the signature with the response, which this proposal could provide.
However, their needs also differ in some significant ways:
While we can design this system to cover both origin-trusted and simple-key signatures, we should check that this is better than having two separate systems for the two kinds of signatures.
Note that while the current proposal for SRI describes signing only the content of a resource, they may need to sign its name as well, to prevent security vulnerabilities. The details of what they need to sign will affect whether and how they can use this proposal.
See https://github.com/WICG/webpackage and [I-D.yasskin-dispatch-web-packaging]. This use requires origin-signed resources to be bundled.
To verify that a thing came from a particular origin, for use in the same context as a TLS connection, we need someone to vouch for the signing key with as much verification as the signing keys used in TLS. The obvious way to do this is to re-use the web PKI and CA ecosystem.
If we re-use existing TLS server certificates, we incur the risks that:
If these risks are too high, we could define a new Extended Key Usage ([RFC5280], section 4.2.1.12) that requires CAs to issue new keys for this purpose or a new certificate extension to do the same. A new EKU would probably require CAs to also issue new intermediate certificates because of how browsers trust EKUs. Both an EKU and a new extension take a long time to deploy and allow CAs to charge package-signers more than normal server operators, which will reduce adoption.
The rest of this document will assume we can re-use existing TLS server certificates.
In order to prevent an attacker who can convince the server to sign some resource from causing those signed bytes to be interpreted as something else, signatures here need to:
The specification also needs to define which signing algorithm to use. I expect to define that as a function from the key type, instead of allowing attacker-controlled data to specify it.
The client needs to be able to find the certificate vouching for the signing key, a chain from that certificate to a trusted root, and possibly other trust information like SCTs ([RFC6962]). One approach would be to include the certificate and its chain in the signature metadata itself, but this wastes bytes when the same certificate is used for multiple HTTP responses. If we decide to put the signature in an HTTP header, certificates are also unusually large for that context.
Another option is to pass a URL that the client can fetch to retrieve the certificate and chain. To avoid extra round trips in fetching that URL, it could be bundled with the signed content or PUSHed with it. The risks from the client_certificate_url extension ([RFC6066] section 11.3) don’t seem to apply here, since an attacker who can get a client to load a package and fetch the certificates it references, can also get the client to perform those fetches by loading other HTML.
To avoid using an unintended certificate with the same public key as the intended one, the content of the certificate chain should be included in the signed data, like TLS does ([I-D.ietf-tls-tls13], section 4.4.3).
The previous [I-D.thomson-http-content-signature] and [I-D.burke-content-signature] schemes signed just the content, while ([I-D.cavage-http-signatures] could also sign the response headers and the request method and path. However, the same path, response headers, and content may mean something very different when retrieved from a different server. Section 3.3 currently includes the whole request URL in the signature, but it’s possible we need a more flexible scheme to allow some higher-level protocols to accept a less-signed URL.
The question of whether to include other request headers—primarily the accept* family—is still open. These headers need to be represented so that clients wanting a different language, say, can avoid using the wrong-language response, but it’s not obvious that there’s a security vulnerability if an attacker can spoof them. For now, the proposal (Section 3) omits other request headers.
In order to allow multiple clients to consume the same signed exchange, the exchange shouldn’t include the exact request headers that any particular client sends. For example, a Japanese resource wouldn’t include
accept-language: ja-JP, ja;q=0.9, en;q=0.8, zh;q=0.7, *;q=0.5
Instead, it would probably include just
accept-language: ja-JP, ja
and clients would use the same matching logic as for PUSH_PROMISE frame headers.
HTTP headers are traditionally munged by proxies, making it impossible to guarantee that the client will see the same sequence of bytes as the author wrote. In the HTTPS world, we have more end-to-end header integrity, but it’s still likely that there are enough TLS-terminating proxies that the author’s signatures would tend to break before getting to the client.
There’s also no way in current HTTP for the response to a client-initiated request ([RFC7540], section 8.1) to convey the request headers it expected to respond to. A PUSH_PROMISE ([RFC7540], section 8.2) does not have this problem, and it would be possible to introduce a response header to convey the expected request headers.
Since proxies don’t modify unknown content types, we could wrap the original exchange into an application/http2 format. This could be as simple as a series of HTTP/2 frames, or could
To help the PUSHed subresources use case (Appendix A.1), we might also want to extend the PUSH_PROMISE frame type to include a signature, and that could tell intermediates not to change the ensuing headers.
A normal HTTPS response is authoritative only for one client, for as long as its cache headers say it should live. A signed exchange can be re-used for many clients, and if it was generated while a server was compromised, it can continue compromising clients even if their requests happen after the server recovers. This signing scheme needs to mitigate that risk.
Certificates are mis-issued and private keys are stolen, and in response clients need to be able to stop trusting these certificates as promptly as possible. Online revocation checks don’t work, so the industry has moved to pushed revocation lists and stapled OCSP responses [RFC6066].
Pushed revocation lists work as-is to block trust in the certificate signing an exchange, but the signatures need an explicit strategy to staple OCSP responses. One option is to extend the certificate download (Appendix B.1.3) to include the OCSP response too, perhaps in the TLS 1.3 CertificateEntry format.
The signed content in a response might be vulnerable to attacks, such as XSS, or might simply be discovered to be incorrect after publication. Once the author fixes those vulnerabilities or mistakes, clients should stop trusting the old signed content in a reasonable amount of time. Similar to certificate revocation, I expect the best option to be stapled “this version is still valid” assertions with short expiration times.
These assertions could be structured as:
The signature also needs to include instructions to intermediates for how to fetch updated validity assertions.
This draft could expire signature validity using the normal HTTP cache control headers ([RFC7234]) instead of embedding an expiration date in the signature itself. This section specifies how that would work, and describes why I haven’t chosen that option.
The signatures in the Signature header field (Section 3.2) would no longer contain “date” or “expires” fields.
The validity-checking algorithm (Section 3.6) would initialize date from the resource’s Date header field ([RFC7231], section 7.1.1.2) and initialize expires from either the Expires header field ([RFC7234] section 5.3) or the Cache-Control header field’s max-age directive ([RFC7234] section 5.2.2.8) (added to date), whichever is present, preferring max-age (or failing) if both are present.
Validity updates (Section 3.7) would include a list of replacement response header fields. For each header field name in this list, the client would remove matching header fields from the stored exchange’s response header fields. Then the client would append the replacement header fields to the stored exchange’s response header fields.
For example, given a stored exchange of:
GET https://example.com/ HTTP/1.1 accept = */* HTTP/1.1 200 date = Mon, 20 Nov 2017 10:00:00 UTC content-type = text/html date = Tue, 21 Nov 2017 10:00:00 UTC expires = Sun, 26 Nov 2017 10:00:00 UTC <!doctype html> <html> ...
And an update listing the following headers:
expires = Fri, 1 Dec 2017 10:00:00 UTC date = Sat, 25 Nov 2017 10:00:00 UTC
The resulting stored exchange would be:
GET https://example.com/ HTTP/1.1 accept = */* HTTP/1.1 200 content-type = text/html expires = Fri, 1 Dec 2017 10:00:00 UTC date = Sat, 25 Nov 2017 10:00:00 UTC <!doctype html> <html> ...
In an exchange with multiple signatures, using cache control to expire signatures forces all signatures to initially live for the same period. Worse, the update from one signature’s “validityUrl” might not match the update for another signature. Clients would need to maintain a current set of headers for each signature, and then decide which set to use when actually parsing the resource itself.
This need to store and reconcile multiple sets of headers for a single signed exchange argues for embedding a signature’s lifetime into the signature.
Thanks to Ilari Liusvaara, Mark Nottingham, Ryan Sleevi, and Yoav Weiss for comments that improved this draft.