Skip to main content

Public Key Pinning Extension for HTTP
draft-ietf-websec-key-pinning-04

The information below is for an old version of the document.
Document Type
This is an older version of an Internet-Draft that was ultimately published as RFC 7469.
Authors Chris Evans , Chris Palmer , Ryan Sleevi
Last updated 2012-12-06
Replaces draft-evans-palmer-key-pinning
RFC stream Internet Engineering Task Force (IETF)
Formats
Reviews
Additional resources Mailing list discussion
Stream WG state WG Document
Document shepherd (None)
IESG IESG state Became RFC 7469 (Proposed Standard)
Consensus boilerplate Unknown
Telechat date (None)
Responsible AD (None)
Send notices to (None)
draft-ietf-websec-key-pinning-04
Web Security                                                    C. Evans
Internet-Draft                                                 C. Palmer
Intended status: Standards Track                               R. Sleevi
Expires: June 10, 2013                                      Google, Inc.
                                                        December 7, 2012

                 Public Key Pinning Extension for HTTP
                    draft-ietf-websec-key-pinning-04

Abstract

   This memo describes an extension to the HTTP protocol allowing web
   host operators to instruct user agents (UAs) to remember ("pin") the
   hosts' cryptographic identities for a given period of time.  During
   that time, UAs will require that the host present a certificate chain
   including at least one Subject Public Key Info structure whose
   fingerprint matches one of the pinned fingerprints for that host.  By
   effectively reducing the number of authorities who can authenticate
   the domain during the lifetime of the pin, pinning may reduce the
   incidence of man-in-the-middle attacks due to compromised
   Certification Authorities.

Status of this Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on June 10, 2013.

Copyright Notice

   Copyright (c) 2012 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of

Evans, et al.             Expires June 10, 2013                 [Page 1]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
     1.1.  Requirements Language  . . . . . . . . . . . . . . . . . .  3
   2.  Server and Client Behavior . . . . . . . . . . . . . . . . . .  3
     2.1.  Response Header Field Syntax . . . . . . . . . . . . . . .  3
       2.1.1.  The max-age Directive  . . . . . . . . . . . . . . . .  5
       2.1.2.  The includeSubDomains Directive  . . . . . . . . . . .  5
       2.1.3.  The report-uri Directive . . . . . . . . . . . . . . .  5
       2.1.4.  The strict Directive . . . . . . . . . . . . . . . . .  6
       2.1.5.  Examples . . . . . . . . . . . . . . . . . . . . . . .  6
     2.2.  Server Processing Model  . . . . . . . . . . . . . . . . .  6
       2.2.1.  HTTP-over-Secure-Transport Request Type  . . . . . . .  6
       2.2.2.  HTTP Request Type  . . . . . . . . . . . . . . . . . .  7
     2.3.  User Agent Processing Model  . . . . . . . . . . . . . . .  7
       2.3.1.  Public-Key-Pins Response Header Field Processing . . .  7
       2.3.2.  Noting a Pinned Host - Storage Model . . . . . . . . .  8
       2.3.3.  HTTP-Equiv <Meta> Element Attribute  . . . . . . . . .  8
       2.3.4.  UA Processing Examples . . . . . . . . . . . . . . . .  8
     2.4.  Semantics of Pins  . . . . . . . . . . . . . . . . . . . .  9
     2.5.  Noting Pins  . . . . . . . . . . . . . . . . . . . . . . .  9
     2.6.  Validating Pinned Connections  . . . . . . . . . . . . . . 11
     2.7.  Interactions With Preloaded Pin Lists  . . . . . . . . . . 11
     2.8.  Pinning Self-Signed End Entities . . . . . . . . . . . . . 12
   3.  Reporting Pin Validation Failure . . . . . . . . . . . . . . . 12
   4.  Security Considerations  . . . . . . . . . . . . . . . . . . . 13
     4.1.  Backup Pins  . . . . . . . . . . . . . . . . . . . . . . . 14
   5.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 14
   6.  Usability Considerations . . . . . . . . . . . . . . . . . . . 14
   7.  Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 14
   8.  What's Changed . . . . . . . . . . . . . . . . . . . . . . . . 14
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 15
     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 15
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 16
   Appendix A.  Fingerprint Generation  . . . . . . . . . . . . . . . 16
   Appendix B.  Deployment Guidance . . . . . . . . . . . . . . . . . 17
   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 18

Evans, et al.             Expires June 10, 2013                 [Page 2]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

1.  Introduction

   We propose a new HTTP header to enable a web host to express to user
   agents (UAs) which Subject Public Key Info (SPKI) structure(s) UAs
   SHOULD expect to be present in the host's certificate chain in future
   connections using TLS (see [RFC5246]).  We call this "public key
   pinning".  At least one UA (Google Chrome) has experimented with
   shipping with a user-extensible embedded set of pins.  Although
   effective, this does not scale.  This proposal addresses the scale
   problem.

   Deploying public key pinning safely will require operational and
   organizational maturity due to the risk that hosts may make
   themselves unavailable by pinning to a SPKI that becomes invalid.
   (See Section 4.)  We believe that, with care, host operators can
   greatly reduce the risk of MITM attacks and other false-
   authentication problems for their users without incurring undue risk.

   We intend for hosts to use public key pinning together with HSTS
   ([RFC6797]), but is possible to pin keys without requiring HSTS.

   This draft is being discussed on the WebSec Working Group mailing
   list, websec@ietf.org.

1.1.  Requirements Language

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in RFC 2119 [RFC2119].

2.  Server and Client Behavior

2.1.  Response Header Field Syntax

   The Public-Key-Pins HTTP response header field (PKP header field)
   indicates to a UA that it SHOULD perform Pin Validation (Section 2.6)
   in regards to the host emitting the response message containing this
   header field, and provides the necessary information for the UA to do
   so.

   Figure 1 describes the ABNF (Augmented Backus-Naur Form) syntax of
   the header field.  It is based on the Generic Grammar defined in
   Section 2 of [RFC2616] (which includes a notion of "implied linear
   whitespace", also known as "implied *LWS").

Evans, et al.             Expires June 10, 2013                 [Page 3]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

Public-Key-Pins =
    "Public-Key-Pins" ":" [ directive ] *( ";" [ directive ] )
Public-Key-Pins-Report-Only =
    "Public-Key-Pins-Report-Only" ":" [ directive ] *( ";" [ directive ] )

directive        = simple-directive
                   / pin-directive

simple-directive = directive-name [ "=" directive-value ]
directive-name   = token
directive-value  = token
                   / quoted-string

pin-directive    = "pin-" token "=" quoted-string

                       Figure 1: HPKP Header Syntax

   token and quoted-string are used as defined in [RFC2616], Section
   2.2.

   The directives defined in this specification are described below.
   The overall requirements for directives are:

   1.  The order of appearance of directives is not significant.

   2.  All simple-directives MUST appear only once in a PKP header
       field.  Directives are either optional or required, as stipulated
       in their definitions.

   3.  Directive names are case-insensitive.

   4.  UAs MUST ignore any PKP header fields containing directives, or
       other header field value data, that do not conform to the syntax
       defined in this specification.

   5.  If a PKP header field contains any directive(s) the UA does not
       recognize, the UA MUST ignore the those directives.

   6.  If the PKP header field otherwise satisfies the above
       requirements (1 through 5), the UA MUST process the directives it
       recognizes.

   Additional directives extending the semantic functionality of the PKP
   header field can be defined in other specifications, with a registry
   (having an IANA policy definition of IETF Review [RFC2616]) defined
   for them at such time.  Such future directives will be ignored by UAs
   implementing only this specification, as well as by generally non-
   conforming UAs.

Evans, et al.             Expires June 10, 2013                 [Page 4]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   In the pin-directive, the token is the name of a cryptographic hash
   algorithm, and MUST be either "sha1" or "sha256".  The quoted-string
   is a sequence of base 64 digits: the base 64-encoded SPKI
   Fingerprint.  See Section 2.4.

2.1.1.  The max-age Directive

   The REQUIRED "max-age" directive specifies the number of seconds,
   after the reception of the PKP header field, during which the UA
   SHOULD regard the host (from whom the message was received) as a
   Known Pinned Host.  The delta-seconds production is specified in
   [RFC2616].

   The syntax of the max-age directive's REQUIRED value (after quoted-
   string unescaping, if necessary) is defined as:

   max-age-value = delta-seconds
   delta-seconds = 1*DIGIT

                      Figure 2: max-age Value Syntax

   delta-seconds is used as defined in [RFC2616], Section 3.3.2.

   NOTE: A max-age value of zero (i.e., "max-age=0") signals the UA to
   cease regarding the host as a Known Pinned Host, including the
   includeSubDomains directive (if asserted for that Known Pinned Host).
   See Section 2.3.1.

2.1.2.  The includeSubDomains Directive

   The OPTIONAL "includeSubDomains" directive is a valueless directive
   which, if present (i.e., it is "asserted"), signals to the UA that
   the Pinning Policy applies to this Pinned Host as well as any
   subdomains of the host's domain name.

2.1.3.  The report-uri Directive

   The OPTIONAL "report-uri" directive indicates the URI to which the UA
   SHOULD report Pin Validation failures (Section 2.6).  The UA POSTs
   the reports to the given URI as described in Section 3.

   TODO: Describe the meaning of Public-Key-Pins-Report-Only and the
   interaction between it and report-uri.  In particular, describe how
   it is possible to be in enforcement mode (i.e. not -Report-Only) and
   still POST reports to the report-uri.

Evans, et al.             Expires June 10, 2013                 [Page 5]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

2.1.4.  The strict Directive

   The OPTIONAL "strict" directive is a valueless directive which, if
   present (i.e., it is "asserted"), signals to the UA that the Pinning
   Policy contained should be applied to the Pinned Host exactly as
   specified, ignoring local client policy.

2.1.5.  Examples

   Figure 3 shows some example response header fields using the pins
   extension (folded for clarity).

   Public-Key-Pins: max-age=500;
       pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
       pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc="

   Public-Key-Pins: max-age=31536000;
       pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
       pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="

   Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
       pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
       pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
       max-age=2592000

   Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
       pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
       pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
       max-age=2592000; includeSubDomains

                      Figure 3: HPKP Header Examples

2.2.  Server Processing Model

   This section describes the processing model that Pinned Hosts
   implement.  The model comprises two facets: the processing rules for
   HTTP request messages received over a secure transport (e.g.  TLS
   [RFC5246]); and the processing rules for HTTP request messages
   received over non-secure transports, such as TCP.

2.2.1.  HTTP-over-Secure-Transport Request Type

   When replying to an HTTP request that was conveyed over a secure
   transport, a Pinned Host SHOULD include in its response exactly one
   PKP header field that MUST satisfy the grammar specified above in
   Section 2.1.  If the Pinned Host does not include the PKP header
   field, and if the connection passed Pin Validation, UAs MUST treat
   the host as if it had set its max-age to 0 (see Section 2.3.1).

Evans, et al.             Expires June 10, 2013                 [Page 6]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   Establishing a given host as a Known Pinned Host, in the context of a
   given UA, MAY be accomplished over the HTTP protocol, which is in
   turn running over secure transport, by correctly returning (per this
   specification) at least one valid PKP header field to the UA.  Other
   mechanisms, such as a client-side pre-loaded Known Pinned Host list
   MAY also be used.

2.2.2.  HTTP Request Type

   Pinned Hosts SHOULD NOT include the PKP header field in HTTP
   responses conveyed over non-secure transport.  UAs MUST ignore any
   PKP header received in an HTTP response conveyed over non-secure
   transport.

2.3.  User Agent Processing Model

   This section describes the HTTP Public Key Pinning processing model
   for UAs.

   TODO: Add a note referring to the HSTS RFC's discussion of IDNs.

2.3.1.  Public-Key-Pins Response Header Field Processing

   If the UA receives, over a secure transport, an HTTP response that
   includes a PKP header field conforming to the grammar specified in
   Section 2.1, and there are no underlying secure transport errors or
   warnings (see Section 2.5), the UA MUST either:

   o  Note the host as a Known HSTS Host if it is not already so noted
      (see Section 2.3.2),

   or,

   o  Update the UA's cached information for the Known Pinned Host if
      any of of the max-age, includeSubDomains, strict, or report-uri
      header field value directives convey information different than
      that already maintained by the UA.

   o  The max-age value is essentially a "time to live" value relative
      to the time of the most recent observation of the PKP header
      field.

   o  If the max-age header field value token has a value of 0, the UA
      MUST remove its cached Pinning Policy information (including the
      includeSubDomains and strict directives, if asserted) if the
      Pinned Host is Known, or, MUST NOT note this Pinned Host if it is
      not yet Known.

Evans, et al.             Expires June 10, 2013                 [Page 7]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   o  If a UA receives more than one PKP header field in an HTTP
      response message over secure transport, then the UA MUST process
      only the first such header field.

   Otherwise:

   o  If the UA receives the HTTP response over insecure transport, or
      if the PKP header is not a Valid Pinning Header (see Section 2.5),
      the UA MUST ignore any present PKP header field(s).

   o  The UA MUST ignore any PKP header fields not conforming to the
      grammar specified in Section 2.1.

2.3.2.  Noting a Pinned Host - Storage Model

   If the substring matching the host production from the Request-URI
   (of the message to which the host responded) syntactically matches
   the IP-literal or IPv4address productions from Section 3.2.2 of
   [RFC3986], then the UA MUST NOT note this host as a Known Pinned
   Host.

   Otherwise, if the substring does not congruently match a Known Pinned
   Host's domain name, per the matching procedure specified in Section
   8.2 of [RFC6797], then the UA MUST note this host as a Known Pinned
   Host, caching the Pinned Host's domain name and noting along with it
   the expiry time of this information, as effectively stipulated per
   the given max-age value, as well as whether or not the
   includeSubDomains or strict directives are asserted, the value of the
   report-uri directive (if present), and any other metadata from
   optional or future PKP header directives.

   The UA MUST NOT modify the expiry time nor the includeSubDomains
   directive of any superdomain matched Known Pinned Host.

   A Known Pinned Host is "expired" if its cache entry has an expiry
   date in the past.  The UA MUST evict all expired Known Pinned Hosts
   from its cache, if at any time, an expired Known Pinned Host exists
   in the cache.

2.3.3.  HTTP-Equiv <Meta> Element Attribute

   UAs MUST NOT heed http-equiv="Public-Key-Pins" attribute settings on
   <meta> elements [W3C.REC-html401-19991224] in received content.

2.3.4.  UA Processing Examples

   TODO.

Evans, et al.             Expires June 10, 2013                 [Page 8]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

2.4.  Semantics of Pins

   An SPKI Fingerprint is defined as the output of a known cryptographic
   hash algorithm whose input is the DER-encoded ASN.1 representation of
   the SubjectPublicKeyInfo (SPKI) field of an X.509 certificate.  A Pin
   is defined as the combination of the known algorithm identifier and
   the SPKI Fingerprint computed using that algorithm.

   The SPKI Fingerprint is encoded in base 64 for use in an HTTP header.
   (See [RFC4648].)

   In this version of the specification, the known cryptographic hash
   algorithms are SHA-1, identified as "sha1", and SHA-256, identified
   as "sha256".  (Future versions of this specification may add new
   algorithms and deprecate old ones.)  UAs MUST ignore Pins for which
   they do not recognize the algorithm identifier.  UAs MUST continue to
   process the rest of a PKP response header field and note Pins for
   algorithms they do recognize; UAs MUST recognize "sha1" and "sha256".

   Figure 4 reproduces the definition of the SubjectPublicKeyInfo
   structure in [RFC5280].

   SubjectPublicKeyInfo  ::=  SEQUENCE  {
       algorithm            AlgorithmIdentifier,
       subjectPublicKey     BIT STRING  }

   AlgorithmIdentifier  ::=  SEQUENCE  {
       algorithm            OBJECT IDENTIFIER,
       parameters           ANY DEFINED BY algorithm OPTIONAL  }

                         Figure 4: SPKI Definition

   If the SubjectPublicKeyInfo of a certificate is incomplete when taken
   in isolation, such as when holding a DSA key without domain
   parameters, a public key pin cannot be formed.

   We pin public keys, rather than entire certificates, to enable
   operators to generate new certificates containing old public keys
   (see [why-pin-key]).

   See Appendix A for an example non-normative program that generates
   SPKI Fingerprints from SubjectPublicKeyInfo fields in certificates.

2.5.  Noting Pins

   Upon receipt of the Public-Key-Pins response header field, the UA
   notes the host as a Pinned Host, storing the Pins and their
   associated directives in non-volatile storage (for example, along

Evans, et al.             Expires June 10, 2013                 [Page 9]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   with the HSTS metadata).  The Pins and their associated directives
   collectively known as Pinning Metadata.

   The UA MUST observe these conditions when noting a Host:

   o  The UA MUST note the Pins if and only if it received the Public-
      Key-Pins response header field over an error-free TLS connection.
      If the host is a Pinned Host, this includes the validation added
      in Section 2.6.

   o  The UA MUST note the Pins if and only if the TLS connection was
      authenticated with a certificate chain containing at least one of
      the SPKI structures indicated by at least one of the given SPKI
      Fingerprints.  (See Section 2.6.)

   o  The UA MUST note the Pins if and only if the given set of Pins
      contains at least one Pin that does NOT refer to an SPKI in the
      certificate chain.  (That is, the host must set a Backup Pin; see
      Section 4.1.)

   If the Public-Key-Pins response header field does not meet all three
   of these criteria, the UA MUST NOT note the host as a Pinned Host.  A
   Public-Key-Pins response header field that meets all these critera is
   known as a Valid Pinning Header.

   The UA MUST ignore Public-Key-Pins response header fields received on
   connections that do not meet the first criterion.

   TODO: Consider whether or not this requirement makes sense: If the UA
   receives a Public-Key-Pins header from a Pinned Host that meets the
   first criterion, but not the following two, the UA MUST discard any
   previously set Pinning Metadata for that host in its non-volatile
   store.  Whether or not the Known Pinned Host is in strict mode,
   should the UA note new pins when Pin Validation is disabled per local
   policy?

   Whenever a UA receives a Valid Pinning Header, it MUST set its
   Pinning Metadata to the exact Pins, max-age, and (if any) report-uri
   and strict mode given in the most recently received Valid Pinning
   Header.

   For forward compatibility, the UA MUST ignore any unrecognized
   Public-Key-Pins header directives, while still processing those
   directives it does recognize.  Section 2.1 specifies the directives
   max-age, pins, includeSubDomains, report-uri, and strict, but future
   specifications and implementations might use additional directives.

Evans, et al.             Expires June 10, 2013                [Page 10]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

2.6.  Validating Pinned Connections

   When a UA connects to a Pinned Host, if the TLS connection has
   errors, the UA MUST terminate the connection without allowing the
   user to proceed anyway.  (This behavior is the same as that required
   by [RFC6797].)

   If the connection has no errors, then the UA will determine whether
   to apply a new, additional correctness check: Pin Validation.  A UA
   SHOULD perform Pin Validation whenever connecting to a Known Pinned
   Host, but MAY allow Pin Validation to be disabled for Hosts according
   to local policy.  For example, a UA may disable Pin Validation for
   Pinned Hosts whose validated certificate chain terminates at a user-
   defined trust anchor, rather than a trust anchor built-in to the UA.
   However, if the Pinned Host Metadata indicates that the Pinned Host
   is operating in "strict mode" (see Section 2.1.4), then the UA MUST
   perform Pin Validation.

   To perform Pin Validation, the UA will compute the SPKI Fingerprints
   for each certificate in the Pinned Host's validated certificate
   chain, using each supported hash algorithm for each certificate.
   (For the purposes of Pin Validation, the UA MUST ignore certificates
   whose SPKI cannot be taken in isolation and superfluous certificates
   in the chain that do not form part of the validating chain.)  The UA
   will then check that the set of these SPKI Fingerprints intersects
   the set of SPKI Fingerprints in that Pinned Host's Pinning Metadata.
   If there is set intersection, the UA continues with the connection as
   normal.  Otherwise, the UA MUST treat this Pin Failure as a non-
   recoverable error.  Any procedure that matches the results of this
   Pin Validation procedure is considered equivalent.

   Note that, although the UA has previously received Pins at the HTTP
   layer, it can and MUST perform Pin Validation at the TLS layer,
   before beginning an HTTP conversation over the TLS channel.  The TLS
   layer thus evaluates TLS connections with pinning information the UA
   received previously, regardless of mechanism: statically preloaded,
   via HTTP header, or some other means (possibly in the TLS layer
   itself).

2.7.  Interactions With Preloaded Pin Lists

   UAs MAY choose to implement built-in public key pins, alongside any
   built-in HSTS opt-in list.  UAs MUST allow users to override a
   built-in pin list, including turning it off.

   UAs MUST use the newest information -- built-in or set via Valid
   Pinning Header -- when performing Pin Validation for the host.  If
   the result of noting a Valid Pinning Header is to disable pinning for

Evans, et al.             Expires June 10, 2013                [Page 11]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   the host (such as because the host set a max-age directive with a
   value of 0), UAs MUST allow this new information to override any
   built-in pins.  That is, a host must be able to un-pin itself even
   from built-in pins.

2.8.  Pinning Self-Signed End Entities

   If UAs accept hosts that authenticate themselves with self-signed end
   entity certificates, they MAY also allow hosts to pin the public keys
   in such certificates.  The usability and security implications of
   this practice are outside the scope of this specification.

3.  Reporting Pin Validation Failure

   When a Known Pinned Host has set the report-uri directive, the UA
   SHOULD report Pin Validation failures to the indicated URI.  The UA
   does this by POSTing a JSON message to the URI; the JSON message
   takes this form:

   {
     "date-time": date-time,
     "hostname": hostname,
     "port": port,
     "certificate-chain": [
       pem1, ... pemN
     ],
     "known-pins": [
       known-pin1, ... known-pinN
     ]
   }

                       Figure 5: JSON Report Format

   Whitespace outside of quoted strings is not significant.  The key/
   value pairs may appear in any order, but each SHOULD appear only
   once.

   The date-time indicates the time the UA observed the Pin Validation
   failure.  It is provided as a string formatted according to Section
   5.6, "Internet Date/Time Format", of [RFC3339].

   The hostname is the hostname to which the UA made the original
   request that failed Pin Validation.  It is provided as a string.

   The port is the port to which the UA made the original request that
   failed Pin Validation.  It is provided either as a string or as an
   integer.

Evans, et al.             Expires June 10, 2013                [Page 12]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   The certificate-chain is the certificate chain, as constructed by the
   UA during certificate chain verification.  (This may differ from the
   certificate chain as served by the Known Pinned Host, of course.)  It
   is provided as an array of strings; each string pem1, ... pemN is the
   PEM representation of each X.509 certificate as described in
   [I-D.josefsson-pkix-textual].

   The known-pins are the Pins that the UA has noted for the Known
   Pinned Host.  They are provided as an array of strings with the
   syntax:

   known-pin = token "=" quoted-string

                        Figure 6: Known Pin Syntax

   As in Section 2.4, the token refers to the algorithm name, and the
   quoted-string refers to the base 64 encoding of the SPKI Fingerprint.

4.  Security Considerations

   Pinning public keys helps hosts strongly assert their cryptographic
   identity even in the face of issuer error, malfeasance or compromise.
   But there is some risk that a host operator could lose or lose
   control of their host's private key (such as by operator error or
   host compromise).  If the operator had pinned only the key of the
   host's end entity certificate, the operator would not be able to
   serve their web site or application in a way that UAs would trust for
   the duration of their pin's max-age.  (Recall that UAs MUST close the
   connection to a host upon Pin Failure.)

   Therefore, there is a necessary trade-off between two competing
   goods: pin specificity and maximal reduction of the scope of issuers
   on the one hand; and flexibility and resilience of the host's
   cryptographic identity on the other hand.  One way to resolve this
   trade-off is to compromise by pinning to the key(s) of the issuer(s)
   of the host's end entity certificate(s).  Often, a valid certificate
   chain will have at least two certificates above the end entity
   certificate: the intermediate issuer, and the trust anchor.
   Operators can pin any one or more of the public keys in this chain,
   and indeed could pin to issuers not in the chain (as, for example, a
   Backup Pin).  Pinning to an intermediate issuer, or even to a trust
   anchor or root, still significantly reduces the number of issuers who
   can issue end entity certificates for the Known Pinned Host, while
   still giving that host flexibility to change keys without a
   disruption of service.

Evans, et al.             Expires June 10, 2013                [Page 13]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

4.1.  Backup Pins

   The primary way to cope with the risk of inadvertant Pin Failure is
   to keep a Backup Pin. A Backup Pin is a fingerprint for the public
   key of a secondary, not-yet-deployed key pair.  The operator keeps
   the backup key pair offline, and sets a pin for it in the Public-Key-
   Pins header.  Then, in case the operator loses control of their
   primary private key, they can deploy the backup key pair.  UAs, who
   have had the backup key pair pinned (when it was set in previous
   Valid Pinning Headers), can connect to the host without error.

   Because having a backup key pair is so important to recovery, UAs
   MUST require that hosts set a Backup Pin. (See Section 2.5.)

5.  IANA Considerations

   This document has no actions for IANA.

6.  Usability Considerations

   When pinning works to detect impostor Pinned Hosts, users will
   experience denial of service.  UAs MUST explain the reason why, i.e.
   that it was impossible to verify the confirmed cryptographic identity
   of the host.

   UAs MUST have a way for users to clear current pins for Pinned Hosts.
   UAs SHOULD have a way for users to query the current state of Pinned
   Hosts.

7.  Acknowledgements

   Thanks to Tobias Gondrom, Jeff Hodges, Adam Langley, Nicolas
   Lidzborski, SM, James Manger, and Yoav Nir for suggestions and edits
   that clarified the text.  Thanks to Trevor Perrin for suggesting a
   mechanism to affirmatively break pins ([pin-break-codes]).  Adam
   Langley provided the SPKI fingerprint generation code.

8.  What's Changed

   Removed the section "Pin Validity Times", which was intended to be in
   harmony with [I-D.perrin-tls-tack].  Now using max-age purely as
   specified in [RFC6797].

   Added new directives: includeSubDomains, report-uri and strict.

Evans, et al.             Expires June 10, 2013                [Page 14]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   Added, but have not yet described, a new variant of the PKP Header:
   Public-Key-Pins-Report-Only.

   Removed the section on pin break codes and verifiers, in favor the of
   most-recently-received policy (Section 2.5).

   Now using a new header field, Public-Key-Pins, separate from HSTS.
   This allows hosts to use pinning separately from Strict Transport
   Security.

   Explicitly requiring that UAs perform Pin Validation before the HTTP
   conversation begins.

   Backup Pins are now required.

   Separated normative from non-normative material.  Removed tangential
   and out-of-scope non-normative discussion.

9.  References

9.1.  Normative References

   [I-D.josefsson-pkix-textual]
              Josefsson, S. and S. Leonard, "Text Encodings of PKIX and
              CMS Structures", draft-josefsson-pkix-textual-01 (work in
              progress), July 2012.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [RFC2616]  Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
              Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
              Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.

   [RFC3339]  Klyne, G., Ed. and C. Newman, "Date and Time on the
              Internet: Timestamps", RFC 3339, July 2002.

   [RFC3986]  Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
              Resource Identifier (URI): Generic Syntax", STD 66,
              RFC 3986, January 2005.

   [RFC4648]  Josefsson, S., "The Base16, Base32, and Base64 Data
              Encodings", RFC 4648, October 2006.

   [RFC5226]  Narten, T. and H. Alvestrand, "Guidelines for Writing an
              IANA Considerations Section in RFCs", BCP 26, RFC 5226,
              May 2008.

Evans, et al.             Expires June 10, 2013                [Page 15]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   [RFC5246]  Dierks, T. and E. Rescorla, "The Transport Layer Security
              (TLS) Protocol Version 1.2", RFC 5246, August 2008.

   [RFC5280]  Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
              Housley, R., and W. Polk, "Internet X.509 Public Key
              Infrastructure Certificate and Certificate Revocation List
              (CRL) Profile", RFC 5280, May 2008.

   [RFC6797]  Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
              Transport Security (HSTS)", RFC 6797, November 2012.

   [W3C.REC-html401-19991224]
              Hors, A., Raggett, D., and I. Jacobs, "HTML 4.01
              Specification", World Wide Web Consortium
              Recommendation REC-html401-19991224, December 1999,
              <http://www.w3.org/TR/1999/REC-html401-19991224>.

9.2.  Informative References

   [I-D.perrin-tls-tack]
              Marlinspike, M., "Trust Assertions for Certificate Keys",
              draft-perrin-tls-tack-01 (work in progress),
              September 2012.

   [pin-break-codes]
              Perrin, T., "Self-Asserted Key Pinning", September 2011,
              <http://trevp.net/SAKP/>.

   [why-pin-key]
              Langley, A., "Public Key Pinning", May 2011,
              <http://www.imperialviolet.org/2011/05/04/pinning.html>.

Appendix A.  Fingerprint Generation

   This Go program generates SPKI Fingerprints, suitable for use in
   pinning, from PEM-encoded certificates.  It is non-normative.

Evans, et al.             Expires June 10, 2013                [Page 16]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   package main

   import (
          "io/ioutil"
          "os"
          "crypto/sha1"
          "crypto/x509"
          "encoding/base64"
          "encoding/pem"
          "fmt"
   )

   func main() {
          if len(os.Args) < 2 {
                  fmt.Printf("Usage: %s PEM-filename\n", os.Args[0])
                  os.Exit(1)
          }
          pemBytes, err := ioutil.ReadFile(os.Args[1])
          if err != nil {
                  panic(err.String())
          }
          block, _ := pem.Decode(pemBytes)
          if block == nil {
                  panic("No PEM structure found")
          }
          derBytes := block.Bytes
          certs, err := x509.ParseCertificates(derBytes)
          if err != nil {
                  panic(err.String())
          }
          cert := certs[0]
          h := sha1.New()
          h.Write(cert.RawSubjectPublicKeyInfo)
          digest := h.Sum()

          fmt.Printf("Hex: %x\nBase64: %s\n", digest,
                  base64.StdEncoding.EncodeToString(digest))
   }

            Figure 7: Example SPKI Fingerprint Generation Code

Appendix B.  Deployment Guidance

   This section is non-normative guidance which may smooth the adoption
   of public key pinning.

Evans, et al.             Expires June 10, 2013                [Page 17]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   o  Operators SHOULD get the backup public key signed by a different
      (root and/or intermediary) CA than their primary certificate, and
      store the backup key pair safely offline.  The semantics of an
      SPKI Fingerprint do not require the issuance of a certificate to
      construct a valid Pin. However, in many deployment scenarios, in
      order to make a Backup Pin operational the server operator will
      need to have a certificate to deploy TLS on the host.  Failure to
      obtain a certificate through prior arrangement will leave clients
      that recognize the site as a Known Pinned Host unable to
      successfully perform Pin Validation until such a time as the
      operator can obtain a new certificate from their desired
      certificate issuer.

   o  It is most economical to have the backup certificate signed by a
      completely different signature chain than the live certificate, to
      maximize recoverability in the event of either root or
      intermediary signer compromise.

   o  Operators SHOULD periodically exercise their Backup Pin plan -- an
      untested backup is no backup at all.

   o  Operators SHOULD start small.  Operators SHOULD first deploy
      public key pinning by using the report-only mode together with a
      report-uri directive that points to a reliable report collection
      endpoint.  When moving out of report-only mode, operators should
      start by setting a max-age of minutes or a few hours, and
      gradually increase max-age as they gain confidence in their
      operational capability.

Authors' Addresses

   Chris Evans
   Google, Inc.
   1600 Amphitheatre Pkwy
   Mountain View, CA  94043
   US

   Email: cevans@google.com

Evans, et al.             Expires June 10, 2013                [Page 18]
Internet-Draft    Public Key Pinning Extension for HTTP    December 2012

   Chris Palmer
   Google, Inc.
   1600 Amphitheatre Pkwy
   Mountain View, CA  94043
   US

   Email: palmer@google.com

   Ryan Sleevi
   Google, Inc.
   1600 Amphitheatre Pkwy
   Mountain View, CA  94043
   US

   Email: sleevi@google.com

Evans, et al.             Expires June 10, 2013                [Page 19]