idnits 2.17.1
draft-ietf-websec-key-pinning-10.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 4 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 (February 6, 2014) is 3730 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 941, 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: August 10, 2014 Google, Inc.
6 February 6, 2014
8 Public Key Pinning Extension for HTTP
9 draft-ietf-websec-key-pinning-10
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 August 10, 2014.
41 Copyright Notice
43 Copyright (c) 2014 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. Examples . . . . . . . . . . . . . . . . . . . . . . 6
66 2.2. Server Processing Model . . . . . . . . . . . . . . . . . 7
67 2.2.1. HTTP-over-Secure-Transport Request Type . . . . . . . 7
68 2.2.2. HTTP Request Type . . . . . . . . . . . . . . . . . . 8
69 2.3. User Agent Processing Model . . . . . . . . . . . . . . . 8
70 2.3.1. Public-Key-Pins Response Header Field Processing . . 8
71 2.3.2. Noting a Pinned Host - Storage Model . . . . . . . . 9
72 2.3.3. HTTP-Equiv Element Attribute . . . . . . . . . 10
73 2.4. Semantics of Pins . . . . . . . . . . . . . . . . . . . . 10
74 2.5. Noting Pins . . . . . . . . . . . . . . . . . . . . . . . 11
75 2.6. Validating Pinned Connections . . . . . . . . . . . . . . 12
76 2.7. Interactions With Preloaded Pin Lists . . . . . . . . . . 12
77 2.8. Pinning Self-Signed End Entities . . . . . . . . . . . . 13
78 3. Reporting Pin Validation Failure . . . . . . . . . . . . . . 13
79 4. Security Considerations . . . . . . . . . . . . . . . . . . . 15
80 4.1. Maximum max-age . . . . . . . . . . . . . . . . . . . . . 15
81 4.2. Using includeSubDomains Safely . . . . . . . . . . . . . 16
82 4.3. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 17
83 5. Privacy Considerations . . . . . . . . . . . . . . . . . . . 17
84 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18
85 7. Usability Considerations . . . . . . . . . . . . . . . . . . 19
86 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 19
87 9. What's Changed . . . . . . . . . . . . . . . . . . . . . . . 19
88 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 20
89 10.1. Normative References . . . . . . . . . . . . . . . . . . 20
90 10.2. Informative References . . . . . . . . . . . . . . . . . 21
91 Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 21
92 Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . 22
93 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 22
95 1. Introduction
97 We propose a new HTTP header to enable a web host to express to user
98 agents (UAs) which Subject Public Key Info (SPKI) structure(s) UAs
99 SHOULD expect to be present in the host's certificate chain in future
100 connections using TLS (see [RFC5246]). We call this "public key
101 pinning". At least one UA (Google Chrome) has experimented with the
102 idea by shipping with a user-extensible embedded set of pins.
103 Although effective, this does not scale. This proposal addresses the
104 scale problem.
106 Deploying public key pinning safely will require operational and
107 organizational maturity due to the risk that hosts may make
108 themselves unavailable by pinning to a SPKI that becomes invalid.
109 (See Section 4.) We believe that, with care, host operators can
110 greatly reduce the risk of MITM attacks and other false-
111 authentication problems for their users without incurring undue risk.
113 We intend for hosts to use public key pinning together with HSTS
114 ([RFC6797]), but is possible to pin keys without requiring HSTS.
116 This draft is being discussed on the WebSec Working Group mailing
117 list, websec@ietf.org.
119 1.1. Requirements Language
121 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
122 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
123 document are to be interpreted as described in RFC 2119 [RFC2119].
125 2. Server and Client Behavior
127 2.1. Response Header Field Syntax
129 The Public-Key-Pins HTTP response header field (PKP header field)
130 indicates to a UA that it should perform Pin Validation (Section 2.6)
131 in regards to the host emitting the response message containing this
132 header field, and provides the necessary information for the UA to do
133 so.
135 Figure 1 describes the ABNF (Augmented Backus-Naur Form) syntax of
136 the header field. It is based on the Generic Grammar defined in
137 Section 2 of [RFC2616] (which includes a notion of "implied linear
138 whitespace", also known as "implied *LWS").
140 Public-Key-Pins =
141 "Public-Key-Pins" ":" [ directive ] *( ";" [ directive ] )
142 Public-Key-Pins-Report-Only =
143 "Public-Key-Pins-Report-Only" ":" [ directive ] *( ";" [ directive ] )
145 directive = simple-directive
146 / pin-directive
148 simple-directive = directive-name [ "=" directive-value ]
149 directive-name = token
150 directive-value = token
151 / quoted-string
153 pin-directive = "pin-" token "=" quoted-string
155 Figure 1: HPKP Header Syntax
157 token and quoted-string are used as defined in [RFC2616],
158 Section 2.2.
160 The directives defined in this specification are described below.
161 The overall requirements for directives are:
163 1. The order of appearance of directives is not significant.
165 2. All simple-directives MUST appear only once in a PKP header
166 field. Directives are either optional or required, as stipulated
167 in their definitions.
169 3. Directive names are case-insensitive.
171 4. UAs MUST ignore any PKP header fields containing directives, or
172 other header field value data, that do not conform to the syntax
173 defined in this specification.
175 5. If a PKP header field contains any directive(s) the UA does not
176 recognize, the UA MUST ignore the those directives.
178 6. If the PKP header field otherwise satisfies the above
179 requirements (1 through 5), the UA MUST process the directives it
180 recognizes.
182 Additional directives extending the semantic functionality of the PKP
183 header field can be defined in other specifications, with a registry
184 (having an IANA policy definition of IETF Review [RFC2616]) defined
185 for them at such time. Such future directives will be ignored by UAs
186 implementing only this specification, as well as by generally non-
187 conforming UAs.
189 In the pin-directive, the token is the name of a cryptographic hash
190 algorithm, and MUST be "sha256". (In the future, additional hash
191 algorithms MAY be registered and used.) The quoted-string is a
192 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. Examples
275 Figure 3 shows some example response header fields using the pins
276 extension (folded for clarity).
278 "d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="
279 "E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
280 Public-Key-Pins: max-age=3000;
281 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
282 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
284 Public-Key-Pins: max-age=2592000;
285 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
286 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
288 Public-Key-Pins: max-age=2592000;
289 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
290 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
291 report-uri="http://example.com/pkp-report"
293 Public-Key-Pins-Report-Only: max-age=2592000;
294 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
295 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
296 report-uri="http://example.com/pkp-report"
298 Public-Key-Pins:
299 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
300 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
301 max-age=259200
303 Public-Key-Pins:
304 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
305 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
306 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
307 max-age=10000; includeSubDomains
309 Figure 3: HPKP Header Examples
311 2.2. Server Processing Model
313 This section describes the processing model that Pinned Hosts
314 implement. The model comprises two facets: the processing rules for
315 HTTP request messages received over a secure transport (e.g. TLS
316 [RFC5246]); and the processing rules for HTTP request messages
317 received over non-secure transports, such as TCP.
319 2.2.1. HTTP-over-Secure-Transport Request Type
321 When replying to an HTTP request that was conveyed over a secure
322 transport, a Pinned Host SHOULD include in its response exactly one
323 PKP header field that MUST satisfy the grammar specified above in
324 Section 2.1.
326 Establishing a given host as a Known Pinned Host, in the context of a
327 given UA, MAY be accomplished over the HTTP protocol, which is in
328 turn running over secure transport, by correctly returning (per this
329 specification) at least one valid PKP header field to the UA. Other
330 mechanisms, such as a client-side pre-loaded Known Pinned Host list
331 MAY also be used.
333 2.2.2. HTTP Request Type
335 Pinned Hosts SHOULD NOT include the PKP header field in HTTP
336 responses conveyed over non-secure transport. UAs MUST ignore any
337 PKP header received in an HTTP response conveyed over non-secure
338 transport.
340 2.3. User Agent Processing Model
342 This section describes the HTTP Public Key Pinning processing model
343 for UAs.
345 The UA processing model relies on parsing domain names. Note that
346 internationalized domain names SHALL be canonicalized according to
347 the scheme in Section 10 of [RFC6797].
349 2.3.1. Public-Key-Pins Response Header Field Processing
351 If the UA receives, over a secure transport, an HTTP response that
352 includes a PKP header field conforming to the grammar specified in
353 Section 2.1, and there are no underlying secure transport errors or
354 warnings (see Section 2.5), the UA MUST either:
356 o Note the host as a Known Pinned Host if it is not already so noted
357 (see Section 2.3.2),
359 or,
361 o Update the UA's cached information for the Known Pinned Host if
362 any of of the max-age, includeSubDomains, or report-uri header
363 field value directives convey information different than that
364 already maintained by the UA.
366 o The max-age value is essentially a "time to live" value relative
367 to the time of the most recent observation of the PKP header
368 field.
370 o If the max-age header field value token has a value of 0, the UA
371 MUST remove its cached Pinning Policy information (including the
372 includeSubDomains directive, if asserted) if the Pinned Host is
373 Known, or, MUST NOT note this Pinned Host if it is not yet Known.
375 o If a UA receives more than one PKP header field in an HTTP
376 response message over secure transport, then the UA MUST process
377 only the first such header field.
379 Otherwise:
381 o If the UA receives the HTTP response over insecure transport, or
382 if the PKP header is not a Valid Pinning Header (see Section 2.5),
383 the UA MUST ignore any present PKP header field(s).
385 o The UA MUST ignore any PKP header fields not conforming to the
386 grammar specified in Section 2.1.
388 2.3.2. Noting a Pinned Host - Storage Model
390 The Effective Pin Date of a Known Pinned Host is the time that the UA
391 observed a Valid Pinning Header for the host. The Effective
392 Expiration Date of a Known Pinned Host is the Effective Pin Date plus
393 the max-age. A Known Pinned Host is "expired" if the Effective
394 Expiration Date refers to a date in the past. The UA MUST ignore all
395 expired Known Pinned Hosts from its cache if, at any time, an expired
396 Known Pinned Host exists in the cache.
398 If the substring matching the host production from the Request-URI
399 (of the message to which the host responded) syntactically matches
400 the IP-literal or IPv4address productions from Section 3.2.2 of
401 [RFC3986], then the UA MUST NOT note this host as a Known Pinned
402 Host.
404 Otherwise, if the substring does not congruently match a Known Pinned
405 Host's domain name, per the matching procedure specified in
406 Section 8.2 of [RFC6797], then the UA MUST note this host as a Known
407 Pinned Host, caching the Pinned Host's domain name and noting along
408 with it the Effective Expiration Date (or enough information to
409 calculate it, i.e. the Effective Pin Date and the value of the max-
410 age directive), whether or not the includeSubDomains directive is
411 asserted, the value of the report-uri directive (if present). If any
412 other metadata from optional or future PKP header directives is
413 present in the Valid Pinning Header, the UA MAY note them if it
414 understands them, and need not note them if it does not understand
415 them.
417 UAs MAY set an upper limit on the value of max-age, so that UAs that
418 have noted erroneous pins (whether by accident or due to attack) have
419 some chance of recovering over time. If the server sets a max-age
420 greater than the UA's upper limit, the UA MAY behave as if the server
421 set the max-age to the UA's upper limit. For example, if the UA caps
422 max-age at 5184000 seconds (60 days), and a Pinned Host sets a max-
423 age directive of 90 days in its Valid Pinning Header, the UA MAY
424 behave as if the max-age were effectively 60 days. (One way to
425 achieve this behavior is for the UA to simply store a value of 60
426 days instead of the 90 day value provided by the Pinned Host.) For
427 UA implementation guidance on how to select a maximum max-age, see
428 Section 4.1.
430 The UA MUST NOT modify any pinning metadata of any superdomain
431 matched Known Pinned Host.
433 2.3.3. HTTP-Equiv Element Attribute
435 UAs MUST NOT heed http-equiv="Public-Key-Pins" attribute settings on
436 elements [W3C.REC-html401-19991224] in received content.
438 2.4. Semantics of Pins
440 An SPKI Fingerprint is defined as the output of a known cryptographic
441 hash algorithm whose input is the DER-encoded ASN.1 representation of
442 the SubjectPublicKeyInfo (SPKI) field of an X.509 certificate. A Pin
443 is defined as the combination of the known algorithm identifier and
444 the SPKI Fingerprint computed using that algorithm.
446 The SPKI Fingerprint is encoded in base 64 for use in an HTTP header.
447 (See [RFC4648].)
449 In this version of the specification, the known cryptographic hash
450 algorithm is SHA-256, identified as "sha256" ([RFC4634]). (Future
451 versions of this specification may add new algorithms and deprecate
452 old ones.) UAs MUST ignore Pins for which they do not recognize the
453 algorithm identifier. UAs MUST continue to process the rest of a PKP
454 response header field and note Pins for algorithms they do recognize;
455 UAs MUST recognize and "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 given in the most recently received Valid Pinning Header.
515 For forward compatibility, the UA MUST ignore any unrecognized
516 Public-Key-Pins header directives, while still processing those
517 directives it does recognize. Section 2.1 specifies the directives
518 max-age, pins, includeSubDomains, and report-uri but future
519 specifications and implementations might use additional directives.
521 2.6. Validating Pinned Connections
523 When a UA connects to a Pinned Host, if the TLS connection has
524 errors, the UA MUST terminate the connection without allowing the
525 user to proceed anyway. (This behavior is the same as that required
526 by [RFC6797].)
528 If the connection has no errors, then the UA will determine whether
529 to apply a new, additional correctness check: Pin Validation. A UA
530 SHOULD perform Pin Validation whenever connecting to a Known Pinned
531 Host, but MAY allow Pin Validation to be disabled for Hosts according
532 to local policy. For example, a UA may disable Pin Validation for
533 Pinned Hosts whose validated certificate chain terminates at a user-
534 defined trust anchor, rather than a trust anchor built-in to the UA.
536 To perform Pin Validation, the UA will compute the SPKI Fingerprints
537 for each certificate in the Pinned Host's validated certificate
538 chain, using each supported hash algorithm for each certificate.
539 (For the purposes of Pin Validation, the UA MUST ignore certificates
540 whose SPKI cannot be taken in isolation, and MUST ignore superfluous
541 certificates in the chain that do not form part of the validating
542 chain.) The UA will then check that the set of these SPKI
543 Fingerprints intersects the set of SPKI Fingerprints in that Pinned
544 Host's Pinning Metadata. If there is set intersection, the UA
545 continues with the connection as normal. Otherwise, the UA MUST
546 treat this Pin Failure as a non-recoverable error. Any procedure
547 that matches the results of this Pin Validation procedure is
548 considered equivalent.
550 Note that, although the UA has previously received Pins at the HTTP
551 layer, it can and MUST perform Pin Validation at the TLS layer,
552 before beginning an HTTP conversation over the TLS channel. The TLS
553 layer thus evaluates TLS connections with pinning information the UA
554 received previously, regardless of mechanism: statically preloaded,
555 via HTTP header, or some other means (possibly in the TLS layer
556 itself).
558 2.7. Interactions With Preloaded Pin Lists
560 UAs MAY choose to implement additional sources of pinning
561 information, such as through built-in lists of pinning information.
562 Such UAs SHOULD allow users to override such additional sources,
563 including disabling them from consideration.
565 UAs that support additional sources of pinning information MUST use
566 the most recently observed pinning information when performing Pin
567 Validation for a host. The most recently observed pinning
568 information is determined based upon the most recent Effective Pin
569 Date, as described in Section 2.3.2.
571 If the result of noting a Valid Pinning Header is to disable pinning
572 for the host, such as through supplying a max-age directive with a
573 value of 0, UAs MUST allow this new information to override any other
574 pinning data. That is, a host must be able to un-pin itself, even in
575 the presence of built-in pins.
577 Example: A UA may ship with a pre-configured list of pins that are
578 collected from past observations of Valid Pinning Headers supplied by
579 hosts. In such a solution, the pre-configured list should track when
580 the Valid Pinning Header was last observed, in order to permit site
581 operators to later update the value by supplying a new Valid Pinning
582 Header. Updates to such a pre-configured list should not update the
583 Effective Pin Dates for each host unless the list vendor has actually
584 observed a more recent header. This is to prevent situations where
585 updating the Effective Pin Date on a pre-configured list of pins may
586 effectively extend the max-age beyond the site operator's stated
587 policy.
589 Example: A UA may ship with a pre-configured list of pins that are
590 collected through out-of-band means, such as direct contact with the
591 site operator. In such a solution, the site operator accepts
592 responsibility for keeping the configured Valid Pinning Header in
593 sync with the vendor's list, allowing the UA vendor to have each
594 update to the list be treated as as an update of the Effective Pin
595 Date.
597 2.8. Pinning Self-Signed End Entities
599 If UAs accept hosts that authenticate themselves with self-signed end
600 entity certificates, they MAY also allow hosts to pin the public keys
601 in such certificates. The usability and security implications of
602 this practice are outside the scope of this specification.
604 3. Reporting Pin Validation Failure
606 When a Known Pinned Host has set the report-uri directive, the UA
607 SHOULD report Pin Validation failures to the indicated URI. The UA
608 does this by POSTing a JSON ([RFC4627]) message to the URI; the JSON
609 message takes this form:
611 {
612 "date-time": date-time,
613 "hostname": hostname,
614 "port": port,
615 "certificate-chain": [
616 pem1, ... pemN
617 ],
618 "known-pins": [
619 known-pin1, ... known-pinN
620 ]
621 }
623 Figure 5: JSON Report Format
625 Whitespace outside of quoted strings is not significant. The key/
626 value pairs may appear in any order, but each SHOULD appear only
627 once.
629 The date-time indicates the time the UA observed the Pin Validation
630 failure. It is provided as a string formatted according to
631 Section 5.6, "Internet Date/Time Format", of [RFC3339].
633 The hostname is the hostname to which the UA made the original
634 request that failed Pin Validation. It is provided as a string.
636 The port is the port to which the UA made the original request that
637 failed Pin Validation. It is provided either as a string or as an
638 integer.
640 The certificate-chain is the certificate chain, as constructed by the
641 UA during certificate chain verification. (This may differ from the
642 certificate chain as served by the Known Pinned Host, of course.) It
643 is provided as an array of strings; each string pem1, ... pemN is the
644 PEM representation of each X.509 certificate as described in
645 [I-D.josefsson-pkix-textual].
647 The known-pins are the Pins that the UA has noted for the Known
648 Pinned Host. They are provided as an array of strings with the
649 syntax:
651 known-pin = token "=" quoted-string
653 Figure 6: Known Pin Syntax
655 As in Section 2.4, the token refers to the algorithm name, and the
656 quoted-string refers to the base 64 encoding of the SPKI Fingerprint.
658 4. Security Considerations
660 Pinning public keys helps hosts strongly assert their cryptographic
661 identity even in the face of issuer error, malfeasance or compromise.
662 But there is some risk that a host operator could lose or lose
663 control of their host's private key (such as by operator error or
664 host compromise). If the operator had pinned only the key of the
665 host's end entity certificate, the operator would not be able to
666 serve their web site or application in a way that UAs would trust for
667 the duration of their pin's max-age. (Recall that UAs MUST close the
668 connection to a host upon Pin Failure.)
670 Therefore, there is a necessary trade-off between two competing
671 goods: pin specificity and maximal reduction of the scope of issuers
672 on the one hand; and flexibility and resilience of the host's
673 cryptographic identity on the other hand. One way to resolve this
674 trade-off is to compromise by pinning to the key(s) of the issuer(s)
675 of the host's end entity certificate(s). Often, a valid certificate
676 chain will have at least two certificates above the end entity
677 certificate: the intermediate issuer, and the trust anchor.
678 Operators can pin any one or more of the public keys in this chain,
679 and indeed could pin to issuers not in the chain (as, for example, a
680 Backup Pin). Pinning to an intermediate issuer, or even to a trust
681 anchor or root, still significantly reduces the number of issuers who
682 can issue end entity certificates for the Known Pinned Host, while
683 still giving that host flexibility to change keys without a
684 disruption of service.
686 4.1. Maximum max-age
688 As mentioned in Section 2.3.2, UAs MAY cap the max-age value at some
689 upper limit. There is a security trade-off in that low maximum
690 values provide a narrow window of protection for users who visit the
691 Known Pinned Host only infrequently, while high maximum values might
692 potentially result in a UA's inability to successfully perform Pin
693 Validation for a Known Pinned Host if the UA's noted pins and the
694 Host's true pins diverge.
696 Such divergence could occur for several reasons, including: UA error;
697 Host operator error; network attack; or a Known Pinned Host that
698 intentionally migrates all pinned keys, combined with a UA that has
699 noted true pins with a high max-age value and has not had a chance to
700 observe the new true pins for the Host. (This last example
701 underscores the importance for Host operators to phase in new keys
702 gradually, and to set the max-age value in accordance with their
703 planned key migration schedule.)
704 There is probably no ideal upper limit to the max-age directive that
705 would satisfy all use cases. However, a value on the order of 60
706 days (5184000 seconds) may be considered a balance between the two
707 competing security concerns.
709 4.2. Using includeSubDomains Safely
711 It may happen that Pinned Hosts whose hostnames share a parent domain
712 use different Valid Pinning Headers. If a Host whose hostname is a
713 parent domain for another Host sets the includeSubDomains directive,
714 the two Hosts' pins may conflict with each other. For example,
715 consider two Known Pinned Hosts, example.com and
716 subdomain.example.com. Assume example.com sets a Valid Pinning
717 Header such as this:
719 Public-Key-Pins: pin-sha256="ABC..."; pin-sha256="DEF..."; includeSubDomains
721 Figure 7: example.com Valid Pinning Header
723 Assume subdomain.example.com sets a Valid Pinning Header such as
724 this:
726 Public-Key-Pins: pin-sha256="GHI..."; pin-sha256="JKL..."
728 Figure 8: subdomain.example.com Valid Pinning Header
730 Assume a UA that has not previously noted any pins for either of
731 these Hosts. If the UA first contacts subdomain.example.com, it will
732 note the pins in the Valid Pinning Header, and perform Pin Validation
733 as normal on subsequent conections. If the UA then contacts
734 example.com, again it will note the pins and perform Pin Validation
735 on future connections. However, if the UA happened to first
736 example.com before subdomain.example.com, the UA would, due to
737 example.com's use of the includeSubDomains directive, attempt to
738 perform Pin Validation for subdomain.example.com using the SPKI
739 hashes ABC... and DEF..., which are not valid for the certificate
740 chains subdomain.example.com (which uses certificates with SPKIs
741 GHI... and JLK...). Thus, depending on the order in which the UA
742 observes the Valid Pinning Headers for hosts example.com and
743 subdomain.example.com, Pin Validation might or might not fail for
744 subdomain.example.com, even if the certificate chain the UA receives
745 for subdomain.example.com is perfectly valid.
747 Thus, Pinned Host operators must use the includeSubDomains directive
748 with care. For example, they may choose to use overlapping pin sets
749 for hosts under a parent domain that uses includeSubDomains, or to
750 not use the includeSubDomains directive in their effective-second-
751 level domains, or to simply use the same pin set for all hosts under
752 a given parent domain.
754 4.3. Backup Pins
756 The primary way to cope with the risk of inadvertent Pin Failure is
757 to keep a Backup Pin. A Backup Pin is a fingerprint for the public
758 key of a secondary, not-yet-deployed key pair. The operator keeps
759 the backup key pair offline, and sets a pin for it in the Public-Key-
760 Pins header. Then, in case the operator loses control of their
761 primary private key, they can deploy the backup key pair. UAs, who
762 have had the backup key pair pinned (when it was set in previous
763 Valid Pinning Headers), can connect to the host without error.
765 Because having a backup key pair is so important to recovery, UAs
766 MUST require that hosts set a Backup Pin. (See Section 2.5.)
768 5. Privacy Considerations
770 Conforming implementations (as well as implementations conforming to
771 [RFC6797]) must store state about which domains have set policies,
772 hence which domains the UA has contacted. A forensic attacker might
773 find this information useful, even if the user has cleared other
774 parts of the UA's state.
776 More importantly, Hosts can use HSTS or HPKP as a "super-cookie", by
777 setting distinct policies for a number of subdomains. For example,
778 assume example.com wishes to track distinct UAs without explicitly
779 setting a cookie, or if a previously-set cookie is deleted from the
780 UA's cookie store. Here are two attack scenarios.
782 1. example.com can use report-uri and the ability to pin arbitrary
783 identifiers to distinguish UAs.
785 2.
787 1. example.com sets a Valid Pinning Header in its response to
788 requests. The header asserts the includeSubDomains
789 directive, and specifies a report-uri directive as well.
790 Pages served by the host also include references to
791 subresource https://bad.example.com/foo.png.
793 2. The Valid Pinning Header includes a "pin" that is not really
794 the hash of an SPKI, but is instead an arbitrary
795 distinguishing string sent only in response to a particular
796 request. For each request, the Host creates a new, distinct
797 distinguishing string and sets it as if it were a pin.
799 3. The certificate chain served by bad.example.com does not pass
800 Pin Validation given the pin set the Host asserted in (1).
801 The HPKP-conforming UA attempts to report the Pin Validation
802 failure to the specified report-uri, including the
803 certificate chain it observed and the SPKI hashes it expected
804 to see. Among the SPKI hashes is the distinguishing string
805 in step (2).
807 3. example.com can use SNI and subdomains to distinguish UAs.
809 4.
811 1. example.com sets a Valid Pinning Header in its response to
812 requests. The header asserts the includeSubDomains
813 directive.
815 2. On a subsequent page view, the Host responds with a page
816 including the subresource https://0.fingerprint.example.com/
817 foo.png, and the server responds using a certificate chain
818 that does not pass Pin Validation for the pin-set defined in
819 the Valid Pinning Header in step (1). The HPKP-conforming UA
820 will close the connection, never completing the request to
821 0.fingerprint.example.com. The Host may thus note that this
822 particular UA had noted the (good) pins for that subdomain.
824 3. example.com can distinguish 2^N UAs by serving Valid Pinning
825 Headers from an arbitrary number N distinct subdomains,
826 giving some UAs Valid Pinning Headers for some, but not all
827 subdomains (causing subsequent requests for
828 n.fingerprint.example.com to fail), and giving some UAs no
829 Valid Pinning Header for other subdomains (causing subsequent
830 requests for m.fingerprint.example.com to succeed).
832 6. IANA Considerations
834 IANA is requested to register the header described in this document
835 in the "Message Headers" registry, with the following parameters:
837 o Header Field Name should be "Public-Key-Pins"
839 o Protocol should be "http"
841 o Status should be "standard"
843 o Reference should be this document
845 7. Usability Considerations
847 When pinning works to detect impostor Pinned Hosts, users will
848 experience denial of service. UAs MUST explain the reason why, i.e.
849 that it was impossible to verify the confirmed cryptographic identity
850 of the host.
852 UAs MUST have a way for users to clear current pins for Pinned Hosts.
853 UAs SHOULD have a way for users to query the current state of Pinned
854 Hosts.
856 8. Acknowledgements
858 Thanks to Tobias Gondrom, Jeff Hodges, Ivan Krstic, Adam Langley,
859 Nicolas Lidzborski, SM, James Manger, Eric Rescorla, Paul Hoffman,
860 and Yoav Nir for suggestions and edits that clarified the text.
861 Thanks to Trevor Perrin for suggesting a mechanism to affirmatively
862 break pins ([pin-break-codes]).
864 9. What's Changed
866 [RFC EDITOR: PLEASE REMOVE THIS SECTION]
868 Removed the strict directive.
870 Removed the requirement that the server set the Valid Pinning Header
871 on every response.
873 Added normative references for SHA, JSON, and base-64.
875 Added the Privacy Considerations section.
877 Changed non-normative pin generation code from Go to POSIX shell
878 script using openssl.
880 Changed max-max-age from SHOULD to MAY, and used the example of 60
881 days instead of 30.
883 Removed the section "Pin Validity Times", which was intended to be in
884 harmony with [I-D.perrin-tls-tack]. Now using max-age purely as
885 specified in [RFC6797].
887 Added new directives: includeSubDomains, report-uri and strict.
889 Added a new variant of the PKP Header: Public-Key-Pins-Report-Only.
891 Removed the section on pin break codes and verifiers, in favor the of
892 most-recently-received policy (Section 2.5).
894 Now using a new header field, Public-Key-Pins, separate from HSTS.
895 This allows hosts to use pinning separately from Strict Transport
896 Security.
898 Explicitly requiring that UAs perform Pin Validation before the HTTP
899 conversation begins.
901 Backup Pins are now required.
903 Separated normative from non-normative material. Removed tangential
904 and out-of-scope non-normative discussion.
906 10. References
908 10.1. Normative References
910 [I-D.josefsson-pkix-textual]
911 Josefsson, S. and S. Leonard, "Text Encodings of PKIX and
912 CMS Structures", draft-josefsson-pkix-textual-02 (work in
913 progress), October 2013.
915 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
916 Requirement Levels", BCP 14, RFC 2119, March 1997.
918 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
919 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
920 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
922 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the
923 Internet: Timestamps", RFC 3339, July 2002.
925 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
926 Resource Identifier (URI): Generic Syntax", STD 66, RFC
927 3986, January 2005.
929 [RFC4627] Crockford, D., "The application/json Media Type for
930 JavaScript Object Notation (JSON)", RFC 4627, July 2006.
932 [RFC4634] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
933 (SHA and HMAC-SHA)", RFC 4634, July 2006.
935 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
936 Encodings", RFC 4648, October 2006.
938 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
939 Encodings", RFC 4648, October 2006.
941 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
942 IANA Considerations Section in RFCs", BCP 26, RFC 5226,
943 May 2008.
945 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
946 (TLS) Protocol Version 1.2", RFC 5246, August 2008.
948 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
949 Housley, R., and W. Polk, "Internet X.509 Public Key
950 Infrastructure Certificate and Certificate Revocation List
951 (CRL) Profile", RFC 5280, May 2008.
953 [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
954 Transport Security (HSTS)", RFC 6797, November 2012.
956 [W3C.REC-html401-19991224]
957 Raggett, D., Hors, A., and I. Jacobs, "HTML 4.01
958 Specification", World Wide Web Consortium Recommendation
959 REC-html401-19991224, December 1999,
960 .
962 10.2. Informative References
964 [I-D.perrin-tls-tack]
965 Marlinspike, M., "Trust Assertions for Certificate Keys",
966 draft-perrin-tls-tack-02 (work in progress), January 2013.
968 [pin-break-codes]
969 Perrin, T., "Self-Asserted Key Pinning", September 2011,
970 .
972 [why-pin-key]
973 Langley, A., "Public Key Pinning", May 2011,
974 .
976 Appendix A. Fingerprint Generation
978 This POSIX shell program generates SPKI Fingerprints, suitable for
979 use in pinning, from PEM-encoded certificates. It is non-normative.
981 openssl x509 -noout -in certificate.pem -pubkey | \
982 openssl asn1parse -noout -inform pem -out public.key
983 openssl dgst -sha256 -binary public.key | base64
985 Figure 9: Example SPKI Fingerprint Generation Code
987 Appendix B. Deployment Guidance
989 This section is non-normative guidance which may smooth the adoption
990 of public key pinning.
992 o Operators SHOULD get the backup public key signed by a different
993 (root and/or intermediary) CA than their primary certificate, and
994 store the backup key pair safely offline. The semantics of an
995 SPKI Fingerprint do not require the issuance of a certificate to
996 construct a valid Pin. However, in many deployment scenarios, in
997 order to make a Backup Pin operational the server operator will
998 need to have a certificate to deploy TLS on the host. Failure to
999 obtain a certificate through prior arrangement will leave clients
1000 that recognize the site as a Known Pinned Host unable to
1001 successfully perform Pin Validation until such a time as the
1002 operator can obtain a new certificate from their desired
1003 certificate issuer.
1005 o It is most economical to have the backup certificate signed by a
1006 completely different signature chain than the live certificate, to
1007 maximize recoverability in the event of either root or
1008 intermediary signer compromise.
1010 o Operators SHOULD periodically exercise their Backup Pin plan -- an
1011 untested backup is no backup at all.
1013 o Operators SHOULD start small. Operators SHOULD first deploy
1014 public key pinning by using the report-only mode together with a
1015 report-uri directive that points to a reliable report collection
1016 endpoint. When moving out of report-only mode, operators should
1017 start by setting a max-age of minutes or a few hours, and
1018 gradually increase max-age as they gain confidence in their
1019 operational capability.
1021 Authors' Addresses
1023 Chris Evans
1024 Google, Inc.
1025 1600 Amphitheatre Pkwy
1026 Mountain View, CA 94043
1027 US
1029 Email: cevans@google.com
1030 Chris Palmer
1031 Google, Inc.
1032 1600 Amphitheatre Pkwy
1033 Mountain View, CA 94043
1034 US
1036 Email: palmer@google.com
1038 Ryan Sleevi
1039 Google, Inc.
1040 1600 Amphitheatre Pkwy
1041 Mountain View, CA 94043
1042 US
1044 Email: sleevi@google.com