idnits 2.17.1
draft-ietf-websec-key-pinning-09.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 2 instances of too long lines in the document, the longest one
being 5 characters in excess of 72.
Miscellaneous warnings:
----------------------------------------------------------------------------
== The copyright year in the IETF Trust and authors Copyright Line does not
match the current year
-- The document date (November 27, 2013) is 3775 days in the past. Is this
intentional?
Checking references for intended status: Proposed Standard
----------------------------------------------------------------------------
(See RFCs 3967 and 4897 for information about using normative references
to lower-maturity documents in RFCs)
== Unused Reference: 'RFC5226' is defined on line 942, but no explicit
reference was found in the text
== Outdated reference: A later version (-10) exists of
draft-josefsson-pkix-textual-02
** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231,
RFC 7232, RFC 7233, RFC 7234, RFC 7235)
** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159)
** Obsolete normative reference: RFC 4634 (Obsoleted by RFC 6234)
** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126)
** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446)
Summary: 6 errors (**), 0 flaws (~~), 3 warnings (==), 1 comment (--).
Run idnits with the --verbose option for more detailed information about
the items above.
--------------------------------------------------------------------------------
2 Web Security C. Evans
3 Internet-Draft C. Palmer
4 Intended status: Standards Track R. Sleevi
5 Expires: May 31, 2014 Google, Inc.
6 November 27, 2013
8 Public Key Pinning Extension for HTTP
9 draft-ietf-websec-key-pinning-09
11 Abstract
13 This memo describes an extension to the HTTP protocol allowing web
14 host operators to instruct user agents (UAs) to remember ("pin") the
15 hosts' cryptographic identities for a given period of time. During
16 that time, UAs will require that the host present a certificate chain
17 including at least one Subject Public Key Info structure whose
18 fingerprint matches one of the pinned fingerprints for that host. By
19 effectively reducing the number of authorities who can authenticate
20 the domain during the lifetime of the pin, pinning may reduce the
21 incidence of man-in-the-middle attacks due to compromised
22 Certification Authorities.
24 Status of This Memo
26 This Internet-Draft is submitted in full conformance with the
27 provisions of BCP 78 and BCP 79.
29 Internet-Drafts are working documents of the Internet Engineering
30 Task Force (IETF). Note that other groups may also distribute
31 working documents as Internet-Drafts. The list of current Internet-
32 Drafts is at http://datatracker.ietf.org/drafts/current/.
34 Internet-Drafts are draft documents valid for a maximum of six months
35 and may be updated, replaced, or obsoleted by other documents at any
36 time. It is inappropriate to use Internet-Drafts as reference
37 material or to cite them other than as "work in progress."
39 This Internet-Draft will expire on May 31, 2014.
41 Copyright Notice
43 Copyright (c) 2013 IETF Trust and the persons identified as the
44 document authors. All rights reserved.
46 This document is subject to BCP 78 and the IETF Trust's Legal
47 Provisions Relating to IETF Documents
48 (http://trustee.ietf.org/license-info) in effect on the date of
49 publication of this document. Please review these documents
50 carefully, as they describe your rights and restrictions with respect
51 to this document. Code Components extracted from this document must
52 include Simplified BSD License text as described in Section 4.e of
53 the Trust Legal Provisions and are provided without warranty as
54 described in the Simplified BSD License.
56 Table of Contents
58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
59 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 3
60 2. Server and Client Behavior . . . . . . . . . . . . . . . . . 3
61 2.1. Response Header Field Syntax . . . . . . . . . . . . . . 3
62 2.1.1. The max-age Directive . . . . . . . . . . . . . . . . 5
63 2.1.2. The includeSubDomains Directive . . . . . . . . . . . 5
64 2.1.3. The report-uri Directive . . . . . . . . . . . . . . 5
65 2.1.4. The strict Directive . . . . . . . . . . . . . . . . 6
66 2.1.5. Examples . . . . . . . . . . . . . . . . . . . . . . 6
67 2.2. Server Processing Model . . . . . . . . . . . . . . . . . 7
68 2.2.1. HTTP-over-Secure-Transport Request Type . . . . . . . 7
69 2.2.2. HTTP Request Type . . . . . . . . . . . . . . . . . . 8
70 2.3. User Agent Processing Model . . . . . . . . . . . . . . . 8
71 2.3.1. Public-Key-Pins Response Header Field Processing . . 8
72 2.3.2. Noting a Pinned Host - Storage Model . . . . . . . . 9
73 2.3.3. HTTP-Equiv Element Attribute . . . . . . . . . 10
74 2.4. Semantics of Pins . . . . . . . . . . . . . . . . . . . . 10
75 2.5. Noting Pins . . . . . . . . . . . . . . . . . . . . . . . 11
76 2.6. Validating Pinned Connections . . . . . . . . . . . . . . 12
77 2.7. Interactions With Preloaded Pin Lists . . . . . . . . . . 13
78 2.8. Pinning Self-Signed End Entities . . . . . . . . . . . . 13
79 3. Reporting Pin Validation Failure . . . . . . . . . . . . . . 14
80 4. Security Considerations . . . . . . . . . . . . . . . . . . . 15
81 4.1. Maximum max-age . . . . . . . . . . . . . . . . . . . . . 15
82 4.2. Using includeSubDomains Safely . . . . . . . . . . . . . 16
83 4.3. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 17
84 5. Privacy Considerations . . . . . . . . . . . . . . . . . . . 17
85 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18
86 7. Usability Considerations . . . . . . . . . . . . . . . . . . 19
87 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 19
88 9. What's Changed . . . . . . . . . . . . . . . . . . . . . . . 19
89 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 20
90 10.1. Normative References . . . . . . . . . . . . . . . . . . 20
91 10.2. Informative References . . . . . . . . . . . . . . . . . 21
92 Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 21
93 Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . 22
94 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 22
96 1. Introduction
98 We propose a new HTTP header to enable a web host to express to user
99 agents (UAs) which Subject Public Key Info (SPKI) structure(s) UAs
100 SHOULD expect to be present in the host's certificate chain in future
101 connections using TLS (see [RFC5246]). We call this "public key
102 pinning". At least one UA (Google Chrome) has experimented with the
103 idea by shipping with a user-extensible embedded set of pins.
104 Although effective, this does not scale. This proposal addresses the
105 scale problem.
107 Deploying public key pinning safely will require operational and
108 organizational maturity due to the risk that hosts may make
109 themselves unavailable by pinning to a SPKI that becomes invalid.
110 (See Section 4.) We believe that, with care, host operators can
111 greatly reduce the risk of MITM attacks and other false-
112 authentication problems for their users without incurring undue risk.
114 We intend for hosts to use public key pinning together with HSTS
115 ([RFC6797]), but is possible to pin keys without requiring HSTS.
117 This draft is being discussed on the WebSec Working Group mailing
118 list, websec@ietf.org.
120 1.1. Requirements Language
122 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
123 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
124 document are to be interpreted as described in RFC 2119 [RFC2119].
126 2. Server and Client Behavior
128 2.1. Response Header Field Syntax
130 The Public-Key-Pins HTTP response header field (PKP header field)
131 indicates to a UA that it should perform Pin Validation (Section 2.6)
132 in regards to the host emitting the response message containing this
133 header field, and provides the necessary information for the UA to do
134 so.
136 Figure 1 describes the ABNF (Augmented Backus-Naur Form) syntax of
137 the header field. It is based on the Generic Grammar defined in
138 Section 2 of [RFC2616] (which includes a notion of "implied linear
139 whitespace", also known as "implied *LWS").
141 Public-Key-Pins =
142 "Public-Key-Pins" ":" [ directive ] *( ";" [ directive ] )
143 Public-Key-Pins-Report-Only =
144 "Public-Key-Pins-Report-Only" ":" [ directive ] *( ";" [ directive ] )
146 directive = simple-directive
147 / pin-directive
149 simple-directive = directive-name [ "=" directive-value ]
150 directive-name = token
151 directive-value = token
152 / quoted-string
154 pin-directive = "pin-" token "=" quoted-string
156 Figure 1: HPKP Header Syntax
158 token and quoted-string are used as defined in [RFC2616],
159 Section 2.2.
161 The directives defined in this specification are described below.
162 The overall requirements for directives are:
164 1. The order of appearance of directives is not significant.
166 2. All simple-directives MUST appear only once in a PKP header
167 field. Directives are either optional or required, as stipulated
168 in their definitions.
170 3. Directive names are case-insensitive.
172 4. UAs MUST ignore any PKP header fields containing directives, or
173 other header field value data, that do not conform to the syntax
174 defined in this specification.
176 5. If a PKP header field contains any directive(s) the UA does not
177 recognize, the UA MUST ignore the those directives.
179 6. If the PKP header field otherwise satisfies the above
180 requirements (1 through 5), the UA MUST process the directives it
181 recognizes.
183 Additional directives extending the semantic functionality of the PKP
184 header field can be defined in other specifications, with a registry
185 (having an IANA policy definition of IETF Review [RFC2616]) defined
186 for them at such time. Such future directives will be ignored by UAs
187 implementing only this specification, as well as by generally non-
188 conforming UAs.
190 In the pin-directive, the token is the name of a cryptographic hash
191 algorithm, and MUST be either "sha1" or "sha256". The quoted-string
192 is a sequence of base 64 digits: the base 64-encoded SPKI Fingerprint
193 ([RFC4648]). See Section 2.4.
195 2.1.1. The max-age Directive
197 The REQUIRED "max-age" directive specifies the number of seconds,
198 after the reception of the PKP header field, during which the UA
199 SHOULD regard the host (from whom the message was received) as a
200 Known Pinned Host. The delta-seconds production is specified in
201 [RFC2616].
203 The syntax of the max-age directive's REQUIRED value (after quoted-
204 string unescaping, if necessary) is defined as:
206 max-age-value = delta-seconds
207 delta-seconds = 1*DIGIT
209 Figure 2: max-age Value Syntax
211 delta-seconds is used as defined in [RFC2616], Section 3.3.2.
213 NOTE: A max-age value of zero (i.e., "max-age=0") signals the UA to
214 cease regarding the host as a Known Pinned Host, including the
215 includeSubDomains directive (if asserted for that Known Pinned Host).
216 See Section 2.3.1.
218 2.1.2. The includeSubDomains Directive
220 The OPTIONAL "includeSubDomains" directive is a valueless directive
221 which, if present (i.e., it is "asserted"), signals to the UA that
222 the Pinning Policy applies to this Pinned Host as well as any
223 subdomains of the host's domain name.
225 2.1.3. The report-uri Directive
227 The OPTIONAL "report-uri" directive indicates the URI to which the UA
228 SHOULD report Pin Validation failures (Section 2.6). The UA POSTs
229 the reports to the given URI as described in Section 3.
231 When used in the Public-Key-Pins-Report-Only header, the UA SHOULD
232 POST reports for Pin Validation failures to the indicated report-uri,
233 although the UA MUST NOT enforce Pin Validation. That is, in the
234 event of Pin Validation failure when the host has set the Public-Key-
235 Pins-Report-Only header, the UA performs Pin Validation only to check
236 whether or not it should POST a report, but not for causing
237 connection failure.
239 If a Host sets both the Public-Key-Pins header and the Public-Key-
240 Pins-Report-Only header, the UA MUST NOT enforce Pin Validation, and
241 MUST note only the pins and directives given in the Public-Key-Pins-
242 Report-Only header.
244 When used in the Public-Key-Pins header, the presence of a report-uri
245 directive indicates to the UA that the UA MUST enforce Pin
246 Validation, and the UA SHOULD also, in the event of Pin Validation
247 failure, POST a report to the report-uri.
249 Note that the report-uri need not necessarily be in the same Internet
250 domain or web origin as the Known Pinned Host.
252 Hosts may set report-uris that use HTTP, HTTPS, or other schemes. If
253 the scheme in the report-uri is HTTPS, UAs MUST perform Pinning
254 Validation when the host in the report-uri is a Known Pinned Host;
255 similarly, UAs MUST apply HSTS if the host in the report-uri is a
256 Known HSTS Host.
258 UAs SHOULD make their best effort to report Pin Validation failures
259 to the report-uri, but may fail to report in exceptional conditions.
260 For example, if connecting the report-uri itself incurs a Pinning
261 Validation failure or other certificate validation failure, the UA
262 MUST cancel the connection (and MAY attempt to re-send the report
263 later). Similarly, if Known Pinned Host A sets a report-uri
264 referring to Known Pinned Host B, and if B sets a report-uri
265 referring to A, and if both hosts fail Pin Validation, the UA SHOULD
266 detect and break the loop by failing to send reports to and about
267 those hosts.
269 UAs SHOULD limit the rate at which they send reports. For example,
270 it is unnecessary to send the same report to the same report-uri more
271 than once.
273 2.1.4. The strict Directive
275 The OPTIONAL "strict" directive is a valueless directive which, if
276 present (i.e., it is "asserted"), signals to the UA that it should
277 apply to the Pinned Host the Pinning Policy expressed in the PKP
278 header exactly as specified, ignoring local client policy.
280 2.1.5. Examples
282 Figure 3 shows some example response header fields using the pins
283 extension (folded for clarity).
285 Public-Key-Pins: max-age=3000;
286 pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
287 pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc="
289 Public-Key-Pins: max-age=2592000;
290 pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
291 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
293 Public-Key-Pins: max-age=2592000;
294 pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
295 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
296 report-uri="http://example.com/pkp-report"
298 Public-Key-Pins-Report-Only: max-age=2592000;
299 pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
300 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
301 report-uri="http://example.com/pkp-report"
303 Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
304 pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
305 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
306 max-age=259200
308 Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
309 pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
310 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
311 max-age=10000; includeSubDomains
313 Figure 3: HPKP Header Examples
315 2.2. Server Processing Model
317 This section describes the processing model that Pinned Hosts
318 implement. The model comprises two facets: the processing rules for
319 HTTP request messages received over a secure transport (e.g. TLS
320 [RFC5246]); and the processing rules for HTTP request messages
321 received over non-secure transports, such as TCP.
323 2.2.1. HTTP-over-Secure-Transport Request Type
325 When replying to an HTTP request that was conveyed over a secure
326 transport, a Pinned Host SHOULD include in its response exactly one
327 PKP header field that MUST satisfy the grammar specified above in
328 Section 2.1.
330 Establishing a given host as a Known Pinned Host, in the context of a
331 given UA, MAY be accomplished over the HTTP protocol, which is in
332 turn running over secure transport, by correctly returning (per this
333 specification) at least one valid PKP header field to the UA. Other
334 mechanisms, such as a client-side pre-loaded Known Pinned Host list
335 MAY also be used.
337 2.2.2. HTTP Request Type
339 Pinned Hosts SHOULD NOT include the PKP header field in HTTP
340 responses conveyed over non-secure transport. UAs MUST ignore any
341 PKP header received in an HTTP response conveyed over non-secure
342 transport.
344 2.3. User Agent Processing Model
346 This section describes the HTTP Public Key Pinning processing model
347 for UAs.
349 The UA processing model relies on parsing domain names. Note that
350 internationalized domain names SHALL be canonicalized according to
351 the scheme in Section 10 of [RFC6797].
353 2.3.1. Public-Key-Pins Response Header Field Processing
355 If the UA receives, over a secure transport, an HTTP response that
356 includes a PKP header field conforming to the grammar specified in
357 Section 2.1, and there are no underlying secure transport errors or
358 warnings (see Section 2.5), the UA MUST either:
360 o Note the host as a Known Pinned Host if it is not already so noted
361 (see Section 2.3.2),
363 or,
365 o Update the UA's cached information for the Known Pinned Host if
366 any of of the max-age, includeSubDomains, strict, or report-uri
367 header field value directives convey information different than
368 that already maintained by the UA.
370 o The max-age value is essentially a "time to live" value relative
371 to the time of the most recent observation of the PKP header
372 field.
374 o If the max-age header field value token has a value of 0, the UA
375 MUST remove its cached Pinning Policy information (including the
376 includeSubDomains and strict directives, if asserted) if the
377 Pinned Host is Known, or, MUST NOT note this Pinned Host if it is
378 not yet Known.
380 o If a UA receives more than one PKP header field in an HTTP
381 response message over secure transport, then the UA MUST process
382 only the first such header field.
384 Otherwise:
386 o If the UA receives the HTTP response over insecure transport, or
387 if the PKP header is not a Valid Pinning Header (see Section 2.5),
388 the UA MUST ignore any present PKP header field(s).
390 o The UA MUST ignore any PKP header fields not conforming to the
391 grammar specified in Section 2.1.
393 2.3.2. Noting a Pinned Host - Storage Model
395 If the substring matching the host production from the Request-URI
396 (of the message to which the host responded) syntactically matches
397 the IP-literal or IPv4address productions from Section 3.2.2 of
398 [RFC3986], then the UA MUST NOT note this host as a Known Pinned
399 Host.
401 Otherwise, if the substring does not congruently match a Known Pinned
402 Host's domain name, per the matching procedure specified in
403 Section 8.2 of [RFC6797], then the UA MUST note this host as a Known
404 Pinned Host, caching the Pinned Host's domain name and noting along
405 with it the time of the observation (also known as the Effective Pin
406 Date), the value of the max-age directive, whether or not the
407 includeSubDomains or strict directives are asserted, the value of the
408 report-uri directive (if present), and any other metadata from
409 optional or future PKP header directives.
411 UAs MAY set an upper limit on the value of max-age, so that UAs that
412 have noted erroneous pins (whether by accident or due to attack) have
413 some chance of recovering over time. If the server sets a max-age
414 greater than the UA's upper limit, the UA MAY behave as if the server
415 set the max-age to the UA's upper limit. For example, if the UA caps
416 max-age at 5184000 seconds (60 days), and a Pinned Host sets a max-
417 age directive of 90 days in its Valid Pinning Header, the UA MAY
418 behave as if the max-age were effectively 60 days. (One way to
419 achieve this behavior is for the UA to simply store a value of 60
420 days instead of the 90 day value provided by the Pinned Host.) For
421 UA implementation guidance on how to select a maximum max-age, see
422 Section 4.1.
424 The UA MUST NOT modify any pinning metadata of any superdomain
425 matched Known Pinned Host.
427 A Known Pinned Host is "expired" if the Effective Pin Date plus the
428 max-age refers to a date in the past. The UA MUST ignore all expired
429 Known Pinned Hosts from its cache if, at any time, an expired Known
430 Pinned Host exists in the cache.
432 2.3.3. HTTP-Equiv Element Attribute
434 UAs MUST NOT heed http-equiv="Public-Key-Pins" attribute settings on
435 elements [W3C.REC-html401-19991224] in received content.
437 2.4. Semantics of Pins
439 An SPKI Fingerprint is defined as the output of a known cryptographic
440 hash algorithm whose input is the DER-encoded ASN.1 representation of
441 the SubjectPublicKeyInfo (SPKI) field of an X.509 certificate. A Pin
442 is defined as the combination of the known algorithm identifier and
443 the SPKI Fingerprint computed using that algorithm.
445 The SPKI Fingerprint is encoded in base 64 for use in an HTTP header.
446 (See [RFC4648].)
448 In this version of the specification, the known cryptographic hash
449 algorithms are SHA-1, identified as "sha1", and SHA-256, identified
450 as "sha256" ([RFC4634]). (Future versions of this specification may
451 add new algorithms and deprecate old ones.) UAs MUST ignore Pins for
452 which they do not recognize the algorithm identifier. UAs MUST
453 continue to process the rest of a PKP response header field and note
454 Pins for algorithms they do recognize; UAs MUST recognize "sha1" and
455 "sha256".
457 Figure 4 reproduces the definition of the SubjectPublicKeyInfo
458 structure in [RFC5280].
460 SubjectPublicKeyInfo ::= SEQUENCE {
461 algorithm AlgorithmIdentifier,
462 subjectPublicKey BIT STRING }
464 AlgorithmIdentifier ::= SEQUENCE {
465 algorithm OBJECT IDENTIFIER,
466 parameters ANY DEFINED BY algorithm OPTIONAL }
468 Figure 4: SPKI Definition
470 If the SubjectPublicKeyInfo of a certificate is incomplete when taken
471 in isolation, such as when holding a DSA key without domain
472 parameters, a public key pin cannot be formed.
474 We pin public keys, rather than entire certificates, to enable
475 operators to generate new certificates containing old public keys
476 (see [why-pin-key]).
478 See Appendix A for an example non-normative program that generates
479 SPKI Fingerprints from SubjectPublicKeyInfo fields in certificates.
481 2.5. Noting Pins
483 Upon receipt of the Public-Key-Pins response header field, the UA
484 notes the host as a Pinned Host, storing the Pins and their
485 associated directives in non-volatile storage (for example, along
486 with the HSTS metadata). The Pins and their associated directives
487 are collectively known as Pinning Metadata.
489 The UA MUST observe these conditions when noting a Host:
491 o The UA MUST note the Pins if and only if it received the Public-
492 Key-Pins response header field over an error-free TLS connection.
493 If the host is a Pinned Host, this includes the validation added
494 in Section 2.6.
496 o The UA MUST note the Pins if and only if the TLS connection was
497 authenticated with a certificate chain containing at least one of
498 the SPKI structures indicated by at least one of the given SPKI
499 Fingerprints. (See Section 2.6.)
501 o The UA MUST note the Pins if and only if the given set of Pins
502 contains at least one Pin that does NOT refer to an SPKI in the
503 certificate chain. (That is, the host must set a Backup Pin; see
504 Section 4.3.)
506 If the Public-Key-Pins response header field does not meet all three
507 of these criteria, the UA MUST NOT note the host as a Pinned Host. A
508 Public-Key-Pins response header field that meets all these critera is
509 known as a Valid Pinning Header.
511 Whenever a UA receives a Valid Pinning Header, it MUST set its
512 Pinning Metadata to the exact Pins, max-age, and (if any) report-uri
513 and strict mode given in the most recently received Valid Pinning
514 Header.
516 For forward compatibility, the UA MUST ignore any unrecognized
517 Public-Key-Pins header directives, while still processing those
518 directives it does recognize. Section 2.1 specifies the directives
519 max-age, pins, includeSubDomains, report-uri, and strict, but future
520 specifications and implementations might use additional directives.
522 2.6. Validating Pinned Connections
524 When a UA connects to a Pinned Host, if the TLS connection has
525 errors, the UA MUST terminate the connection without allowing the
526 user to proceed anyway. (This behavior is the same as that required
527 by [RFC6797].)
529 If the connection has no errors, then the UA will determine whether
530 to apply a new, additional correctness check: Pin Validation. A UA
531 SHOULD perform Pin Validation whenever connecting to a Known Pinned
532 Host, but MAY allow Pin Validation to be disabled for Hosts according
533 to local policy. For example, a UA may disable Pin Validation for
534 Pinned Hosts whose validated certificate chain terminates at a user-
535 defined trust anchor, rather than a trust anchor built-in to the UA.
536 However, if the Pinned Host Metadata indicates that the Pinned Host
537 is operating in "strict mode" (see Section 2.1.4), then the UA MUST
538 perform Pin Validation.
540 To perform Pin Validation, the UA will compute the SPKI Fingerprints
541 for each certificate in the Pinned Host's validated certificate
542 chain, using each supported hash algorithm for each certificate.
543 (For the purposes of Pin Validation, the UA MUST ignore certificates
544 whose SPKI cannot be taken in isolation, and MUST ignore superfluous
545 certificates in the chain that do not form part of the validating
546 chain.) The UA will then check that the set of these SPKI
547 Fingerprints intersects the set of SPKI Fingerprints in that Pinned
548 Host's Pinning Metadata. If there is set intersection, the UA
549 continues with the connection as normal. Otherwise, the UA MUST
550 treat this Pin Failure as a non-recoverable error. Any procedure
551 that matches the results of this Pin Validation procedure is
552 considered equivalent.
554 Note that, although the UA has previously received Pins at the HTTP
555 layer, it can and MUST perform Pin Validation at the TLS layer,
556 before beginning an HTTP conversation over the TLS channel. The TLS
557 layer thus evaluates TLS connections with pinning information the UA
558 received previously, regardless of mechanism: statically preloaded,
559 via HTTP header, or some other means (possibly in the TLS layer
560 itself).
562 2.7. Interactions With Preloaded Pin Lists
564 UAs MAY choose to implement additional sources of pinning
565 information, such as through built-in lists of pinning information.
566 Such UAs SHOULD allow users to override such additional sources,
567 including disabling them from consideration.
569 UAs that support additional sources of pinning information MUST use
570 the most recently observed pinning information when performing Pin
571 Validation for a host. The most recently observed pinning
572 information is determined based upon the most recent Effective Pin
573 Date, as described in Section 2.3.2.
575 If the result of noting a Valid Pinning Header is to disable pinning
576 for the host, such as through supplying a max-age directive with a
577 value of 0, UAs MUST allow this new information to override any other
578 pinning data. That is, a host must be able to un-pin itself, even in
579 the presence of built-in pins.
581 Example: A UA may ship with a pre-configured list of pins that are
582 collected from past observations of Valid Pinning Headers supplied by
583 hosts. In such a solution, the pre-configured list should track when
584 the Valid Pinning Header was last observed, in order to permit site
585 operators to later update the value by supplying a new Valid Pinning
586 Header. Updates to such a pre-configured list should not update the
587 Effective Pin Dates for each host unless the list vendor has actually
588 observed a more recent header. This is to prevent situations where
589 updating the Effective Pin Date on a pre-configured list of pins may
590 effectively extend the max-age beyond the site operator's stated
591 policy.
593 Example: A UA may ship with a pre-configured list of pins that are
594 collected through out-of-band means, such as direct contact with the
595 site operator. In such a solution, the site operator accepts
596 responsibility for keeping the configured Valid Pinning Header in
597 sync with the vendor's list, allowing the UA vendor to have each
598 update to the list be treated as as an update of the Effective Pin
599 Date.
601 2.8. Pinning Self-Signed End Entities
602 If UAs accept hosts that authenticate themselves with self-signed end
603 entity certificates, they MAY also allow hosts to pin the public keys
604 in such certificates. The usability and security implications of
605 this practice are outside the scope of this specification.
607 3. Reporting Pin Validation Failure
609 When a Known Pinned Host has set the report-uri directive, the UA
610 SHOULD report Pin Validation failures to the indicated URI. The UA
611 does this by POSTing a JSON ([RFC4627]) message to the URI; the JSON
612 message takes this form:
614 {
615 "date-time": date-time,
616 "hostname": hostname,
617 "port": port,
618 "certificate-chain": [
619 pem1, ... pemN
620 ],
621 "known-pins": [
622 known-pin1, ... known-pinN
623 ]
624 }
626 Figure 5: JSON Report Format
628 Whitespace outside of quoted strings is not significant. The key/
629 value pairs may appear in any order, but each SHOULD appear only
630 once.
632 The date-time indicates the time the UA observed the Pin Validation
633 failure. It is provided as a string formatted according to
634 Section 5.6, "Internet Date/Time Format", of [RFC3339].
636 The hostname is the hostname to which the UA made the original
637 request that failed Pin Validation. It is provided as a string.
639 The port is the port to which the UA made the original request that
640 failed Pin Validation. It is provided either as a string or as an
641 integer.
643 The certificate-chain is the certificate chain, as constructed by the
644 UA during certificate chain verification. (This may differ from the
645 certificate chain as served by the Known Pinned Host, of course.) It
646 is provided as an array of strings; each string pem1, ... pemN is the
647 PEM representation of each X.509 certificate as described in
648 [I-D.josefsson-pkix-textual].
650 The known-pins are the Pins that the UA has noted for the Known
651 Pinned Host. They are provided as an array of strings with the
652 syntax:
654 known-pin = token "=" quoted-string
656 Figure 6: Known Pin Syntax
658 As in Section 2.4, the token refers to the algorithm name, and the
659 quoted-string refers to the base 64 encoding of the SPKI Fingerprint.
661 4. Security Considerations
663 Pinning public keys helps hosts strongly assert their cryptographic
664 identity even in the face of issuer error, malfeasance or compromise.
665 But there is some risk that a host operator could lose or lose
666 control of their host's private key (such as by operator error or
667 host compromise). If the operator had pinned only the key of the
668 host's end entity certificate, the operator would not be able to
669 serve their web site or application in a way that UAs would trust for
670 the duration of their pin's max-age. (Recall that UAs MUST close the
671 connection to a host upon Pin Failure.)
673 Therefore, there is a necessary trade-off between two competing
674 goods: pin specificity and maximal reduction of the scope of issuers
675 on the one hand; and flexibility and resilience of the host's
676 cryptographic identity on the other hand. One way to resolve this
677 trade-off is to compromise by pinning to the key(s) of the issuer(s)
678 of the host's end entity certificate(s). Often, a valid certificate
679 chain will have at least two certificates above the end entity
680 certificate: the intermediate issuer, and the trust anchor.
681 Operators can pin any one or more of the public keys in this chain,
682 and indeed could pin to issuers not in the chain (as, for example, a
683 Backup Pin). Pinning to an intermediate issuer, or even to a trust
684 anchor or root, still significantly reduces the number of issuers who
685 can issue end entity certificates for the Known Pinned Host, while
686 still giving that host flexibility to change keys without a
687 disruption of service.
689 4.1. Maximum max-age
691 As mentioned in Section 2.3.2, UAs MAY cap the max-age value at some
692 upper limit. There is a security trade-off in that low maximum
693 values provide a narrow window of protection for users who visit the
694 Known Pinned Host only infrequently, while high maximum values might
695 potentially result in a UA's inability to successfully perform Pin
696 Validation for a Known Pinned Host if the UA's noted pins and the
697 Host's true pins diverge.
699 Such divergence could occur for several reasons, including: UA error;
700 Host operator error; network attack; or a Known Pinned Host that
701 intentionally migrates all pinned keys, combined with a UA that has
702 noted true pins with a high max-age value and has not had a chance to
703 observe the new true pins for the Host. (This last example
704 underscores the importance for Host operators to phase in new keys
705 gradually, and to set the max-age value in accordance with their
706 planned key migration schedule.)
708 There is probably no ideal upper limit to the max-age directive that
709 would satisfy all use cases. However, a value on the order of 60
710 days (5184000 seconds) may be considered a balance between the two
711 competing security concerns.
713 4.2. Using includeSubDomains Safely
715 It may happen that Pinned Hosts whose hostnames share a parent domain
716 use different Valid Pinning Headers. If a Host whose hostname is a
717 parent domain for another Host sets the includeSubDomains directive,
718 the two Hosts' pins may conflict with each other. For example,
719 consider two Known Pinned Hosts, example.com and
720 subdomain.example.com. Assume example.com sets a Valid Pinning
721 Header such as this:
723 Public-Key-Pins: pin-sha1="ABC..."; pin-sha1="DEF..."; includeSubDomains
725 Figure 7: example.com Valid Pinning Header
727 Assume subdomain.example.com sets a Valid Pinning Header such as
728 this:
730 Public-Key-Pins: pin-sha1="GHI..."; pin-sha1="JKL..."
732 Figure 8: subdomain.example.com Valid Pinning Header
734 Assume a UA that has not previously noted any pins for either of
735 these Hosts. If the UA first contacts subdomain.example.com, it will
736 note the pins in the Valid Pinning Header, and perform Pin Validation
737 as normal on subsequent conections. If the UA then contacts
738 example.com, again it will note the pins and perform Pin Validation
739 on future connections. However, if the UA happened to first
740 example.com before subdomain.example.com, the UA would, due to
741 example.com's use of the includeSubDomains directive, attempt to
742 perform Pin Validation for subdomain.example.com using the SPKI
743 hashes ABC... and DEF..., which are not valid for the certificate
744 chains subdomain.example.com (which uses certificates with SPKIs
745 GHI... and JLK...). Thus, depending on the order in which the UA
746 observes the Valid Pinning Headers for hosts example.com and
747 subdomain.example.com, Pin Validation might or might not fail for
748 subdomain.example.com, even if the certificate chain the UA receives
749 for subdomain.example.com is perfectly valid.
751 Thus, Pinned Host operators must use the includeSubDomains directive
752 with care. For example, they may choose to use overlapping pin sets
753 for hosts under a parent domain that uses includeSubDomains, or to
754 not use the includeSubDomains directive in their effective-second-
755 level domains, or to simply use the same pin set for all hosts under
756 a given parent domain.
758 4.3. Backup Pins
760 The primary way to cope with the risk of inadvertent Pin Failure is
761 to keep a Backup Pin. A Backup Pin is a fingerprint for the public
762 key of a secondary, not-yet-deployed key pair. The operator keeps
763 the backup key pair offline, and sets a pin for it in the Public-Key-
764 Pins header. Then, in case the operator loses control of their
765 primary private key, they can deploy the backup key pair. UAs, who
766 have had the backup key pair pinned (when it was set in previous
767 Valid Pinning Headers), can connect to the host without error.
769 Because having a backup key pair is so important to recovery, UAs
770 MUST require that hosts set a Backup Pin. (See Section 2.5.)
772 5. Privacy Considerations
774 Conforming implementations (as well as implementations conforming to
775 [RFC6797]) must store state about which domains have set policies,
776 hence which domains the UA has contacted. A forensic attacker might
777 find this information useful, even if the user has cleared other
778 parts of the UA's state.
780 More importantly, Hosts can use HSTS or HPKP as a "super-cookie", by
781 setting distinct policies for a number of subdomains. For example,
782 assume example.com wishes to track distinct UAs without explicitly
783 setting a cookie, or if a previously-set cookie is deleted from the
784 UA's cookie store. Here are two attack scenarios.
786 1. example.com can use report-uri and the ability to pin arbitrary
787 identifiers to distinguish UAs.
789 2.
791 1. example.com sets a Valid Pinning Header in its response to
792 requests. The header asserts the includeSubDomains
793 directive, and specifies a report-uri directive as well.
794 Pages served by the host also include references to
795 subresource https://bad.example.com/foo.png.
797 2. The Valid Pinning Header includes a "pin" that is not really
798 the hash of an SPKI, but is instead an arbitrary
799 distinguishing string sent only in response to a particular
800 request. For each request, the Host creates a new, distinct
801 distinguishing string and sets it as if it were a pin.
803 3. The certificate chain served by bad.example.com does not pass
804 Pin Validation given the pin set the Host asserted in (1).
805 The HPKP-conforming UA attempts to report the Pin Validation
806 failure to the specified report-uri, including the
807 certificate chain it observed and the SPKI hashes it expected
808 to see. Among the SPKI hashes is the distinguishing string
809 in step (2).
811 3. example.com can use SNI and subdomains to distinguish UAs.
813 4.
815 1. example.com sets a Valid Pinning Header in its response to
816 requests. The header asserts the includeSubDomains
817 directive.
819 2. On a subsequent page view, the Host responds with a page
820 including the subresource https://0.fingerprint.example.com/
821 foo.png, and the server responds using a certificate chain
822 that does not pass Pin Validation for the pin-set defined in
823 the Valid Pinning Header in step (1). The HPKP-conforming UA
824 will close the connection, never completing the request to
825 0.fingerprint.example.com. The Host may thus note that this
826 particular UA had noted the (good) pins for that subdomain.
828 3. example.com can distinguish 2^N UAs by serving Valid Pinning
829 Headers from an arbitrary number N distinct subdomains,
830 giving some UAs Valid Pinning Headers for some, but not all
831 subdomains (causing subsequent requests for
832 n.fingerprint.example.com to fail), and giving some UAs no
833 Valid Pinning Header for other subdomains (causing subsequent
834 requests for m.fingerprint.example.com to succeed).
836 6. IANA Considerations
837 IANA is requested to register the header described in this document
838 in the "Message Headers" registry, with the following parameters:
840 o Header Field Name should be "Public-Key-Pins"
842 o Protocol should be "http"
844 o Status should be "standard"
846 o Reference should be this document
848 7. Usability Considerations
850 When pinning works to detect impostor Pinned Hosts, users will
851 experience denial of service. UAs MUST explain the reason why, i.e.
852 that it was impossible to verify the confirmed cryptographic identity
853 of the host.
855 UAs MUST have a way for users to clear current pins for Pinned Hosts.
856 UAs SHOULD have a way for users to query the current state of Pinned
857 Hosts.
859 8. Acknowledgements
861 Thanks to Tobias Gondrom, Jeff Hodges, Ivan Krstic, Adam Langley,
862 Nicolas Lidzborski, SM, James Manger, Eric Rescorla, Paul Hoffman,
863 and Yoav Nir for suggestions and edits that clarified the text.
864 Thanks to Trevor Perrin for suggesting a mechanism to affirmatively
865 break pins ([pin-break-codes]).
867 9. What's Changed
869 [RFC EDITOR: PLEASE REMOVE THIS SECTION]
871 Removed the requirement that the server set the Valid Pinning Header
872 on every response.
874 Added normative references for SHA, JSON, and base-64.
876 Added the Privacy Considerations section.
878 Changed non-normative pin generation code from Go to POSIX shell
879 script using openssl.
881 Changed max-max-age from SHOULD to MAY, and used the example of 60
882 days instead of 30.
884 Removed the section "Pin Validity Times", which was intended to be in
885 harmony with [I-D.perrin-tls-tack]. Now using max-age purely as
886 specified in [RFC6797].
888 Added new directives: includeSubDomains, report-uri and strict.
890 Added a new variant of the PKP Header: Public-Key-Pins-Report-Only.
892 Removed the section on pin break codes and verifiers, in favor the of
893 most-recently-received policy (Section 2.5).
895 Now using a new header field, Public-Key-Pins, separate from HSTS.
896 This allows hosts to use pinning separately from Strict Transport
897 Security.
899 Explicitly requiring that UAs perform Pin Validation before the HTTP
900 conversation begins.
902 Backup Pins are now required.
904 Separated normative from non-normative material. Removed tangential
905 and out-of-scope non-normative discussion.
907 10. References
909 10.1. Normative References
911 [I-D.josefsson-pkix-textual]
912 Josefsson, S. and S. Leonard, "Text Encodings of PKIX and
913 CMS Structures", draft-josefsson-pkix-textual-02 (work in
914 progress), October 2013.
916 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
917 Requirement Levels", BCP 14, RFC 2119, March 1997.
919 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
920 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
921 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
923 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the
924 Internet: Timestamps", RFC 3339, July 2002.
926 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
927 Resource Identifier (URI): Generic Syntax", STD 66, RFC
928 3986, January 2005.
930 [RFC4627] Crockford, D., "The application/json Media Type for
931 JavaScript Object Notation (JSON)", RFC 4627, July 2006.
933 [RFC4634] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
934 (SHA and HMAC-SHA)", RFC 4634, July 2006.
936 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
937 Encodings", RFC 4648, October 2006.
939 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
940 Encodings", RFC 4648, October 2006.
942 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
943 IANA Considerations Section in RFCs", BCP 26, RFC 5226,
944 May 2008.
946 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
947 (TLS) Protocol Version 1.2", RFC 5246, August 2008.
949 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
950 Housley, R., and W. Polk, "Internet X.509 Public Key
951 Infrastructure Certificate and Certificate Revocation List
952 (CRL) Profile", RFC 5280, May 2008.
954 [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
955 Transport Security (HSTS)", RFC 6797, November 2012.
957 [W3C.REC-html401-19991224]
958 Hors, A., Raggett, D., and I. Jacobs, "HTML 4.01
959 Specification", World Wide Web Consortium Recommendation
960 REC-html401-19991224, December 1999,
961 .
963 10.2. Informative References
965 [I-D.perrin-tls-tack]
966 Marlinspike, M., "Trust Assertions for Certificate Keys",
967 draft-perrin-tls-tack-02 (work in progress), January 2013.
969 [pin-break-codes]
970 Perrin, T., "Self-Asserted Key Pinning", September 2011,
971 .
973 [why-pin-key]
974 Langley, A., "Public Key Pinning", May 2011,
975 .
977 Appendix A. Fingerprint Generation
979 This POSIX shell program generates SPKI Fingerprints, suitable for
980 use in pinning, from PEM-encoded certificates. It is non-normative.
982 openssl x509 -noout -in certificate.pem -pubkey | \
983 openssl asn1parse -inform pem -out public.key
984 openssl dgst -sha1 -binary public.key | base64
986 Figure 9: Example SPKI Fingerprint Generation Code
988 Appendix B. Deployment Guidance
990 This section is non-normative guidance which may smooth the adoption
991 of public key pinning.
993 o Operators SHOULD get the backup public key signed by a different
994 (root and/or intermediary) CA than their primary certificate, and
995 store the backup key pair safely offline. The semantics of an
996 SPKI Fingerprint do not require the issuance of a certificate to
997 construct a valid Pin. However, in many deployment scenarios, in
998 order to make a Backup Pin operational the server operator will
999 need to have a certificate to deploy TLS on the host. Failure to
1000 obtain a certificate through prior arrangement will leave clients
1001 that recognize the site as a Known Pinned Host unable to
1002 successfully perform Pin Validation until such a time as the
1003 operator can obtain a new certificate from their desired
1004 certificate issuer.
1006 o It is most economical to have the backup certificate signed by a
1007 completely different signature chain than the live certificate, to
1008 maximize recoverability in the event of either root or
1009 intermediary signer compromise.
1011 o Operators SHOULD periodically exercise their Backup Pin plan
1012 -\u002D an untested backup is no backup at all.
1014 o Operators SHOULD start small. Operators SHOULD first deploy
1015 public key pinning by using the report-only mode together with a
1016 report-uri directive that points to a reliable report collection
1017 endpoint. When moving out of report-only mode, operators should
1018 start by setting a max-age of minutes or a few hours, and
1019 gradually increase max-age as they gain confidence in their
1020 operational capability.
1022 Authors' Addresses
1023 Chris Evans
1024 Google, Inc.
1025 1600 Amphitheatre Pkwy
1026 Mountain View, CA 94043
1027 US
1029 Email: cevans@google.com
1031 Chris Palmer
1032 Google, Inc.
1033 1600 Amphitheatre Pkwy
1034 Mountain View, CA 94043
1035 US
1037 Email: palmer@google.com
1039 Ryan Sleevi
1040 Google, Inc.
1041 1600 Amphitheatre Pkwy
1042 Mountain View, CA 94043
1043 US
1045 Email: sleevi@google.com