idnits 2.17.1
draft-ietf-websec-key-pinning-11.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 2 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 8, 2014) is 3731 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 998, 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 12, 2014 Google, Inc.
6 February 8, 2014
8 Public Key Pinning Extension for HTTP
9 draft-ietf-websec-key-pinning-11
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 12, 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 . . . . . . . . . . . . . . . . . . . 16
80 4.1. Maximum max-age . . . . . . . . . . . . . . . . . . . . . 17
81 4.2. Using includeSubDomains Safely . . . . . . . . . . . . . 17
82 4.3. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 18
83 5. Privacy Considerations . . . . . . . . . . . . . . . . . . . 19
84 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20
85 7. Usability Considerations . . . . . . . . . . . . . . . . . . 20
86 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 20
87 9. What's Changed . . . . . . . . . . . . . . . . . . . . . . . 21
88 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 21
89 10.1. Normative References . . . . . . . . . . . . . . . . . . 22
90 10.2. Informative References . . . . . . . . . . . . . . . . . 23
91 Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 23
92 Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . 23
93 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 24
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 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 Public-Key-Pins: max-age=3000;
279 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
280 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
282 Public-Key-Pins: max-age=2592000;
283 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
284 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
286 Public-Key-Pins: max-age=2592000;
287 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
288 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
289 report-uri="http://example.com/pkp-report"
291 Public-Key-Pins-Report-Only: max-age=2592000;
292 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
293 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
294 report-uri="http://example.com/pkp-report"
296 Public-Key-Pins:
297 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
298 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
299 max-age=259200
301 Public-Key-Pins:
302 pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
303 pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
304 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
305 max-age=10000; includeSubDomains
307 Figure 3: HPKP Header Examples
309 2.2. Server Processing Model
311 This section describes the processing model that Pinned Hosts
312 implement. The model comprises two facets: the processing rules for
313 HTTP request messages received over a secure transport (e.g. TLS
314 [RFC5246]); and the processing rules for HTTP request messages
315 received over non-secure transports, such as TCP.
317 2.2.1. HTTP-over-Secure-Transport Request Type
319 When replying to an HTTP request that was conveyed over a secure
320 transport, a Pinned Host SHOULD include in its response exactly one
321 PKP header field that MUST satisfy the grammar specified above in
322 Section 2.1.
324 Establishing a given host as a Known Pinned Host, in the context of a
325 given UA, MAY be accomplished over the HTTP protocol, which is in
326 turn running over secure transport, by correctly returning (per this
327 specification) at least one valid PKP header field to the UA. Other
328 mechanisms, such as a client-side pre-loaded Known Pinned Host list
329 MAY also be used.
331 2.2.2. HTTP Request Type
333 Pinned Hosts SHOULD NOT include the PKP header field in HTTP
334 responses conveyed over non-secure transport. UAs MUST ignore any
335 PKP header received in an HTTP response conveyed over non-secure
336 transport.
338 2.3. User Agent Processing Model
340 This section describes the HTTP Public Key Pinning processing model
341 for UAs.
343 The UA processing model relies on parsing domain names. Note that
344 internationalized domain names SHALL be canonicalized according to
345 the scheme in Section 10 of [RFC6797].
347 2.3.1. Public-Key-Pins Response Header Field Processing
349 If the UA receives, over a secure transport, an HTTP response that
350 includes a PKP header field conforming to the grammar specified in
351 Section 2.1, and there are no underlying secure transport errors or
352 warnings (see Section 2.5), the UA MUST either:
354 o Note the host as a Known Pinned Host if it is not already so noted
355 (see Section 2.3.2),
357 or,
359 o Update the UA's cached information for the Known Pinned Host if
360 any of of the max-age, includeSubDomains, or report-uri header
361 field value directives convey information different than that
362 already maintained by the UA.
364 o The max-age value is essentially a "time to live" value relative
365 to the time of the most recent observation of the PKP header
366 field.
368 o If the max-age header field value token has a value of 0, the UA
369 MUST remove its cached Pinning Policy information (including the
370 includeSubDomains directive, if asserted) if the Pinned Host is
371 Known, or, MUST NOT note this Pinned Host if it is not yet Known.
373 o If a UA receives more than one PKP header field in an HTTP
374 response message over secure transport, then the UA MUST process
375 only the first such header field.
377 Otherwise:
379 o If the UA receives the HTTP response over insecure transport, or
380 if the PKP header is not a Valid Pinning Header (see Section 2.5),
381 the UA MUST ignore any present PKP header field(s).
383 o The UA MUST ignore any PKP header fields not conforming to the
384 grammar specified in Section 2.1.
386 2.3.2. Noting a Pinned Host - Storage Model
388 The Effective Pin Date of a Known Pinned Host is the time that the UA
389 observed a Valid Pinning Header for the host. The Effective
390 Expiration Date of a Known Pinned Host is the Effective Pin Date plus
391 the max-age. A Known Pinned Host is "expired" if the Effective
392 Expiration Date refers to a date in the past. The UA MUST ignore all
393 expired Known Pinned Hosts from its cache if, at any time, an expired
394 Known Pinned Host exists in the cache.
396 If the substring matching the host production from the Request-URI
397 (of the message to which the host responded) syntactically matches
398 the IP-literal or IPv4address productions from Section 3.2.2 of
399 [RFC3986], then the UA MUST NOT note this host as a Known Pinned
400 Host.
402 Otherwise, if the substring does not congruently match a Known Pinned
403 Host's domain name, per the matching procedure specified in
404 Section 8.2 of [RFC6797], then the UA MUST note this host as a Known
405 Pinned Host, caching the Pinned Host's domain name and noting along
406 with it the Effective Expiration Date (or enough information to
407 calculate it, i.e. the Effective Pin Date and the value of the max-
408 age directive), whether or not the includeSubDomains directive is
409 asserted, the value of the report-uri directive (if present). If any
410 other metadata from optional or future PKP header directives is
411 present in the Valid Pinning Header, the UA MAY note them if it
412 understands them, and need not note them if it does not understand
413 them.
415 UAs MAY set an upper limit on the value of max-age, so that UAs that
416 have noted erroneous Pins (whether by accident or due to attack) have
417 some chance of recovering over time. If the server sets a max-age
418 greater than the UA's upper limit, the UA MAY behave as if the server
419 set the max-age to the UA's upper limit. For example, if the UA caps
420 max-age at 5184000 seconds (60 days), and a Pinned Host sets a max-
421 age directive of 90 days in its Valid Pinning Header, the UA MAY
422 behave as if the max-age were effectively 60 days. (One way to
423 achieve this behavior is for the UA to simply store a value of 60
424 days instead of the 90 day value provided by the Pinned Host.) For
425 UA implementation guidance on how to select a maximum max-age, see
426 Section 4.1.
428 The UA MUST NOT modify any pinning metadata of any superdomain
429 matched Known Pinned Host.
431 2.3.3. HTTP-Equiv Element Attribute
433 UAs MUST NOT heed http-equiv="Public-Key-Pins" or http-equiv="Public-
434 Key-Pins-Report-Only" attribute settings on elements
435 [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 algorithm is SHA-256, identified as "sha256" ([RFC4634]). (Future
450 versions of this specification may add new algorithms and deprecate
451 old ones.) UAs MUST ignore Pins for which they do not recognize the
452 algorithm identifier. UAs MUST continue to process the rest of a PKP
453 response header field and note Pins for algorithms they do recognize;
454 UAs MUST recognize "sha256".
456 Figure 4 reproduces the definition of the SubjectPublicKeyInfo
457 structure in [RFC5280].
459 SubjectPublicKeyInfo ::= SEQUENCE {
460 algorithm AlgorithmIdentifier,
461 subjectPublicKey BIT STRING }
463 AlgorithmIdentifier ::= SEQUENCE {
464 algorithm OBJECT IDENTIFIER,
465 parameters ANY DEFINED BY algorithm OPTIONAL }
467 Figure 4: SPKI Definition
469 If the SubjectPublicKeyInfo of a certificate is incomplete when taken
470 in isolation, such as when holding a DSA key without domain
471 parameters, a public key pin cannot be formed.
473 We pin public keys, rather than entire certificates, to enable
474 operators to generate new certificates containing old public keys
475 (see [why-pin-key]).
477 See Appendix A for an example non-normative program that generates
478 SPKI Fingerprints from SubjectPublicKeyInfo fields in certificates.
480 2.5. Noting Pins
482 Upon receipt of the Public-Key-Pins response header field, the UA
483 notes the host as a Pinned Host, storing the Pins and their
484 associated directives in non-volatile storage (for example, along
485 with the HSTS metadata). The Pins and their associated directives
486 are collectively known as Pinning Metadata.
488 The UA MUST observe these conditions when noting a Host:
490 o The UA MUST note the Pins if and only if it received the Public-
491 Key-Pins response header field over an error-free TLS connection.
492 If the host is a Pinned Host, this includes the validation added
493 in Section 2.6.
495 o The UA MUST note the Pins if and only if the TLS connection was
496 authenticated with a certificate chain containing at least one of
497 the SPKI structures indicated by at least one of the given SPKI
498 Fingerprints. (See Section 2.6.)
500 o The UA MUST note the Pins if and only if the given set of Pins
501 contains at least one Pin that does NOT refer to an SPKI in the
502 certificate chain. (That is, the host must set a Backup Pin; see
503 Section 4.3.)
505 If the Public-Key-Pins response header field does not meet all three
506 of these criteria, the UA MUST NOT note the host as a Pinned Host. A
507 Public-Key-Pins response header field that meets all these critera is
508 known as a Valid Pinning Header.
510 Whenever a UA receives a Valid Pinning Header, it MUST set its
511 Pinning Metadata to the exact Pins, max-age, and (if any) report-uri
512 given in the most recently received Valid Pinning Header.
514 For forward compatibility, the UA MUST ignore any unrecognized
515 Public-Key-Pins header directives, while still processing those
516 directives it does recognize. Section 2.1 specifies the directives
517 max-age, Pins, includeSubDomains, and report-uri but future
518 specifications and implementations might use additional directives.
520 2.6. Validating Pinned Connections
522 When a UA connects to a Pinned Host, if the TLS connection has
523 errors, the UA MUST terminate the connection without allowing the
524 user to proceed anyway. (This behavior is the same as that required
525 by [RFC6797].)
527 If the connection has no errors, then the UA will determine whether
528 to apply a new, additional correctness check: Pin Validation. A UA
529 SHOULD perform Pin Validation whenever connecting to a Known Pinned
530 Host, but MAY allow Pin Validation to be disabled for Hosts according
531 to local policy. For example, a UA may disable Pin Validation for
532 Pinned Hosts whose validated certificate chain terminates at a user-
533 defined trust anchor, rather than a trust anchor built-in to the UA.
535 To perform Pin Validation, the UA will compute the SPKI Fingerprints
536 for each certificate in the Pinned Host's validated certificate
537 chain, using each supported hash algorithm for each certificate.
538 (For the purposes of Pin Validation, the UA MUST ignore certificates
539 whose SPKI cannot be taken in isolation, and MUST ignore superfluous
540 certificates in the chain that do not form part of the validating
541 chain.) The UA will then check that the set of these SPKI
542 Fingerprints intersects the set of SPKI Fingerprints in that Pinned
543 Host's Pinning Metadata. If there is set intersection, the UA
544 continues with the connection as normal. Otherwise, the UA MUST
545 treat this Pin Failure as a non-recoverable error. Any procedure
546 that matches the results of this Pin Validation procedure is
547 considered equivalent.
549 Note that, although the UA has previously received Pins at the HTTP
550 layer, it can and MUST perform Pin Validation at the TLS layer,
551 before beginning an HTTP conversation over the TLS channel. The TLS
552 layer thus evaluates TLS connections with pinning information the UA
553 received previously, regardless of mechanism: statically preloaded,
554 via HTTP header, or some other means (possibly in the TLS layer
555 itself).
557 2.7. Interactions With Preloaded Pin Lists
559 UAs MAY choose to implement additional sources of pinning
560 information, such as through built-in lists of pinning information.
561 Such UAs SHOULD allow users to override such additional sources,
562 including disabling them from consideration.
564 UAs that support additional sources of pinning information MUST use
565 the most recently observed pinning information when performing Pin
566 Validation for a host. The most recently observed pinning
567 information is determined based upon the most recent Effective Pin
568 Date, as described in Section 2.3.2.
570 If the result of noting a Valid Pinning Header is to disable pinning
571 for the host, such as through supplying a max-age directive with a
572 value of 0, UAs MUST allow this new information to override any other
573 pinning data. That is, a host must be able to un-pin itself, even in
574 the presence of built-in Pins.
576 Example: A UA may ship with a pre-configured list of Pins that are
577 collected from past observations of Valid Pinning Headers supplied by
578 hosts. In such a solution, the pre-configured list should track when
579 the Valid Pinning Header was last observed, in order to permit site
580 operators to later update the value by supplying a new Valid Pinning
581 Header. Updates to such a pre-configured list should not update the
582 Effective Pin Dates for each host unless the list vendor has actually
583 observed a more recent header. This is to prevent situations where
584 updating the Effective Pin Date on a pre-configured list of Pins may
585 effectively extend the max-age beyond the site operator's stated
586 policy.
588 Example: A UA may ship with a pre-configured list of Pins that are
589 collected through out-of-band means, such as direct contact with the
590 site operator. In such a solution, the site operator accepts
591 responsibility for keeping the configured Valid Pinning Header in
592 sync with the vendor's list, allowing the UA vendor to have each
593 update to the list be treated as as an update of the Effective Pin
594 Date.
596 2.8. Pinning Self-Signed End Entities
598 If UAs accept hosts that authenticate themselves with self-signed end
599 entity certificates, they MAY also allow hosts to pin the public keys
600 in such certificates. The usability and security implications of
601 this practice are outside the scope of this specification.
603 3. Reporting Pin Validation Failure
605 When a Known Pinned Host has set the report-uri directive, the UA
606 SHOULD report Pin Validation failures to the indicated URI. The UA
607 does this by POSTing a JSON ([RFC4627]) message to the URI; the JSON
608 message takes this form:
610 {
611 "date-time": date-time,
612 "hostname": hostname,
613 "port": port,
614 "effective-expiration-date": expiration-date,
615 "include-subdomains": include-subdomains,
616 "served-certificate-chain": [
617 pem1, ... pemN
618 ],
619 "validated-certificate-chain": [
620 pem1, ... pemN
621 ],
622 "known-pins": [
623 known-pin1, ... known-pinN
624 ]
625 }
627 Figure 5: JSON Report Format
629 Whitespace outside of quoted strings is not significant. The key/
630 value pairs may appear in any order, but each SHOULD appear only
631 once.
633 The date-time indicates the time the UA observed the Pin Validation
634 failure. It is provided as a string formatted according to
635 Section 5.6, "Internet Date/Time Format", of [RFC3339].
637 The hostname is the hostname to which the UA made the original
638 request that failed Pin Validation. It is provided as a string.
640 The port is the port to which the UA made the original request that
641 failed Pin Validation. It is provided either as a string or as an
642 integer.
644 The effective-expiration-date is the Effective Expiration Date for
645 the noted Pins. It is provided as a string formatted according to
646 Section 5.6, "Internet Date/Time Format", of [RFC3339].
648 include-subdomains indicates whether or not the UA has noted the
649 includeSubDomains directive for the Known Pinned Host. It is
650 provided as one of the JSON identifiers true or false.
652 The served-certificate-chain is the certificate chain, as served by
653 the Known Pinned Host during TLS session setup. It is provided as an
654 array of strings; each string pem1, ... pemN is the PEM
655 representation of each X.509 certificate as described in
656 [I-D.josefsson-pkix-textual].
658 The validated-certificate-chain is the certificate chain, as
659 constructed by the UA during certificate chain verification. (This
660 may differ from the served-certificate-chain.) It is provided as an
661 array of strings; each string pem1, ... pemN is the PEM
662 representation of each X.509 certificate as described in
663 [I-D.josefsson-pkix-textual].
665 The known-pins are the Pins that the UA has noted for the Known
666 Pinned Host. They are provided as an array of strings with the
667 syntax:
669 known-pin = token "=" quoted-string
671 Figure 6: Known Pin Syntax
673 As in Section 2.4, the token refers to the algorithm name, and the
674 quoted-string refers to the base 64 encoding of the SPKI Fingerprint.
675 When formulating the JSON POST body, the UA MUST either use single-
676 quoted JSON strings, or use double-quoted JSON strings and \-escape
677 the embedded double quotes in the quoted-string part of the known-
678 pin.
680 Figure 7 shows an example of a Pin Validation failure report. (PEM
681 strings are shown on multiple lines for readability in this
682 document.)
684 {
685 "date-time": "2014-04-06T13:00:50Z",
686 "hostname": "www.example.com",
687 "port": 443,
688 "effective-expiration-date": "2014-05-01T12:40:50Z"
689 "include-subdomains": false,
690 "served-certificate-chain": [
691 "-----BEGIN CERTIFICATE-----\n
692 MIIEBDCCAuygAwIBAgIDAjppMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n
693 ...
694 HFa9llF7b1cq26KqltyMdMKVvvBulRP/F/A8rLIQjcxz++iPAsbw+zOzlTvjwsto\n
695 WHPbqCRiOwY1nQ2pM714A5AuTHhdUDqB1O6gyHA43LL5Z/qHQF1hwFGPa4NrzQU6\n
696 yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx\n
697 -----END CERTIFICATE-----",
698 ...
699 ],
700 "validated-certificate-chain": [
701 "-----BEGIN CERTIFICATE-----\n
702 MIIEBDCCAuygAwIBAgIDAjppMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n
703 ...
704 HFa9llF7b1cq26KqltyMdMKVvvBulRP/F/A8rLIQjcxz++iPAsbw+zOzlTvjwsto\n
705 WHPbqCRiOwY1nQ2pM714A5AuTHhdUDqB1O6gyHA43LL5Z/qHQF1hwFGPa4NrzQU6\n
706 yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx\n
707 -----END CERTIFICATE-----",
708 ...
709 ],
710 "known-pins": [
711 'pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="',
712 "pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\""
713 ]
714 }
716 Figure 7: Pin Validation Failure Report Example
718 4. Security Considerations
720 Pinning public keys helps hosts strongly assert their cryptographic
721 identity even in the face of issuer error, malfeasance or compromise.
722 But there is some risk that a host operator could lose or lose
723 control of their host's private key (such as by operator error or
724 host compromise). If the operator had pinned only the key of the
725 host's end entity certificate, the operator would not be able to
726 serve their web site or application in a way that UAs would trust for
727 the duration of their pin's max-age. (Recall that UAs MUST close the
728 connection to a host upon Pin Failure.)
730 Therefore, there is a necessary trade-off between two competing
731 goods: pin specificity and maximal reduction of the scope of issuers
732 on the one hand; and flexibility and resilience of the host's
733 cryptographic identity on the other hand. One way to resolve this
734 trade-off is to compromise by pinning to the key(s) of the issuer(s)
735 of the host's end entity certificate(s). Often, a valid certificate
736 chain will have at least two certificates above the end entity
737 certificate: the intermediate issuer, and the trust anchor.
738 Operators can pin any one or more of the public keys in this chain,
739 and indeed could pin to issuers not in the chain (as, for example, a
740 Backup Pin). Pinning to an intermediate issuer, or even to a trust
741 anchor or root, still significantly reduces the number of issuers who
742 can issue end entity certificates for the Known Pinned Host, while
743 still giving that host flexibility to change keys without a
744 disruption of service.
746 4.1. Maximum max-age
748 As mentioned in Section 2.3.2, UAs MAY cap the max-age value at some
749 upper limit. There is a security trade-off in that low maximum
750 values provide a narrow window of protection for users who visit the
751 Known Pinned Host only infrequently, while high maximum values might
752 potentially result in a UA's inability to successfully perform Pin
753 Validation for a Known Pinned Host if the UA's noted Pins and the
754 Host's true Pins diverge.
756 Such divergence could occur for several reasons, including: UA error;
757 Host operator error; network attack; or a Known Pinned Host that
758 intentionally migrates all pinned keys, combined with a UA that has
759 noted true Pins with a high max-age value and has not had a chance to
760 observe the new true Pins for the Host. (This last example
761 underscores the importance for Host operators to phase in new keys
762 gradually, and to set the max-age value in accordance with their
763 planned key migration schedule.)
765 There is probably no ideal upper limit to the max-age directive that
766 would satisfy all use cases. However, a value on the order of 60
767 days (5184000 seconds) may be considered a balance between the two
768 competing security concerns.
770 4.2. Using includeSubDomains Safely
772 It may happen that Pinned Hosts whose hostnames share a parent domain
773 use different Valid Pinning Headers. If a Host whose hostname is a
774 parent domain for another Host sets the includeSubDomains directive,
775 the two Hosts' Pins may conflict with each other. For example,
776 consider two Known Pinned Hosts, example.com and
777 subdomain.example.com. Assume example.com sets a Valid Pinning
778 Header such as this:
780 Public-Key-Pins: max-age=12000; pin-sha256="ABC..."; pin-sha256="DEF...";
781 includeSubDomains
783 Figure 8: example.com Valid Pinning Header
785 Assume subdomain.example.com sets a Valid Pinning Header such as
786 this:
788 Public-Key-Pins: pin-sha256="GHI..."; pin-sha256="JKL..."
790 Figure 9: subdomain.example.com Valid Pinning Header
792 Assume a UA that has not previously noted any Pins for either of
793 these Hosts. If the UA first contacts subdomain.example.com, it will
794 note the Pins in the Valid Pinning Header, and perform Pin Validation
795 as normal on subsequent conections. If the UA then contacts
796 example.com, again it will note the Pins and perform Pin Validation
797 on future connections. However, if the UA happened to first
798 example.com before subdomain.example.com, the UA would, due to
799 example.com's use of the includeSubDomains directive, attempt to
800 perform Pin Validation for subdomain.example.com using the SPKI
801 hashes ABC... and DEF..., which are not valid for the certificate
802 chains subdomain.example.com (which uses certificates with SPKIs
803 GHI... and JLK...). Thus, depending on the order in which the UA
804 observes the Valid Pinning Headers for hosts example.com and
805 subdomain.example.com, Pin Validation might or might not fail for
806 subdomain.example.com, even if the certificate chain the UA receives
807 for subdomain.example.com is perfectly valid.
809 Thus, Pinned Host operators must use the includeSubDomains directive
810 with care. For example, they may choose to use overlapping pin sets
811 for hosts under a parent domain that uses includeSubDomains, or to
812 not use the includeSubDomains directive in their effective-second-
813 level domains, or to simply use the same pin set for all hosts under
814 a given parent domain.
816 4.3. Backup Pins
818 The primary way to cope with the risk of inadvertent Pin Failure is
819 to keep a Backup Pin. A Backup Pin is a fingerprint for the public
820 key of a secondary, not-yet-deployed key pair. The operator keeps
821 the backup key pair offline, and sets a pin for it in the Public-Key-
822 Pins header. Then, in case the operator loses control of their
823 primary private key, they can deploy the backup key pair. UAs, who
824 have had the backup key pair pinned (when it was set in previous
825 Valid Pinning Headers), can connect to the host without error.
827 Because having a backup key pair is so important to recovery, UAs
828 MUST require that hosts set a Backup Pin. (See Section 2.5.)
830 5. Privacy Considerations
832 Conforming implementations (as well as implementations conforming to
833 [RFC6797]) must store state about which domains have set policies,
834 hence which domains the UA has contacted. A forensic attacker might
835 find this information useful, even if the user has cleared other
836 parts of the UA's state.
838 More importantly, Hosts can use HSTS or HPKP as a "super-cookie", by
839 setting distinct policies for a number of subdomains. For example,
840 assume example.com wishes to track distinct UAs without explicitly
841 setting a cookie, or if a previously-set cookie is deleted from the
842 UA's cookie store. Here are two attack scenarios.
844 o example.com can use report-uri and the ability to pin arbitrary
845 identifiers to distinguish UAs.
847 1. example.com sets a Valid Pinning Header in its response to
848 requests. The header asserts the includeSubDomains directive,
849 and specifies a report-uri directive as well. Pages served by
850 the host also include references to subresource https://
851 bad.example.com/foo.png.
853 2. The Valid Pinning Header includes a "pin" that is not really
854 the hash of an SPKI, but is instead an arbitrary
855 distinguishing string sent only in response to a particular
856 request. For each request, the Host creates a new, distinct
857 distinguishing string and sets it as if it were a pin.
859 3. The certificate chain served by bad.example.com does not pass
860 Pin Validation given the pin set the Host asserted in (1).
861 The HPKP-conforming UA attempts to report the Pin Validation
862 failure to the specified report-uri, including the certificate
863 chain it observed and the SPKI hashes it expected to see.
864 Among the SPKI hashes is the distinguishing string in step
865 (2).
867 o example.com can use SNI and subdomains to distinguish UAs.
869 1. example.com sets a Valid Pinning Header in its response to
870 requests. The header asserts the includeSubDomains directive.
872 2. On a subsequent page view, the Host responds with a page
873 including the subresource https://0.fingerprint.example.com/
874 foo.png, and the server responds using a certificate chain
875 that does not pass Pin Validation for the pin-set defined in
876 the Valid Pinning Header in step (1). The HPKP-conforming UA
877 will close the connection, never completing the request to
878 0.fingerprint.example.com. The Host may thus note that this
879 particular UA had noted the (good) Pins for that subdomain.
881 3. example.com can distinguish 2^N UAs by serving Valid Pinning
882 Headers from an arbitrary number N distinct subdomains, giving
883 some UAs Valid Pinning Headers for some, but not all
884 subdomains (causing subsequent requests for
885 n.fingerprint.example.com to fail), and giving some UAs no
886 Valid Pinning Header for other subdomains (causing subsequent
887 requests for m.fingerprint.example.com to succeed).
889 6. IANA Considerations
891 IANA is requested to register the header described in this document
892 in the "Message Headers" registry, with the following parameters:
894 o Header Field Names should be "Public-Key-Pins" and "Public-Key-
895 Pins-Report-Only".
897 o Protocol should be "http"
899 o Status should be "standard"
901 o Reference should be this document
903 7. Usability Considerations
905 When pinning works to detect impostor Pinned Hosts, users will
906 experience denial of service. UAs MUST explain the reason why, i.e.
907 that it was impossible to verify the confirmed cryptographic identity
908 of the host.
910 UAs MUST have a way for users to clear current Pins for Pinned Hosts.
911 UAs SHOULD have a way for users to query the current state of Pinned
912 Hosts.
914 8. Acknowledgements
916 Thanks to Tobias Gondrom, Jeff Hodges, Paul Hoffman, Ivan Krstic,
917 Adam Langley, Nicolas Lidzborski, SM, James Manger, Yoav Nir, Eric
918 Rescorla, and Tom Ritter for suggestions and edits that clarified the
919 text. Thanks to Trevor Perrin for suggesting a mechanism to
920 affirmatively break Pins ([pin-break-codes]).
922 9. What's Changed
924 [RFC EDITOR: PLEASE REMOVE THIS SECTION]
926 Removed the strict directive.
928 Removed the requirement that the server set the Valid Pinning Header
929 on every response.
931 Added normative references for SHA, JSON, and base-64.
933 Added the Privacy Considerations section.
935 Changed non-normative pin generation code from Go to POSIX shell
936 script using openssl.
938 Changed max-max-age from SHOULD to MAY, and used the example of 60
939 days instead of 30.
941 Removed the section "Pin Validity Times", which was intended to be in
942 harmony with [I-D.perrin-tls-tack]. Now using max-age purely as
943 specified in [RFC6797].
945 Added new directives: includeSubDomains, report-uri and strict.
947 Added a new variant of the PKP Header: Public-Key-Pins-Report-Only.
949 Removed the section on pin break codes and verifiers, in favor the of
950 most-recently-received policy (Section 2.5).
952 Now using a new header field, Public-Key-Pins, separate from HSTS.
953 This allows hosts to use pinning separately from Strict Transport
954 Security.
956 Explicitly requiring that UAs perform Pin Validation before the HTTP
957 conversation begins.
959 Backup Pins are now required.
961 Separated normative from non-normative material. Removed tangential
962 and out-of-scope non-normative discussion.
964 10. References
965 10.1. Normative References
967 [I-D.josefsson-pkix-textual]
968 Josefsson, S. and S. Leonard, "Text Encodings of PKIX and
969 CMS Structures", draft-josefsson-pkix-textual-02 (work in
970 progress), October 2013.
972 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
973 Requirement Levels", BCP 14, RFC 2119, March 1997.
975 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
976 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
977 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
979 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the
980 Internet: Timestamps", RFC 3339, July 2002.
982 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
983 Resource Identifier (URI): Generic Syntax", STD 66, RFC
984 3986, January 2005.
986 [RFC4627] Crockford, D., "The application/json Media Type for
987 JavaScript Object Notation (JSON)", RFC 4627, July 2006.
989 [RFC4634] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
990 (SHA and HMAC-SHA)", RFC 4634, July 2006.
992 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
993 Encodings", RFC 4648, October 2006.
995 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
996 Encodings", RFC 4648, October 2006.
998 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
999 IANA Considerations Section in RFCs", BCP 26, RFC 5226,
1000 May 2008.
1002 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
1003 (TLS) Protocol Version 1.2", RFC 5246, August 2008.
1005 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
1006 Housley, R., and W. Polk, "Internet X.509 Public Key
1007 Infrastructure Certificate and Certificate Revocation List
1008 (CRL) Profile", RFC 5280, May 2008.
1010 [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
1011 Transport Security (HSTS)", RFC 6797, November 2012.
1013 [W3C.REC-html401-19991224]
1014 Raggett, D., Hors, A., and I. Jacobs, "HTML 4.01
1015 Specification", World Wide Web Consortium Recommendation
1016 REC-html401-19991224, December 1999,
1017 .
1019 10.2. Informative References
1021 [I-D.perrin-tls-tack]
1022 Marlinspike, M., "Trust Assertions for Certificate Keys",
1023 draft-perrin-tls-tack-02 (work in progress), January 2013.
1025 [pin-break-codes]
1026 Perrin, T., "Self-Asserted Key Pinning", September 2011,
1027 .
1029 [why-pin-key]
1030 Langley, A., "Public Key Pinning", May 2011,
1031 .
1033 Appendix A. Fingerprint Generation
1035 This POSIX shell program generates SPKI Fingerprints, suitable for
1036 use in pinning, from PEM-encoded certificates. It is non-normative.
1038 openssl x509 -noout -in certificate.pem -pubkey | \
1039 openssl asn1parse -noout -inform pem -out public.key
1040 openssl dgst -sha256 -binary public.key | base64
1042 Figure 10: Example SPKI Fingerprint Generation Code
1044 Appendix B. Deployment Guidance
1046 This section is non-normative guidance which may smooth the adoption
1047 of public key pinning.
1049 o Operators SHOULD get the backup public key signed by a different
1050 (root and/or intermediary) CA than their primary certificate, and
1051 store the backup key pair safely offline. The semantics of an
1052 SPKI Fingerprint do not require the issuance of a certificate to
1053 construct a valid Pin. However, in many deployment scenarios, in
1054 order to make a Backup Pin operational the server operator will
1055 need to have a certificate to deploy TLS on the host. Failure to
1056 obtain a certificate through prior arrangement will leave clients
1057 that recognize the site as a Known Pinned Host unable to
1058 successfully perform Pin Validation until such a time as the
1059 operator can obtain a new certificate from their desired
1060 certificate issuer.
1062 o It is most economical to have the backup certificate signed by a
1063 completely different signature chain than the live certificate, to
1064 maximize recoverability in the event of either root or
1065 intermediary signer compromise.
1067 o Operators SHOULD periodically exercise their Backup Pin plan -- an
1068 untested backup is no backup at all.
1070 o Operators SHOULD start small. Operators SHOULD first deploy
1071 public key pinning by using the report-only mode together with a
1072 report-uri directive that points to a reliable report collection
1073 endpoint. When moving out of report-only mode, operators should
1074 start by setting a max-age of minutes or a few hours, and
1075 gradually increase max-age as they gain confidence in their
1076 operational capability.
1078 Authors' Addresses
1080 Chris Evans
1081 Google, Inc.
1082 1600 Amphitheatre Pkwy
1083 Mountain View, CA 94043
1084 US
1086 Email: cevans@google.com
1088 Chris Palmer
1089 Google, Inc.
1090 1600 Amphitheatre Pkwy
1091 Mountain View, CA 94043
1092 US
1094 Email: palmer@google.com
1096 Ryan Sleevi
1097 Google, Inc.
1098 1600 Amphitheatre Pkwy
1099 Mountain View, CA 94043
1100 US
1102 Email: sleevi@google.com