idnits 2.17.1 draft-ietf-websec-key-pinning-04.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 is 1 instance 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 (December 7, 2012) is 4130 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) -- Looks like a reference, but probably isn't: '0' on line 776 -- Looks like a reference, but probably isn't: '1' on line 763 == Unused Reference: 'RFC5226' is defined on line 705, but no explicit reference was found in the text == Outdated reference: A later version (-10) exists of draft-josefsson-pkix-textual-01 ** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) == Outdated reference: A later version (-02) exists of draft-perrin-tls-tack-01 Summary: 4 errors (**), 0 flaws (~~), 4 warnings (==), 3 comments (--). 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: June 10, 2013 Google, Inc. 6 December 7, 2012 8 Public Key Pinning Extension for HTTP 9 draft-ietf-websec-key-pinning-04 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 June 10, 2013. 41 Copyright Notice 43 Copyright (c) 2012 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 59 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 3 60 2. Server and Client Behavior . . . . . . . . . . . . . . . . . . 3 61 2.1. Response Header Field Syntax . . . . . . . . . . . . . . . 3 62 2.1.1. The max-age Directive . . . . . . . . . . . . . . . . 5 63 2.1.2. The includeSubDomains Directive . . . . . . . . . . . 5 64 2.1.3. The report-uri Directive . . . . . . . . . . . . . . . 5 65 2.1.4. The strict Directive . . . . . . . . . . . . . . . . . 6 66 2.1.5. Examples . . . . . . . . . . . . . . . . . . . . . . . 6 67 2.2. Server Processing Model . . . . . . . . . . . . . . . . . 6 68 2.2.1. HTTP-over-Secure-Transport Request Type . . . . . . . 6 69 2.2.2. HTTP Request Type . . . . . . . . . . . . . . . . . . 7 70 2.3. User Agent Processing Model . . . . . . . . . . . . . . . 7 71 2.3.1. Public-Key-Pins Response Header Field Processing . . . 7 72 2.3.2. Noting a Pinned Host - Storage Model . . . . . . . . . 8 73 2.3.3. HTTP-Equiv Element Attribute . . . . . . . . . 8 74 2.3.4. UA Processing Examples . . . . . . . . . . . . . . . . 8 75 2.4. Semantics of Pins . . . . . . . . . . . . . . . . . . . . 9 76 2.5. Noting Pins . . . . . . . . . . . . . . . . . . . . . . . 9 77 2.6. Validating Pinned Connections . . . . . . . . . . . . . . 11 78 2.7. Interactions With Preloaded Pin Lists . . . . . . . . . . 11 79 2.8. Pinning Self-Signed End Entities . . . . . . . . . . . . . 12 80 3. Reporting Pin Validation Failure . . . . . . . . . . . . . . . 12 81 4. Security Considerations . . . . . . . . . . . . . . . . . . . 13 82 4.1. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 14 83 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 84 6. Usability Considerations . . . . . . . . . . . . . . . . . . . 14 85 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 14 86 8. What's Changed . . . . . . . . . . . . . . . . . . . . . . . . 14 87 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 15 88 9.1. Normative References . . . . . . . . . . . . . . . . . . . 15 89 9.2. Informative References . . . . . . . . . . . . . . . . . . 16 90 Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 16 91 Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . . 17 92 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 18 94 1. Introduction 96 We propose a new HTTP header to enable a web host to express to user 97 agents (UAs) which Subject Public Key Info (SPKI) structure(s) UAs 98 SHOULD expect to be present in the host's certificate chain in future 99 connections using TLS (see [RFC5246]). We call this "public key 100 pinning". At least one UA (Google Chrome) has experimented with 101 shipping with a user-extensible embedded set of pins. Although 102 effective, this does not scale. This proposal addresses the scale 103 problem. 105 Deploying public key pinning safely will require operational and 106 organizational maturity due to the risk that hosts may make 107 themselves unavailable by pinning to a SPKI that becomes invalid. 108 (See Section 4.) We believe that, with care, host operators can 109 greatly reduce the risk of MITM attacks and other false- 110 authentication problems for their users without incurring undue risk. 112 We intend for hosts to use public key pinning together with HSTS 113 ([RFC6797]), but is possible to pin keys without requiring HSTS. 115 This draft is being discussed on the WebSec Working Group mailing 116 list, websec@ietf.org. 118 1.1. Requirements Language 120 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 121 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 122 document are to be interpreted as described in RFC 2119 [RFC2119]. 124 2. Server and Client Behavior 126 2.1. Response Header Field Syntax 128 The Public-Key-Pins HTTP response header field (PKP header field) 129 indicates to a UA that it SHOULD perform Pin Validation (Section 2.6) 130 in regards to the host emitting the response message containing this 131 header field, and provides the necessary information for the UA to do 132 so. 134 Figure 1 describes the ABNF (Augmented Backus-Naur Form) syntax of 135 the header field. It is based on the Generic Grammar defined in 136 Section 2 of [RFC2616] (which includes a notion of "implied linear 137 whitespace", also known as "implied *LWS"). 139 Public-Key-Pins = 140 "Public-Key-Pins" ":" [ directive ] *( ";" [ directive ] ) 141 Public-Key-Pins-Report-Only = 142 "Public-Key-Pins-Report-Only" ":" [ directive ] *( ";" [ directive ] ) 144 directive = simple-directive 145 / pin-directive 147 simple-directive = directive-name [ "=" directive-value ] 148 directive-name = token 149 directive-value = token 150 / quoted-string 152 pin-directive = "pin-" token "=" quoted-string 154 Figure 1: HPKP Header Syntax 156 token and quoted-string are used as defined in [RFC2616], Section 157 2.2. 159 The directives defined in this specification are described below. 160 The overall requirements for directives are: 162 1. The order of appearance of directives is not significant. 164 2. All simple-directives MUST appear only once in a PKP header 165 field. Directives are either optional or required, as stipulated 166 in their definitions. 168 3. Directive names are case-insensitive. 170 4. UAs MUST ignore any PKP header fields containing directives, or 171 other header field value data, that do not conform to the syntax 172 defined in this specification. 174 5. If a PKP header field contains any directive(s) the UA does not 175 recognize, the UA MUST ignore the those directives. 177 6. If the PKP header field otherwise satisfies the above 178 requirements (1 through 5), the UA MUST process the directives it 179 recognizes. 181 Additional directives extending the semantic functionality of the PKP 182 header field can be defined in other specifications, with a registry 183 (having an IANA policy definition of IETF Review [RFC2616]) defined 184 for them at such time. Such future directives will be ignored by UAs 185 implementing only this specification, as well as by generally non- 186 conforming UAs. 188 In the pin-directive, the token is the name of a cryptographic hash 189 algorithm, and MUST be either "sha1" or "sha256". The quoted-string 190 is a sequence of base 64 digits: the base 64-encoded SPKI 191 Fingerprint. See Section 2.4. 193 2.1.1. The max-age Directive 195 The REQUIRED "max-age" directive specifies the number of seconds, 196 after the reception of the PKP header field, during which the UA 197 SHOULD regard the host (from whom the message was received) as a 198 Known Pinned Host. The delta-seconds production is specified in 199 [RFC2616]. 201 The syntax of the max-age directive's REQUIRED value (after quoted- 202 string unescaping, if necessary) is defined as: 204 max-age-value = delta-seconds 205 delta-seconds = 1*DIGIT 207 Figure 2: max-age Value Syntax 209 delta-seconds is used as defined in [RFC2616], Section 3.3.2. 211 NOTE: A max-age value of zero (i.e., "max-age=0") signals the UA to 212 cease regarding the host as a Known Pinned Host, including the 213 includeSubDomains directive (if asserted for that Known Pinned Host). 214 See Section 2.3.1. 216 2.1.2. The includeSubDomains Directive 218 The OPTIONAL "includeSubDomains" directive is a valueless directive 219 which, if present (i.e., it is "asserted"), signals to the UA that 220 the Pinning Policy applies to this Pinned Host as well as any 221 subdomains of the host's domain name. 223 2.1.3. The report-uri Directive 225 The OPTIONAL "report-uri" directive indicates the URI to which the UA 226 SHOULD report Pin Validation failures (Section 2.6). The UA POSTs 227 the reports to the given URI as described in Section 3. 229 TODO: Describe the meaning of Public-Key-Pins-Report-Only and the 230 interaction between it and report-uri. In particular, describe how 231 it is possible to be in enforcement mode (i.e. not -Report-Only) and 232 still POST reports to the report-uri. 234 2.1.4. The strict Directive 236 The OPTIONAL "strict" directive is a valueless directive which, if 237 present (i.e., it is "asserted"), signals to the UA that the Pinning 238 Policy contained should be applied to the Pinned Host exactly as 239 specified, ignoring local client policy. 241 2.1.5. Examples 243 Figure 3 shows some example response header fields using the pins 244 extension (folded for clarity). 246 Public-Key-Pins: max-age=500; 247 pin-sha1="4n972HfV354KP560yw4uqe/baXc="; 248 pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc=" 250 Public-Key-Pins: max-age=31536000; 251 pin-sha1="4n972HfV354KP560yw4uqe/baXc="; 252 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=" 254 Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc="; 255 pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00="; 256 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="; 257 max-age=2592000 259 Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc="; 260 pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00="; 261 pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="; 262 max-age=2592000; includeSubDomains 264 Figure 3: HPKP Header Examples 266 2.2. Server Processing Model 268 This section describes the processing model that Pinned Hosts 269 implement. The model comprises two facets: the processing rules for 270 HTTP request messages received over a secure transport (e.g. TLS 271 [RFC5246]); and the processing rules for HTTP request messages 272 received over non-secure transports, such as TCP. 274 2.2.1. HTTP-over-Secure-Transport Request Type 276 When replying to an HTTP request that was conveyed over a secure 277 transport, a Pinned Host SHOULD include in its response exactly one 278 PKP header field that MUST satisfy the grammar specified above in 279 Section 2.1. If the Pinned Host does not include the PKP header 280 field, and if the connection passed Pin Validation, UAs MUST treat 281 the host as if it had set its max-age to 0 (see Section 2.3.1). 283 Establishing a given host as a Known Pinned Host, in the context of a 284 given UA, MAY be accomplished over the HTTP protocol, which is in 285 turn running over secure transport, by correctly returning (per this 286 specification) at least one valid PKP header field to the UA. Other 287 mechanisms, such as a client-side pre-loaded Known Pinned Host list 288 MAY also be used. 290 2.2.2. HTTP Request Type 292 Pinned Hosts SHOULD NOT include the PKP header field in HTTP 293 responses conveyed over non-secure transport. UAs MUST ignore any 294 PKP header received in an HTTP response conveyed over non-secure 295 transport. 297 2.3. User Agent Processing Model 299 This section describes the HTTP Public Key Pinning processing model 300 for UAs. 302 TODO: Add a note referring to the HSTS RFC's discussion of IDNs. 304 2.3.1. Public-Key-Pins Response Header Field Processing 306 If the UA receives, over a secure transport, an HTTP response that 307 includes a PKP header field conforming to the grammar specified in 308 Section 2.1, and there are no underlying secure transport errors or 309 warnings (see Section 2.5), the UA MUST either: 311 o Note the host as a Known HSTS Host if it is not already so noted 312 (see Section 2.3.2), 314 or, 316 o Update the UA's cached information for the Known Pinned Host if 317 any of of the max-age, includeSubDomains, strict, or report-uri 318 header field value directives convey information different than 319 that already maintained by the UA. 321 o The max-age value is essentially a "time to live" value relative 322 to the time of the most recent observation of the PKP header 323 field. 325 o If the max-age header field value token has a value of 0, the UA 326 MUST remove its cached Pinning Policy information (including the 327 includeSubDomains and strict directives, if asserted) if the 328 Pinned Host is Known, or, MUST NOT note this Pinned Host if it is 329 not yet Known. 331 o If a UA receives more than one PKP header field in an HTTP 332 response message over secure transport, then the UA MUST process 333 only the first such header field. 335 Otherwise: 337 o If the UA receives the HTTP response over insecure transport, or 338 if the PKP header is not a Valid Pinning Header (see Section 2.5), 339 the UA MUST ignore any present PKP header field(s). 341 o The UA MUST ignore any PKP header fields not conforming to the 342 grammar specified in Section 2.1. 344 2.3.2. Noting a Pinned Host - Storage Model 346 If the substring matching the host production from the Request-URI 347 (of the message to which the host responded) syntactically matches 348 the IP-literal or IPv4address productions from Section 3.2.2 of 349 [RFC3986], then the UA MUST NOT note this host as a Known Pinned 350 Host. 352 Otherwise, if the substring does not congruently match a Known Pinned 353 Host's domain name, per the matching procedure specified in Section 354 8.2 of [RFC6797], then the UA MUST note this host as a Known Pinned 355 Host, caching the Pinned Host's domain name and noting along with it 356 the expiry time of this information, as effectively stipulated per 357 the given max-age value, as well as whether or not the 358 includeSubDomains or strict directives are asserted, the value of the 359 report-uri directive (if present), and any other metadata from 360 optional or future PKP header directives. 362 The UA MUST NOT modify the expiry time nor the includeSubDomains 363 directive of any superdomain matched Known Pinned Host. 365 A Known Pinned Host is "expired" if its cache entry has an expiry 366 date in the past. The UA MUST evict all expired Known Pinned Hosts 367 from its cache, if at any time, an expired Known Pinned Host exists 368 in the cache. 370 2.3.3. HTTP-Equiv Element Attribute 372 UAs MUST NOT heed http-equiv="Public-Key-Pins" attribute settings on 373 elements [W3C.REC-html401-19991224] in received content. 375 2.3.4. UA Processing Examples 377 TODO. 379 2.4. Semantics of Pins 381 An SPKI Fingerprint is defined as the output of a known cryptographic 382 hash algorithm whose input is the DER-encoded ASN.1 representation of 383 the SubjectPublicKeyInfo (SPKI) field of an X.509 certificate. A Pin 384 is defined as the combination of the known algorithm identifier and 385 the SPKI Fingerprint computed using that algorithm. 387 The SPKI Fingerprint is encoded in base 64 for use in an HTTP header. 388 (See [RFC4648].) 390 In this version of the specification, the known cryptographic hash 391 algorithms are SHA-1, identified as "sha1", and SHA-256, identified 392 as "sha256". (Future versions of this specification may add new 393 algorithms and deprecate old ones.) UAs MUST ignore Pins for which 394 they do not recognize the algorithm identifier. UAs MUST continue to 395 process the rest of a PKP response header field and note Pins for 396 algorithms they do recognize; UAs MUST recognize "sha1" and "sha256". 398 Figure 4 reproduces the definition of the SubjectPublicKeyInfo 399 structure in [RFC5280]. 401 SubjectPublicKeyInfo ::= SEQUENCE { 402 algorithm AlgorithmIdentifier, 403 subjectPublicKey BIT STRING } 405 AlgorithmIdentifier ::= SEQUENCE { 406 algorithm OBJECT IDENTIFIER, 407 parameters ANY DEFINED BY algorithm OPTIONAL } 409 Figure 4: SPKI Definition 411 If the SubjectPublicKeyInfo of a certificate is incomplete when taken 412 in isolation, such as when holding a DSA key without domain 413 parameters, a public key pin cannot be formed. 415 We pin public keys, rather than entire certificates, to enable 416 operators to generate new certificates containing old public keys 417 (see [why-pin-key]). 419 See Appendix A for an example non-normative program that generates 420 SPKI Fingerprints from SubjectPublicKeyInfo fields in certificates. 422 2.5. Noting Pins 424 Upon receipt of the Public-Key-Pins response header field, the UA 425 notes the host as a Pinned Host, storing the Pins and their 426 associated directives in non-volatile storage (for example, along 427 with the HSTS metadata). The Pins and their associated directives 428 collectively known as Pinning Metadata. 430 The UA MUST observe these conditions when noting a Host: 432 o The UA MUST note the Pins if and only if it received the Public- 433 Key-Pins response header field over an error-free TLS connection. 434 If the host is a Pinned Host, this includes the validation added 435 in Section 2.6. 437 o The UA MUST note the Pins if and only if the TLS connection was 438 authenticated with a certificate chain containing at least one of 439 the SPKI structures indicated by at least one of the given SPKI 440 Fingerprints. (See Section 2.6.) 442 o The UA MUST note the Pins if and only if the given set of Pins 443 contains at least one Pin that does NOT refer to an SPKI in the 444 certificate chain. (That is, the host must set a Backup Pin; see 445 Section 4.1.) 447 If the Public-Key-Pins response header field does not meet all three 448 of these criteria, the UA MUST NOT note the host as a Pinned Host. A 449 Public-Key-Pins response header field that meets all these critera is 450 known as a Valid Pinning Header. 452 The UA MUST ignore Public-Key-Pins response header fields received on 453 connections that do not meet the first criterion. 455 TODO: Consider whether or not this requirement makes sense: If the UA 456 receives a Public-Key-Pins header from a Pinned Host that meets the 457 first criterion, but not the following two, the UA MUST discard any 458 previously set Pinning Metadata for that host in its non-volatile 459 store. Whether or not the Known Pinned Host is in strict mode, 460 should the UA note new pins when Pin Validation is disabled per local 461 policy? 463 Whenever a UA receives a Valid Pinning Header, it MUST set its 464 Pinning Metadata to the exact Pins, max-age, and (if any) report-uri 465 and strict mode given in the most recently received Valid Pinning 466 Header. 468 For forward compatibility, the UA MUST ignore any unrecognized 469 Public-Key-Pins header directives, while still processing those 470 directives it does recognize. Section 2.1 specifies the directives 471 max-age, pins, includeSubDomains, report-uri, and strict, but future 472 specifications and implementations might use additional directives. 474 2.6. Validating Pinned Connections 476 When a UA connects to a Pinned Host, if the TLS connection has 477 errors, the UA MUST terminate the connection without allowing the 478 user to proceed anyway. (This behavior is the same as that required 479 by [RFC6797].) 481 If the connection has no errors, then the UA will determine whether 482 to apply a new, additional correctness check: Pin Validation. A UA 483 SHOULD perform Pin Validation whenever connecting to a Known Pinned 484 Host, but MAY allow Pin Validation to be disabled for Hosts according 485 to local policy. For example, a UA may disable Pin Validation for 486 Pinned Hosts whose validated certificate chain terminates at a user- 487 defined trust anchor, rather than a trust anchor built-in to the UA. 488 However, if the Pinned Host Metadata indicates that the Pinned Host 489 is operating in "strict mode" (see Section 2.1.4), then the UA MUST 490 perform Pin Validation. 492 To perform Pin Validation, the UA will compute the SPKI Fingerprints 493 for each certificate in the Pinned Host's validated certificate 494 chain, using each supported hash algorithm for each certificate. 495 (For the purposes of Pin Validation, the UA MUST ignore certificates 496 whose SPKI cannot be taken in isolation and superfluous certificates 497 in the chain that do not form part of the validating chain.) The UA 498 will then check that the set of these SPKI Fingerprints intersects 499 the set of SPKI Fingerprints in that Pinned Host's Pinning Metadata. 500 If there is set intersection, the UA continues with the connection as 501 normal. Otherwise, the UA MUST treat this Pin Failure as a non- 502 recoverable error. Any procedure that matches the results of this 503 Pin Validation procedure is considered equivalent. 505 Note that, although the UA has previously received Pins at the HTTP 506 layer, it can and MUST perform Pin Validation at the TLS layer, 507 before beginning an HTTP conversation over the TLS channel. The TLS 508 layer thus evaluates TLS connections with pinning information the UA 509 received previously, regardless of mechanism: statically preloaded, 510 via HTTP header, or some other means (possibly in the TLS layer 511 itself). 513 2.7. Interactions With Preloaded Pin Lists 515 UAs MAY choose to implement built-in public key pins, alongside any 516 built-in HSTS opt-in list. UAs MUST allow users to override a 517 built-in pin list, including turning it off. 519 UAs MUST use the newest information -- built-in or set via Valid 520 Pinning Header -- when performing Pin Validation for the host. If 521 the result of noting a Valid Pinning Header is to disable pinning for 522 the host (such as because the host set a max-age directive with a 523 value of 0), UAs MUST allow this new information to override any 524 built-in pins. That is, a host must be able to un-pin itself even 525 from built-in pins. 527 2.8. Pinning Self-Signed End Entities 529 If UAs accept hosts that authenticate themselves with self-signed end 530 entity certificates, they MAY also allow hosts to pin the public keys 531 in such certificates. The usability and security implications of 532 this practice are outside the scope of this specification. 534 3. Reporting Pin Validation Failure 536 When a Known Pinned Host has set the report-uri directive, the UA 537 SHOULD report Pin Validation failures to the indicated URI. The UA 538 does this by POSTing a JSON message to the URI; the JSON message 539 takes this form: 541 { 542 "date-time": date-time, 543 "hostname": hostname, 544 "port": port, 545 "certificate-chain": [ 546 pem1, ... pemN 547 ], 548 "known-pins": [ 549 known-pin1, ... known-pinN 550 ] 551 } 553 Figure 5: JSON Report Format 555 Whitespace outside of quoted strings is not significant. The key/ 556 value pairs may appear in any order, but each SHOULD appear only 557 once. 559 The date-time indicates the time the UA observed the Pin Validation 560 failure. It is provided as a string formatted according to Section 561 5.6, "Internet Date/Time Format", of [RFC3339]. 563 The hostname is the hostname to which the UA made the original 564 request that failed Pin Validation. It is provided as a string. 566 The port is the port to which the UA made the original request that 567 failed Pin Validation. It is provided either as a string or as an 568 integer. 570 The certificate-chain is the certificate chain, as constructed by the 571 UA during certificate chain verification. (This may differ from the 572 certificate chain as served by the Known Pinned Host, of course.) It 573 is provided as an array of strings; each string pem1, ... pemN is the 574 PEM representation of each X.509 certificate as described in 575 [I-D.josefsson-pkix-textual]. 577 The known-pins are the Pins that the UA has noted for the Known 578 Pinned Host. They are provided as an array of strings with the 579 syntax: 581 known-pin = token "=" quoted-string 583 Figure 6: Known Pin Syntax 585 As in Section 2.4, the token refers to the algorithm name, and the 586 quoted-string refers to the base 64 encoding of the SPKI Fingerprint. 588 4. Security Considerations 590 Pinning public keys helps hosts strongly assert their cryptographic 591 identity even in the face of issuer error, malfeasance or compromise. 592 But there is some risk that a host operator could lose or lose 593 control of their host's private key (such as by operator error or 594 host compromise). If the operator had pinned only the key of the 595 host's end entity certificate, the operator would not be able to 596 serve their web site or application in a way that UAs would trust for 597 the duration of their pin's max-age. (Recall that UAs MUST close the 598 connection to a host upon Pin Failure.) 600 Therefore, there is a necessary trade-off between two competing 601 goods: pin specificity and maximal reduction of the scope of issuers 602 on the one hand; and flexibility and resilience of the host's 603 cryptographic identity on the other hand. One way to resolve this 604 trade-off is to compromise by pinning to the key(s) of the issuer(s) 605 of the host's end entity certificate(s). Often, a valid certificate 606 chain will have at least two certificates above the end entity 607 certificate: the intermediate issuer, and the trust anchor. 608 Operators can pin any one or more of the public keys in this chain, 609 and indeed could pin to issuers not in the chain (as, for example, a 610 Backup Pin). Pinning to an intermediate issuer, or even to a trust 611 anchor or root, still significantly reduces the number of issuers who 612 can issue end entity certificates for the Known Pinned Host, while 613 still giving that host flexibility to change keys without a 614 disruption of service. 616 4.1. Backup Pins 618 The primary way to cope with the risk of inadvertant Pin Failure is 619 to keep a Backup Pin. A Backup Pin is a fingerprint for the public 620 key of a secondary, not-yet-deployed key pair. The operator keeps 621 the backup key pair offline, and sets a pin for it in the Public-Key- 622 Pins header. Then, in case the operator loses control of their 623 primary private key, they can deploy the backup key pair. UAs, who 624 have had the backup key pair pinned (when it was set in previous 625 Valid Pinning Headers), can connect to the host without error. 627 Because having a backup key pair is so important to recovery, UAs 628 MUST require that hosts set a Backup Pin. (See Section 2.5.) 630 5. IANA Considerations 632 This document has no actions for IANA. 634 6. Usability Considerations 636 When pinning works to detect impostor Pinned Hosts, users will 637 experience denial of service. UAs MUST explain the reason why, i.e. 638 that it was impossible to verify the confirmed cryptographic identity 639 of the host. 641 UAs MUST have a way for users to clear current pins for Pinned Hosts. 642 UAs SHOULD have a way for users to query the current state of Pinned 643 Hosts. 645 7. Acknowledgements 647 Thanks to Tobias Gondrom, Jeff Hodges, Adam Langley, Nicolas 648 Lidzborski, SM, James Manger, and Yoav Nir for suggestions and edits 649 that clarified the text. Thanks to Trevor Perrin for suggesting a 650 mechanism to affirmatively break pins ([pin-break-codes]). Adam 651 Langley provided the SPKI fingerprint generation code. 653 8. What's Changed 655 Removed the section "Pin Validity Times", which was intended to be in 656 harmony with [I-D.perrin-tls-tack]. Now using max-age purely as 657 specified in [RFC6797]. 659 Added new directives: includeSubDomains, report-uri and strict. 661 Added, but have not yet described, a new variant of the PKP Header: 662 Public-Key-Pins-Report-Only. 664 Removed the section on pin break codes and verifiers, in favor the of 665 most-recently-received policy (Section 2.5). 667 Now using a new header field, Public-Key-Pins, separate from HSTS. 668 This allows hosts to use pinning separately from Strict Transport 669 Security. 671 Explicitly requiring that UAs perform Pin Validation before the HTTP 672 conversation begins. 674 Backup Pins are now required. 676 Separated normative from non-normative material. Removed tangential 677 and out-of-scope non-normative discussion. 679 9. References 681 9.1. Normative References 683 [I-D.josefsson-pkix-textual] 684 Josefsson, S. and S. Leonard, "Text Encodings of PKIX and 685 CMS Structures", draft-josefsson-pkix-textual-01 (work in 686 progress), July 2012. 688 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 689 Requirement Levels", BCP 14, RFC 2119, March 1997. 691 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 692 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 693 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 695 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the 696 Internet: Timestamps", RFC 3339, July 2002. 698 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 699 Resource Identifier (URI): Generic Syntax", STD 66, 700 RFC 3986, January 2005. 702 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 703 Encodings", RFC 4648, October 2006. 705 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 706 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 707 May 2008. 709 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 710 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 712 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 713 Housley, R., and W. Polk, "Internet X.509 Public Key 714 Infrastructure Certificate and Certificate Revocation List 715 (CRL) Profile", RFC 5280, May 2008. 717 [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict 718 Transport Security (HSTS)", RFC 6797, November 2012. 720 [W3C.REC-html401-19991224] 721 Hors, A., Raggett, D., and I. Jacobs, "HTML 4.01 722 Specification", World Wide Web Consortium 723 Recommendation REC-html401-19991224, December 1999, 724 . 726 9.2. Informative References 728 [I-D.perrin-tls-tack] 729 Marlinspike, M., "Trust Assertions for Certificate Keys", 730 draft-perrin-tls-tack-01 (work in progress), 731 September 2012. 733 [pin-break-codes] 734 Perrin, T., "Self-Asserted Key Pinning", September 2011, 735 . 737 [why-pin-key] 738 Langley, A., "Public Key Pinning", May 2011, 739 . 741 Appendix A. Fingerprint Generation 743 This Go program generates SPKI Fingerprints, suitable for use in 744 pinning, from PEM-encoded certificates. It is non-normative. 746 package main 748 import ( 749 "io/ioutil" 750 "os" 751 "crypto/sha1" 752 "crypto/x509" 753 "encoding/base64" 754 "encoding/pem" 755 "fmt" 756 ) 758 func main() { 759 if len(os.Args) < 2 { 760 fmt.Printf("Usage: %s PEM-filename\n", os.Args[0]) 761 os.Exit(1) 762 } 763 pemBytes, err := ioutil.ReadFile(os.Args[1]) 764 if err != nil { 765 panic(err.String()) 766 } 767 block, _ := pem.Decode(pemBytes) 768 if block == nil { 769 panic("No PEM structure found") 770 } 771 derBytes := block.Bytes 772 certs, err := x509.ParseCertificates(derBytes) 773 if err != nil { 774 panic(err.String()) 775 } 776 cert := certs[0] 777 h := sha1.New() 778 h.Write(cert.RawSubjectPublicKeyInfo) 779 digest := h.Sum() 781 fmt.Printf("Hex: %x\nBase64: %s\n", digest, 782 base64.StdEncoding.EncodeToString(digest)) 783 } 785 Figure 7: Example SPKI Fingerprint Generation Code 787 Appendix B. Deployment Guidance 789 This section is non-normative guidance which may smooth the adoption 790 of public key pinning. 792 o Operators SHOULD get the backup public key signed by a different 793 (root and/or intermediary) CA than their primary certificate, and 794 store the backup key pair safely offline. The semantics of an 795 SPKI Fingerprint do not require the issuance of a certificate to 796 construct a valid Pin. However, in many deployment scenarios, in 797 order to make a Backup Pin operational the server operator will 798 need to have a certificate to deploy TLS on the host. Failure to 799 obtain a certificate through prior arrangement will leave clients 800 that recognize the site as a Known Pinned Host unable to 801 successfully perform Pin Validation until such a time as the 802 operator can obtain a new certificate from their desired 803 certificate issuer. 805 o It is most economical to have the backup certificate signed by a 806 completely different signature chain than the live certificate, to 807 maximize recoverability in the event of either root or 808 intermediary signer compromise. 810 o Operators SHOULD periodically exercise their Backup Pin plan -- an 811 untested backup is no backup at all. 813 o Operators SHOULD start small. Operators SHOULD first deploy 814 public key pinning by using the report-only mode together with a 815 report-uri directive that points to a reliable report collection 816 endpoint. When moving out of report-only mode, operators should 817 start by setting a max-age of minutes or a few hours, and 818 gradually increase max-age as they gain confidence in their 819 operational capability. 821 Authors' Addresses 823 Chris Evans 824 Google, Inc. 825 1600 Amphitheatre Pkwy 826 Mountain View, CA 94043 827 US 829 Email: cevans@google.com 830 Chris Palmer 831 Google, Inc. 832 1600 Amphitheatre Pkwy 833 Mountain View, CA 94043 834 US 836 Email: palmer@google.com 838 Ryan Sleevi 839 Google, Inc. 840 1600 Amphitheatre Pkwy 841 Mountain View, CA 94043 842 US 844 Email: sleevi@google.com