draft-ietf-websec-key-pinning-03.txt   draft-ietf-websec-key-pinning-04.txt 
Web Security C. Evans Web Security C. Evans
Internet-Draft C. Palmer Internet-Draft C. Palmer
Intended status: Standards Track Google, Inc. Intended status: Standards Track R. Sleevi
Expires: April 19, 2013 October 16, 2012 Expires: June 10, 2013 Google, Inc.
December 7, 2012
Public Key Pinning Extension for HTTP Public Key Pinning Extension for HTTP
draft-ietf-websec-key-pinning-03 draft-ietf-websec-key-pinning-04
Abstract Abstract
This memo describes an extension to the HTTP protocol allowing web This memo describes an extension to the HTTP protocol allowing web
host operators to instruct user agents (UAs) to remember ("pin") the host operators to instruct user agents (UAs) to remember ("pin") the
hosts' cryptographic identities for a given period of time. During hosts' cryptographic identities for a given period of time. During
that time, UAs will require that the host present a certificate chain that time, UAs will require that the host present a certificate chain
including at least one Subject Public Key Info structure whose including at least one Subject Public Key Info structure whose
fingerprint matches one or more of the pinned fingerprints for that fingerprint matches one of the pinned fingerprints for that host. By
host. By effectively reducing the scope of authorities who can effectively reducing the number of authorities who can authenticate
authenticate the domain during the lifetime of the pin, pinning may the domain during the lifetime of the pin, pinning may reduce the
reduce the incidence of man-in-the-middle attacks due to compromised incidence of man-in-the-middle attacks due to compromised
Certification Authorities and other authentication errors and Certification Authorities.
attacks.
Status of this Memo Status of this Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on April 19, 2013. This Internet-Draft will expire on June 10, 2013.
Copyright Notice Copyright Notice
Copyright (c) 2012 IETF Trust and the persons identified as the Copyright (c) 2012 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. 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
1. Introduction 1. Introduction
We propose a new HTTP header to enable a web host to express to user 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 agents (UAs) which Subject Public Key Info (SPKI) structure(s) UAs
MUST expect to be present in the host's certificate chain in future SHOULD expect to be present in the host's certificate chain in future
connections using TLS (see [rfc-5246]). We call this "public key connections using TLS (see [RFC5246]). We call this "public key
pinning". At least one user agent (Google Chrome) has experimented pinning". At least one UA (Google Chrome) has experimented with
with shipping with a user-extensible embedded set of pins. Although shipping with a user-extensible embedded set of pins. Although
effective, this does not scale. This proposal addresses the scale effective, this does not scale. This proposal addresses the scale
problem. problem.
Deploying public key pinning safely will require operational and Deploying public key pinning safely will require operational and
organizational maturity due to the risk that hosts may make organizational maturity due to the risk that hosts may make
themselves unavailable by pinning to a SPKI that becomes invalid. themselves unavailable by pinning to a SPKI that becomes invalid.
(See Section 3.) We believe that, with care, host operators can (See Section 4.) We believe that, with care, host operators can
greatly reduce the risk of MITM attacks and other false- greatly reduce the risk of MITM attacks and other false-
authentication problems for their users without incurring undue risk. authentication problems for their users without incurring undue risk.
We intend for hosts to use public key pinning together with HSTS (as We intend for hosts to use public key pinning together with HSTS
defined in [hsts-draft], but is possible to pin keys without ([RFC6797]), but is possible to pin keys without requiring HSTS.
requiring HSTS.
This draft is being discussed on the WebSec Working Group mailing This draft is being discussed on the WebSec Working Group mailing
list, websec@ietf.org. list, websec@ietf.org.
1.1. Requirements Language 1.1. Requirements Language
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [rfc-2119]. document are to be interpreted as described in RFC 2119 [RFC2119].
2. Server and Client Behavior 2. Server and Client Behavior
2.1. Response Header Field Syntax 2.1. Response Header Field Syntax
To set a pin, hosts use a new HTTP header field, Public-Key-Pins, in The Public-Key-Pins HTTP response header field (PKP header field)
their HTTP responses. Figure 1 describes the syntax of the header indicates to a UA that it SHOULD perform Pin Validation (Section 2.6)
field. in regards to the host emitting the response message containing this
header field, and provides the necessary information for the UA to do
so.
Public-Key-Pins = "Public-Key-Pins" ":" LWS directives 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").
directives = max-age LWS ";" LWS pins Public-Key-Pins =
/ pins LWS ";" LWS max-age "Public-Key-Pins" ":" [ directive ] *( ";" [ directive ] )
Public-Key-Pins-Report-Only =
"Public-Key-Pins-Report-Only" ":" [ directive ] *( ";" [ directive ] )
max-age = "max-age" LWS "=" LWS delta-seconds directive = simple-directive
/ pin-directive
pins = pin simple-directive = directive-name [ "=" directive-value ]
/ pin LWS ";" LWS pins directive-name = token
directive-value = token
/ quoted-string
pin = "pin-" token LWS "=" LWS quoted-string pin-directive = "pin-" token "=" quoted-string
Figure 1 Figure 1: HPKP Header Syntax
In the pin rule, the token is the name of a cryptographic hash token and quoted-string are used as defined in [RFC2616], Section
algorithm, and MUST be either "sha1" or "sha256". (Future versions 2.2.
of this specification may change the hash functions.) The quoted-
string is a sequence of base64 digits: a base64-encoded hash. See
Section 2.2.
Figure 2 shows some example response header fields using the pins 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.
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.
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). extension (folded for clarity).
Public-Key-Pins: max-age=500; Public-Key-Pins: max-age=500;
pin-sha1="4n972HfV354KP560yw4uqe/baXc="; pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc=" pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc="
Public-Key-Pins: max-age=31536000; Public-Key-Pins: max-age=31536000;
pin-sha1="4n972HfV354KP560yw4uqe/baXc="; pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=" pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc="; Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00="; pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="; pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
max-age=2592000 max-age=2592000
Figure 2 Public-Key-Pins: pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
pin-sha1="qvTGHdzF6KLavt4PO0gs2a6pQ00=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
max-age=2592000; includeSubDomains
2.2. Semantics of Pins Figure 3: HPKP Header Examples
The fingerprint is the SHA-1 or SHA-256 hash of the DER-encoded ASN.1 2.2. Server Processing Model
representation of the SubjectPublicKeyInfo (SPKI) field of the X.509
certificate. Figure 3 reproduces the definition of the This section describes the processing model that Pinned Hosts
SubjectPublicKeyInfo structure in [rfc-5280]. 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).
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.
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.
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 { SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier, algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING } subjectPublicKey BIT STRING }
AlgorithmIdentifier ::= SEQUENCE { AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER, algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL } parameters ANY DEFINED BY algorithm OPTIONAL }
Figure 3 Figure 4: SPKI Definition
The SPKI hash is then encoded in base-64 for use in an HTTP header.
(See [rfc-4648].)
If the SubjectPublicKeyInfo of a certificate is incomplete when taken If the SubjectPublicKeyInfo of a certificate is incomplete when taken
in isolation, such as when holding a DSA key without domain in isolation, such as when holding a DSA key without domain
parameters, a public key pin cannot be formed. parameters, a public key pin cannot be formed.
We pin public keys, rather than entire certificates, to enable We pin public keys, rather than entire certificates, to enable
operators to generate new certificates containing old public keys operators to generate new certificates containing old public keys
(see [why-pin-key]). (see [why-pin-key]).
See Appendix A for an example non-normative program that generates See Appendix A for an example non-normative program that generates
public key fingerprints from SubjectPublicKeyInfo fields in SPKI Fingerprints from SubjectPublicKeyInfo fields in certificates.
certificates.
2.3. Noting Pins 2.5. Noting Pins
Upon receipt of the Public-Key-Pins response header field, the UA Upon receipt of the Public-Key-Pins response header field, the UA
notes the host as a Pinned Host, storing the pins and their notes the host as a Pinned Host, storing the Pins and their
associated max-age in non-volatile storage (for example, along with associated directives in non-volatile storage (for example, along
the HSTS metadata). The pins and their associated max-age are with the HSTS metadata). The Pins and their associated directives
collectively known as Pinning Metadata. collectively known as Pinning Metadata.
The UA MUST observe these conditions when noting a host: 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- 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. Key-Pins response header field over an error-free TLS connection.
The UAs MUST ignore Public-Key-Pins response header fields If the host is a Pinned Host, this includes the validation added
received on HTTP (non-HTTPS) connections. in Section 2.6.
o The UA MUST note the pins if and only if the TLS connection was 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 authenticated with a certificate chain containing at least one of
the SPKI structures indicated by at least one of the given the SPKI structures indicated by at least one of the given SPKI
fingerprints. (See Section 2.4.) Fingerprints. (See Section 2.6.)
o The UA MUST note the pins if and only if the given set of pins 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 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 certificate chain. (That is, the host must set a Backup Pin; see
Section 3.1.) Section 4.1.)
If the Public-Key-Pins response header field does not meet all three 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, of these criteria, the UA MUST NOT note the host as a Pinned Host. A
and MUST discard any previously set Pinning Metadata for that host in Public-Key-Pins response header field that meets all these critera is
its non-volatile store. Public-Key-Pins response header fields that known as a Valid Pinning Header.
meet all these critera are known as Valid Pinning Headers.
Whenever a UA receives a Valid Pinning Header, it MUST set its The UA MUST ignore Public-Key-Pins response header fields received on
Pinning Metadata to the exact pins and max-age given in the most connections that do not meet the first criterion.
recently received Valid Pinning Header.
2.3.1. max-age 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?
max-age specifies the number of seconds, after the reception of the Whenever a UA receives a Valid Pinning Header, it MUST set its
Public-Key-Pins HTTP Response Header, during which the UA regards the Pinning Metadata to the exact Pins, max-age, and (if any) report-uri
host as a Pinned Host (up to a maximum of 30 days; see Section 2.5). and strict mode given in the most recently received Valid Pinning
The delta-seconds production is specified in [rfc-2616]. Header.
Note that by setting a low or 0 value for max-age, hosts effectively For forward compatibility, the UA MUST ignore any unrecognized
instruct UAs to cease regarding them as Pinned Hosts. 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.
2.4. Validating Pinned Connections 2.6. Validating Pinned Connections
When a UA connects to a Pinned Host, if the TLS connection has When a UA connects to a Pinned Host, if the TLS connection has
errors, the UA MUST terminate the connection without allowing the errors, the UA MUST terminate the connection without allowing the
user to proceed anyway. (This behavior is the same as that required user to proceed anyway. (This behavior is the same as that required
by [hsts-draft].) by [RFC6797].)
If the connection has no errors, the UA will then apply a new, If the connection has no errors, then the UA will determine whether
additional correctness check: Pin Validation. To perform Pin to apply a new, additional correctness check: Pin Validation. A UA
Validation, the UA will compute the fingerprints of the SPKI SHOULD perform Pin Validation whenever connecting to a Known Pinned
structures in each certificate in the host's validated certificate Host, but MAY allow Pin Validation to be disabled for Hosts according
chain. (For the purposes of Pin Validation, the UA MUST ignore to local policy. For example, a UA may disable Pin Validation for
certificates who SPKI cannot be taken in isolation and superfluous Pinned Hosts whose validated certificate chain terminates at a user-
certificates in the chain that do not form part of the validating defined trust anchor, rather than a trust anchor built-in to the UA.
chain.) The UA will then check that the set of these fingerprints However, if the Pinned Host Metadata indicates that the Pinned Host
intersects the set of fingerprints in that host's Pinning Metadata. 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 If there is set intersection, the UA continues with the connection as
normal. Otherwise, the UA MUST treat this Pin Failure as a non- normal. Otherwise, the UA MUST treat this Pin Failure as a non-
recoverable error. recoverable error. Any procedure that matches the results of this
Pin Validation procedure is considered equivalent.
Note that, although the UA has previously received public key 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, such as specified in [tack-draft]).
2.5. Pin Validity Times
In harmony with section 5.3.4 "Create and activate pins" of
[tack-draft], clients MUST enforce a maximum age for pins that is no
longer than the least of (a) 30 days (30 * 24 * 60 * 60 seconds)
after the most recent time that the client noted the pin; (b) the
amount of time the pin has been noted; or (c) the most recent time
the pin was noted + max-age:
active_period_end = MIN(current + current - initial,
time_pin_noted + max-age,
current + 30 days)
Figure 4 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.6. Interactions With Preloaded Pin Lists 2.7. Interactions With Preloaded Pin Lists
UAs MAY choose to implement built-in public key pins, alongside any 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 HSTS opt-in list. UAs MUST allow users to override a
built-in pin list, including turning it off. built-in pin list, including turning it off.
UAs MUST use the newest information -- built-in or set via Valid UAs MUST use the newest information -- built-in or set via Valid
Pinning Header -- when performing Pin Validation for the host. Pinning Header -- when performing Pin Validation for the host. If
the result of noting a Valid Pinning Header is to disable pinning for
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.7. Pinning Self-Signed End Entities 2.8. Pinning Self-Signed End Entities
If UAs accept hosts that authenticate themselves with self-signed end If UAs accept hosts that authenticate themselves with self-signed end
entity certificates, they MAY also allow hosts to pin the public keys entity certificates, they MAY also allow hosts to pin the public keys
in such certificates. The usability and security implications of in such certificates. The usability and security implications of
this practice are outside the scope of this specification. this practice are outside the scope of this specification.
3. Security Considerations 3. Reporting Pin Validation Failure
Pinning public keys helps hosts assert their cryptographic identity, When a Known Pinned Host has set the report-uri directive, the UA
but there is some risk that a host operator could lose or lose SHOULD report Pin Validation failures to the indicated URI. The UA
control of their host's private key. In this case, the operator does this by POSTing a JSON message to the URI; the JSON message
would not be able to serve their web site or application in a way takes this form:
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.)
3.1. Backup Pins {
"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.
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.
4.1. Backup Pins
The primary way to cope with the risk of inadvertant Pin Failure is 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 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 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- 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 Pins header. Then, in case the operator loses control of their
primary private key, they can deploy the backup key pair. UAs, who 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 have had the backup key pair pinned (when it was set in previous
Valid Pinning Headers), can connect to the host without error. Valid Pinning Headers), can connect to the host without error.
Because having a backup key pair is so important to recovery, UAs Because having a backup key pair is so important to recovery, UAs
MUST require that hosts set a Backup Pin. (See Section 2.3.) MUST require that hosts set a Backup Pin. (See Section 2.5.)
4. IANA Considerations 5. IANA Considerations
This document has no actions for IANA. This document has no actions for IANA.
5. Usability Considerations 6. Usability Considerations
When pinning works to detect impostor Pinned Hosts, users will When pinning works to detect impostor Pinned Hosts, users will
experience denial of service. UAs MUST explain the reason why, i.e. experience denial of service. UAs MUST explain the reason why, i.e.
that it was impossible to verify the confirmed cryptographic identity that it was impossible to verify the confirmed cryptographic identity
of the host. of the host.
UAs MUST have a way for users to clear current pins for Pinned Hosts. 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 UAs SHOULD have a way for users to query the current state of Pinned
Hosts. Hosts.
6. Acknowledgements 7. Acknowledgements
Thanks to Tobias Gondrom, Jeff Hodges, Adam Langley, Nicolas Thanks to Tobias Gondrom, Jeff Hodges, Adam Langley, Nicolas
Lidzborski, SM, James Manger, and Yoav Nir for suggestions and edits Lidzborski, SM, James Manger, and Yoav Nir for suggestions and edits
that clarified the text. Thanks to Trevor Perrin for suggesting a that clarified the text. Thanks to Trevor Perrin for suggesting a
mechanism to affirmatively break pins ([pin-break-codes]). Adam mechanism to affirmatively break pins ([pin-break-codes]). Adam
Langley provided the SPKI fingerprint generation code. Langley provided the SPKI fingerprint generation code.
7. What's Changed 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.
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 Removed the section on pin break codes and verifiers, in favor the of
most-recently-received policy (Section 2.3). most-recently-received policy (Section 2.5).
Now using a new header field, Public-Key-Pins, separate from HSTS. Now using a new header field, Public-Key-Pins, separate from HSTS.
This allows hosts to use pinning separately from Strict Transport This allows hosts to use pinning separately from Strict Transport
Security. Security.
Explicitly requiring that UAs perform Pin Validation before the HTTP Explicitly requiring that UAs perform Pin Validation before the HTTP
conversation begins. conversation begins.
Backup Pins are now required. Backup Pins are now required.
Separated normative from non-normative material. Removed tangential Separated normative from non-normative material. Removed tangential
and out-of-scope non-normative discussion. and out-of-scope non-normative discussion.
8. References 9. References
8.1. Normative References 9.1. Normative References
[hsts-draft] [I-D.josefsson-pkix-textual]
Hodges, J., Jackson, C., and A. Barth, "HTTP Strict Josefsson, S. and S. Leonard, "Text Encodings of PKIX and
Transport Security (HSTS)", October 2011, <http:// CMS Structures", draft-josefsson-pkix-textual-01 (work in
tools.ietf.org/html/ progress), July 2012.
draft-ietf-websec-strict-transport-sec-03>.
[rfc-2119] [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
Requirement Levels", March 1997,
<http://www.ietf.org/rfc/rfc2119.txt>.
[rfc-2616] [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
Transfer Protocol -- HTTP/1.1", June 1999, Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
<http://www.ietf.org/rfc/rfc2616.txt>.
[rfc-4648] [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the
Josefsson, S., "The Base16, Base32, and Base64 Data Internet: Timestamps", RFC 3339, July 2002.
Encodings", October 2006,
<http://www.ietf.org/rfc/rfc4648.txt>.
[rfc-5246] [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Rescorla, E. and T. Dierks, "The Transport Layer Security Resource Identifier (URI): Generic Syntax", STD 66,
(TLS) Protocol Version 1.2", August 2008, RFC 3986, January 2005.
<http://www.ietf.org/rfc/rfc5246.txt>.
[rfc-5280] [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 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.
[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 Housley, R., and W. Polk, "Internet X.509 Public Key
Infrastructure Certificate and Certificate Revocation List Infrastructure Certificate and Certificate Revocation List
(CRL) Profile", May 2008, (CRL) Profile", RFC 5280, May 2008.
<http://www.ietf.org/rfc/rfc5280.txt>.
8.2. Informative References [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
Transport Security (HSTS)", RFC 6797, November 2012.
[why-pin-key] [W3C.REC-html401-19991224]
Langley, A., "Public Key Pinning", May 2011, Hors, A., Raggett, D., and I. Jacobs, "HTML 4.01
<http://www.imperialviolet.org/2011/05/04/pinning.html>. 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] [pin-break-codes]
Perrin, T., "Self-Asserted Key Pinning", September 2011, Perrin, T., "Self-Asserted Key Pinning", September 2011,
<http://trevp.net/SAKP/>. <http://trevp.net/SAKP/>.
[tack-draft] [why-pin-key]
Perrin, T. and M. Marlinspike, "Trust Assertions for Langley, A., "Public Key Pinning", May 2011,
Certificate Keys", May 2012, <http://www.imperialviolet.org/2011/05/04/pinning.html>.
<http://tools.ietf.org/html/draft-perrin-tls-tack>.
Appendix A. Fingerprint Generation Appendix A. Fingerprint Generation
This Go program generates public key fingerprints, suitable for use This Go program generates SPKI Fingerprints, suitable for use in
in pinning, from PEM-encoded certificates. It is non-normative. pinning, from PEM-encoded certificates. It is non-normative.
package main package main
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"crypto/sha1" "crypto/sha1"
"crypto/x509" "crypto/x509"
"encoding/base64" "encoding/base64"
"encoding/pem" "encoding/pem"
skipping to change at page 15, line 49 skipping to change at page 17, line 44
} }
cert := certs[0] cert := certs[0]
h := sha1.New() h := sha1.New()
h.Write(cert.RawSubjectPublicKeyInfo) h.Write(cert.RawSubjectPublicKeyInfo)
digest := h.Sum() digest := h.Sum()
fmt.Printf("Hex: %x\nBase64: %s\n", digest, fmt.Printf("Hex: %x\nBase64: %s\n", digest,
base64.StdEncoding.EncodeToString(digest)) base64.StdEncoding.EncodeToString(digest))
} }
Figure 5 Figure 7: Example SPKI Fingerprint Generation Code
Appendix B. Deployment Guidance Appendix B. Deployment Guidance
This section is non-normative guidance which may smooth the adoption This section is non-normative guidance which may smooth the adoption
of public key pinning. of public key pinning.
o Operators SHOULD get the backup public key signed by a different o Operators SHOULD get the backup public key signed by a different
(root and/or intermediary) CA than their primary certificate, and (root and/or intermediary) CA than their primary certificate, and
store the backup key pair safely offline. 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 o It is most economical to have the backup certificate signed by a
completely different signature chain than the live certificate, to completely different signature chain than the live certificate, to
maximize recoverability in the event of either root or maximize recoverability in the event of either root or
intermediary signer compromise. intermediary signer compromise.
o Operators SHOULD periodically exercise their Backup Pin plan -- an o Operators SHOULD periodically exercise their Backup Pin plan -- an
untested backup is no backup at all. untested backup is no backup at all.
o Operators SHOULD start small. Operators SHOULD first deploy o Operators SHOULD start small. Operators SHOULD first deploy
public key pinning by setting a max-age of minutes or a few hours, public key pinning by using the report-only mode together with a
and gradually increase max-age as they gain confidence in their 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. operational capability.
Authors' Addresses Authors' Addresses
Chris Evans Chris Evans
Google, Inc. Google, Inc.
1600 Amphitheatre Pkwy 1600 Amphitheatre Pkwy
Mountain View, CA 94043 Mountain View, CA 94043
US US
skipping to change at page 17, line 14 skipping to change at page 19, line 4
Authors' Addresses Authors' Addresses
Chris Evans Chris Evans
Google, Inc. Google, Inc.
1600 Amphitheatre Pkwy 1600 Amphitheatre Pkwy
Mountain View, CA 94043 Mountain View, CA 94043
US US
Email: cevans@google.com Email: cevans@google.com
Chris Palmer Chris Palmer
Google, Inc. Google, Inc.
1600 Amphitheatre Pkwy 1600 Amphitheatre Pkwy
Mountain View, CA 94043 Mountain View, CA 94043
US US
Email: palmer@google.com Email: palmer@google.com
Ryan Sleevi
Google, Inc.
1600 Amphitheatre Pkwy
Mountain View, CA 94043
US
Email: sleevi@google.com
 End of changes. 73 change blocks. 
170 lines changed or deleted 536 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/