draft-ietf-websec-key-pinning-20.txt   draft-ietf-websec-key-pinning-21.txt 
Web Security C. Evans Web Security C. Evans
Internet-Draft C. Palmer Internet-Draft C. Palmer
Intended status: Standards Track R. Sleevi Intended status: Standards Track R. Sleevi
Expires: February 8, 2015 Google, Inc. Expires: April 8, 2015 Google, Inc.
August 7, 2014 October 5, 2014
Public Key Pinning Extension for HTTP Public Key Pinning Extension for HTTP
draft-ietf-websec-key-pinning-20 draft-ietf-websec-key-pinning-21
Abstract Abstract
This document describes an extension to the HTTP protocol allowing This document defines a new HTTP header that allows web host
web host operators to instruct user agents to remember ("pin") the operators to instruct user agents to remember ("pin") the hosts'
hosts' cryptographic identities for a given period of time. During cryptographic identities over a period of time. During that time,
that time, UAs will require that the host present a certificate chain UAs will require that the host presents a certificate chain including
including at least one Subject Public Key Info structure whose at least one Subject Public Key Info structure whose fingerprint
fingerprint matches one of the pinned fingerprints for that host. By matches one of the pinned fingerprints for that host. By effectively
effectively reducing the number of authorities who can authenticate reducing the number of trusted authorities who can authenticate the
the domain during the lifetime of the pin, pinning may reduce the domain during the lifetime of the pin, pinning may reduce the
incidence of man-in-the-middle attacks due to compromised incidence of man-in-the-middle attacks due to compromised
Certification Authorities. Certification Authorities.
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 February 8, 2015. This Internet-Draft will expire on April 8, 2015.
Copyright Notice Copyright Notice
Copyright (c) 2014 IETF Trust and the persons identified as the Copyright (c) 2014 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
skipping to change at page 2, line 17 skipping to change at page 2, line 17
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 Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Requirements Language . . . . . . . . . . . . . . . . . . 4 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 4
2. Server and Client Behavior . . . . . . . . . . . . . . . . . 4 2. Server and Client Behavior . . . . . . . . . . . . . . . . . 4
2.1. Response Header Field Syntax . . . . . . . . . . . . . . 4 2.1. Response Header Field Syntax . . . . . . . . . . . . . . 4
2.1.1. The max-age Directive . . . . . . . . . . . . . . . . 5 2.1.1. The pin- Directive . . . . . . . . . . . . . . . . . 5
2.1.2. The includeSubDomains Directive . . . . . . . . . . . 6 2.1.2. The max-age Directive . . . . . . . . . . . . . . . . 6
2.1.3. The report-uri Directive . . . . . . . . . . . . . . 6 2.1.3. The includeSubDomains Directive . . . . . . . . . . . 6
2.1.4. Examples . . . . . . . . . . . . . . . . . . . . . . 7 2.1.4. The report-uri Directive . . . . . . . . . . . . . . 6
2.1.5. Examples . . . . . . . . . . . . . . . . . . . . . . 7
2.2. Server Processing Model . . . . . . . . . . . . . . . . . 8 2.2. Server Processing Model . . . . . . . . . . . . . . . . . 8
2.2.1. HTTP-over-Secure-Transport Request Type . . . . . . . 8 2.2.1. HTTP-over-Secure-Transport Request Type . . . . . . . 8
2.2.2. HTTP Request Type . . . . . . . . . . . . . . . . . . 8 2.2.2. HTTP Request Type . . . . . . . . . . . . . . . . . . 9
2.3. User Agent Processing Model . . . . . . . . . . . . . . . 8 2.3. User Agent Processing Model . . . . . . . . . . . . . . . 9
2.3.1. Public-Key-Pins Response Header Field Processing . . 8 2.3.1. Public-Key-Pins Response Header Field Processing . . 9
2.3.2. Interaction of Public-Key-Pins and Public-Key-Pins- 2.3.2. Interaction of Public-Key-Pins and Public-Key-Pins-
Report-Only . . . . . . . . . . . . . . . . . . . . . 9 Report-Only . . . . . . . . . . . . . . . . . . . . . 10
2.3.3. Noting a Pinned Host - Storage Model . . . . . . . . 10 2.3.3. Noting a Pinned Host - Storage Model . . . . . . . . 11
2.3.4. HTTP-Equiv <Meta> Element Attribute . . . . . . . . . 11 2.3.4. HTTP-Equiv <Meta> Element Attribute . . . . . . . . . 12
2.4. Semantics of Pins . . . . . . . . . . . . . . . . . . . . 11 2.4. Semantics of Pins . . . . . . . . . . . . . . . . . . . . 12
2.5. Noting Pins . . . . . . . . . . . . . . . . . . . . . . . 12 2.5. Noting Pins . . . . . . . . . . . . . . . . . . . . . . . 13
2.6. Validating Pinned Connections . . . . . . . . . . . . . . 13 2.6. Validating Pinned Connections . . . . . . . . . . . . . . 14
2.7. Interactions With Preloaded Pin Lists . . . . . . . . . . 14 2.7. Interactions With Preloaded Pin Lists . . . . . . . . . . 15
2.8. Pinning Self-Signed End Entities . . . . . . . . . . . . 14 2.8. Pinning Self-Signed End Entities . . . . . . . . . . . . 15
3. Reporting Pin Validation Failure . . . . . . . . . . . . . . 14 3. Reporting Pin Validation Failure . . . . . . . . . . . . . . 15
4. Security Considerations . . . . . . . . . . . . . . . . . . . 17 4. Security Considerations . . . . . . . . . . . . . . . . . . . 18
4.1. Maximum max-age . . . . . . . . . . . . . . . . . . . . . 18 4.1. Maximum max-age . . . . . . . . . . . . . . . . . . . . . 19
4.2. Using includeSubDomains Safely . . . . . . . . . . . . . 18 4.2. Using includeSubDomains Safely . . . . . . . . . . . . . 19
4.3. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 19 4.3. Backup Pins . . . . . . . . . . . . . . . . . . . . . . . 20
4.4. Interactions With Cookie Scoping . . . . . . . . . . . . 20 4.4. Interactions With Cookie Scoping . . . . . . . . . . . . 21
5. Privacy Considerations . . . . . . . . . . . . . . . . . . . 20 4.5. Hostile Pinning . . . . . . . . . . . . . . . . . . . . . 21
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21 5. Privacy Considerations . . . . . . . . . . . . . . . . . . . 21
7. Usability Considerations . . . . . . . . . . . . . . . . . . 22 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 22 7. Usability Considerations . . . . . . . . . . . . . . . . . . 23
9. What's Changed . . . . . . . . . . . . . . . . . . . . . . . 22 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 24
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 9. What's Changed . . . . . . . . . . . . . . . . . . . . . . . 24
10.1. Normative References . . . . . . . . . . . . . . . . . . 23 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 25
10.2. Informative References . . . . . . . . . . . . . . . . . 24 10.1. Normative References . . . . . . . . . . . . . . . . . . 25
Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 25 10.2. Informative References . . . . . . . . . . . . . . . . . 26
Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . 25 Appendix A. Fingerprint Generation . . . . . . . . . . . . . . . 27
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 26 Appendix B. Deployment Guidance . . . . . . . . . . . . . . . . 27
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 28
1. Introduction 1. Introduction
This document defines a new HTTP header that enables a web host to This document defines a new HTTP header that enables user agents
express to user agents (UAs) which Subject Public Key Info (SPKI) (UAs) to determine which Subject Public Key Info (SPKI) structures
structure(s) UAs SHOULD expect to be present in the host's will be present in a web host's certificate chain in future TLS
certificate chain in future connections using TLS [RFC5246]. We call [RFC5246] connections.
this "public key pinning" (PKP); in particular, this document
describes HTTP-based public key pinning (HPKP). At least one UA
(Google Chrome) has experimented with the idea by shipping with a
user-extensible embedded set of Pins. Although effective, this does
not scale. This proposal addresses the scale problem.
Deploying PKP safely will require operational and organizational Deploying PKP safely will require operational and organizational
maturity due to the risk that hosts may make themselves unavailable maturity due to the risk that hosts may make themselves unavailable
by pinning to a (set of) SPKI(s) that becomes invalid (see by pinning to a (set of) SPKI(s) that becomes invalid (see
Section 4). With care, host operators can greatly reduce the risk of Section 4). With care, host operators can greatly reduce the risk of
main-in-the-middle (MITM) attacks and other false-authentication main-in-the-middle (MITM) attacks and other false-authentication
problems for their users without incurring undue risk. problems for their users without incurring undue risk.
PKP is meant to be used together with HTTP Strict Transport Security PKP is meant to be used together with HTTP Strict Transport Security
(HSTS) [RFC6797], but it is possible to pin keys without requiring (HSTS) [RFC6797], but it is possible to pin keys without requiring
skipping to change at page 4, line 31 skipping to change at page 4, line 30
in this specification. They are used by a server to indicate that a in this specification. They are used by a server to indicate that a
UA should perform Pin Validation (Section 2.6) for the host emitting UA should perform Pin Validation (Section 2.6) for the host emitting
the response message, and to provide the necessary information for the response message, and to provide the necessary information for
the UA to do so. the UA to do so.
Figure 1 describes the syntax (Augmented Backus-Naur Form) of the Figure 1 describes the syntax (Augmented Backus-Naur Form) of the
header fields, using the grammar defined in [RFC5234] and the rules header fields, using the grammar defined in [RFC5234] and the rules
defined in Section 3.2 of [RFC7230]. The field values of both header defined in Section 3.2 of [RFC7230]. The field values of both header
fields conform to the same rules. fields conform to the same rules.
Public-Key-Directives = [ directive ] *( OWS ";" OWS [ directive ] ) Public-Key-Directives = directive *( OWS ";" OWS directive )
directive = simple-directive
/ pin-directive
simple-directive = directive-name [ "=" directive-value ] directive = directive-name [ "=" directive-value ]
directive-name = token directive-name = token
directive-value = token directive-value = token
/ quoted-string / quoted-string
pin-directive = "pin-" token "=" quoted-string
Figure 1: HPKP Header Syntax Figure 1: HPKP Header Syntax
Optional white space (OWS) is used as defined in Section 3.2.3 of Optional white space (OWS) is used as defined in Section 3.2.3 of
[RFC7230]. token and quoted-string are used as defined in [RFC7230]. token and quoted-string are used as defined in
Section 3.2.6 of [RFC7230]. Section 3.2.6 of [RFC7230].
The directives defined in this specification are described below. The directives defined in this specification are described below.
The overall requirements for directives are: The overall requirements for directives are:
1. The order of appearance of directives is not significant. 1. The order of appearance of directives is not significant.
2. A given simple-directive MUST NOT appear more than once in a 2. A given directive MUST NOT appear more than once in a given
given header field. Directives are either optional or required, header field. Directives are either optional or required, as
as stipulated in their definitions. stipulated in their definitions.
3. Directive names are case-insensitive. 3. Directive names are case-insensitive.
4. UAs MUST ignore any header fields containing directives, or other 4. UAs MUST ignore any header fields containing directives, or other
header field value data, that do not conform to the syntax header field value data, that do not conform to the syntax
defined in this specification. In particular, UAs must not defined in this specification. In particular, UAs must not
attempt to fix malformed header fields. attempt to fix malformed header fields.
5. If a header field contains any directive(s) the UA does not 5. If a header field contains any directive(s) the UA does not
recognize, the UA MUST ignore those directives. recognize, the UA MUST ignore those directives.
6. If the PKP or PKP-RO header field otherwise satisfies the above 6. If the PKP or PKP-RO header field otherwise satisfies the above
requirements (1 through 5), the UA MUST process the directives it requirements (1 through 5), the UA MUST process the directives it
recognizes. recognizes.
Additional directives extending the semantic functionality of the Additional directives extending the semantic functionality of the
header fields can be defined in other specifications. The first such header fields can be defined in other specifications. The first such
specification will need to define a reistry for such directives. specification will need to define a registry for such directives.
Such future directives will be ignored by UAs implementing only this Such future directives will be ignored by UAs implementing only this
specification, as well as by generally non-conforming UAs. specification, as well as by generally non-conforming UAs.
When a connection passes Pin Validation using the UA's noted Pins for
the host at the time, the host becomes a Known Pinned Host.
2.1.1. The pin- Directive
The pin directive specifies a way for web host operators to indicate
a cryptographic identity that should be bound to a given web host.
The syntax of a pin directive is as follows:
pin-directive = pin-directive-name "=" pin-directive-value
pin-directive-name = "pin-" token
pin-directive-value = quoted-string
Figure 2: Pin Directive Syntax
In the pin-directive, the token is the name of a cryptographic hash In the pin-directive, the token is the name of a cryptographic hash
algorithm. The only algorithm allowed at this time is "sha256", i.e. algorithm. The only algorithm allowed at this time is "sha256", i.e.
the hash algorithm SHA256 ([RFC4634]); additional algorithms may be the hash algorithm SHA256 ([RFC4634]); additional algorithms may be
allowed for use in this context in the future. The quoted-string is allowed for use in this context in the future. The quoted-string is
a sequence of base 64 digits: the base 64-encoded SPKI Fingerprint a sequence of base 64 digits: the base 64-encoded SPKI Fingerprint
[RFC4648] (see Section 2.4). [RFC4648] (see Section 2.4).
When a connection passes Pin Validation using the UA's noted Pins for According to the processing rules of Section 2.1, the UA MUST ignore
the host at the time, the host becomes a Known Pinned Host. pin-directives with tokens naming hash algorithms it does not
recognize. If the set of remaining effective pin-directives is
empty, and if the host is a Known Pinned Host, the UA MUST cease to
consider the host as a Known Pinned Host (the UA should fail open).
According to rule 5, above, the UA MUST ignore pin-directives with The UA should indicate to users that the host is no longer a Known
tokens naming hash algorithms it does not recognize. If the set of Pinned Host.
remaining effective pin-directives is empty, and if the host is a
Known Pinned Host, the UA MUST cease to consider the host as a Known
Pinned Host (the UA should fail open). The UA should indicate to
users that the host is no longer a Known Pinned Host.
2.1.1. The max-age Directive Note, per the processing rules of Section 2.1, the pin-directive-name
is case insensitive.
2.1.2. The max-age Directive
The "max-age" directive specifies the number of seconds after the The "max-age" directive specifies the number of seconds after the
reception of the PKP header field during which the UA SHOULD regard 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 host (from whom the message was received) as a Known Pinned Host.
The "max-age" directive is REQUIRED to be present within a "Public- The "max-age" directive is REQUIRED to be present within a "Public-
Key-Pins" header field, and is OPTIONAL within a "Public-Key-Pins- Key-Pins" header field. The "max-age" directive is meaningless
Report-Only" header field. within a "Public-Key-Pins-Report-Only" header field, and UAs MUST
ignore it and not cache the header. See Section 2.3.3.
If present, the max-age directive is REQUIRED to have a directive The max-age directive is REQUIRED to have a directive value, for
value, for which the the syntax (after quoted-string unescaping, if which the syntax (after quoted-string unescaping, if necessary) is
necessary) is defined as: defined as:
max-age-value = delta-seconds max-age-value = delta-seconds
delta-seconds = 1*DIGIT delta-seconds = 1*DIGIT
Figure 2: max-age Value Syntax Figure 3: max-age Value Syntax
delta-seconds is used as defined in [RFC7234], Section 1.2.1. delta-seconds is used as defined in [RFC7234], Section 1.2.1.
2.1.2. The includeSubDomains Directive See Section 2.3.3 for limitations on the range of values for max-age.
2.1.3. The includeSubDomains Directive
The OPTIONAL includeSubDomains directive is a valueless directive The OPTIONAL includeSubDomains directive is a valueless directive
that, if present (i.e., it is "asserted"), signals to the UA that the that, 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 Pinning Policy applies to this Pinned Host as well as any subdomains
of the host's domain name. of the host's domain name.
2.1.3. The report-uri Directive 2.1.4. The report-uri Directive
The OPTIONAL report-uri directive indicates the URI to which the UA The OPTIONAL report-uri directive indicates the URI to which the UA
SHOULD report Pin Validation failures (Section 2.6). The UA POSTs SHOULD report Pin Validation failures (Section 2.6). The UA POSTs
the reports to the given URI as described in Section 3. the reports to the given URI as described in Section 3.
When used in the PKP or PKP-RO headers, the presence of a report-uri When used in the PKP or PKP-RO headers, the presence of a report-uri
directive indicates to the UA that in the event of Pin Validation directive indicates to the UA that in the event of Pin Validation
failure it SHOULD POST a report to the report-uri. If the header is failure it SHOULD POST a report to the report-uri. If the header is
Public-Key-Pins, the UA should do this in addition to terminating the Public-Key-Pins, the UA should do this in addition to terminating the
connection (as described in Section 2.6). connection (as described in Section 2.6).
skipping to change at page 7, line 16 skipping to change at page 7, line 31
SHOULD detect and break the loop by failing to send reports to and SHOULD detect and break the loop by failing to send reports to and
about those hosts. about those hosts.
In any case of report failure, the UA MAY attempt to re-send the In any case of report failure, the UA MAY attempt to re-send the
report later. report later.
UAs SHOULD limit the rate at which they send reports. For example, UAs SHOULD limit the rate at which they send reports. For example,
it is unnecessary to send the same report to the same report-uri more it is unnecessary to send the same report to the same report-uri more
than once per distinct set of declared Pins. than once per distinct set of declared Pins.
2.1.4. Examples 2.1.5. Examples
Figure 3 shows some example PKP and PKP-RO response header fields. Figure 4 shows some example PKP and PKP-RO response header fields.
(Lines are folded to fit.) (Lines are folded to fit.)
Public-Key-Pins: max-age=3000; Public-Key-Pins: max-age=3000;
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
Public-Key-Pins: max-age=2592000; Public-Key-Pins: max-age=2592000;
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=" pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
Public-Key-Pins: max-age=2592000; Public-Key-Pins: max-age=2592000;
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
skipping to change at page 7, line 50 skipping to change at page 8, line 33
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="; pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
max-age=259200 max-age=259200
Public-Key-Pins: Public-Key-Pins:
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="; pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
max-age=10000; includeSubDomains max-age=10000; includeSubDomains
Figure 3: HPKP Header Examples Figure 4: HPKP Header Examples
2.2. Server Processing Model 2.2. Server Processing Model
This section describes the processing model that Pinned Hosts This section describes the processing model that Pinned Hosts
implement. The model has 2 parts: (1) the processing rules for HTTP implement. The model has 2 parts: (1) the processing rules for HTTP
request messages received over a secure transport (e.g. TLS); and request messages received over a secure transport (e.g.
(2) the processing rules for HTTP request messages received over non- authenticated, non-anonymous TLS); and (2) the processing rules for
secure transports, such as TCP. HTTP request messages received over non-secure transports, such as
TCP.
2.2.1. HTTP-over-Secure-Transport Request Type 2.2.1. HTTP-over-Secure-Transport Request Type
When replying to an HTTP request that was conveyed over a secure When replying to an HTTP request that was conveyed over a secure
transport, a Pinned Host SHOULD include in its response exactly one transport, a Pinned Host SHOULD include in its response exactly one
PKP header field, exactly one PKP-RO header field, or one of each. PKP header field, exactly one PKP-RO header field, or one of each.
Each instance of either header field MUST satisfy the grammar Each instance of either header field MUST satisfy the grammar
specified in Section 2.1. specified in Section 2.1.
Establishing a given host as a Known Pinned Host, in the context of a Establishing a given host as a Known Pinned Host, in the context of a
skipping to change at page 9, line 20 skipping to change at page 10, line 6
already maintained by the UA. already maintained by the UA.
The max-age value is essentially a "time to live" value relative to 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. If the time of the most recent observation of the PKP header field. If
the max-age header field value token has a value of 0, the UA MUST the max-age header field value token has a value of 0, the UA MUST
remove its cached Pinning Policy information (including the remove its cached Pinning Policy information (including the
includeSubDomains directive, if asserted) if the Pinned Host is includeSubDomains directive, if asserted) if the Pinned Host is
Known, or, MUST NOT note this Pinned Host if it is not yet Known. Known, or, MUST NOT note this Pinned Host if it is not yet Known.
If a UA receives more than one PKP header field or more than one PKP- If a UA receives more than one PKP header field or more than one PKP-
RO header fieled in an HTTP response message over secure transport, RO header field in an HTTP response message over secure transport,
then the UA MUST process only the first PKP header field (if present) then the UA MUST process only the first PKP header field (if present)
and only the first PKP-RO header field (if present). and only the first PKP-RO header field (if present).
If the UA receives the HTTP response over insecure transport, or if 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 the PKP header is not a Valid Pinning Header (see Section 2.5), the
UA MUST ignore any present PKP header field(s). Similarly, if the UA UA MUST ignore any present PKP header field(s). Similarly, if the UA
receives the HTTP response over insecure transport, the UA MUST receives the HTTP response over insecure transport, the UA MUST
ignore any present PKP-RO header field(s). The UA MUST ignore any ignore any present PKP-RO header field(s). The UA MUST ignore any
PKP or PKP-RO header fields not conforming to the grammar specified PKP or PKP-RO header fields not conforming to the grammar specified
in Section 2.1. in Section 2.1.
skipping to change at page 10, line 10 skipping to change at page 10, line 43
Note: There is no purpose to using the PKP-RO header without the Note: There is no purpose to using the PKP-RO header without the
report-uri directive. User Agents MAY discard such headers without report-uri directive. User Agents MAY discard such headers without
interpreting them further. interpreting them further.
When the PKP header is used with a report-uri, the UA SHOULD POST When the PKP header is used with a report-uri, the UA SHOULD POST
reports for Pin Validation failures to the indicated report-uri, as reports for Pin Validation failures to the indicated report-uri, as
well as enforcing Pin Validation. well as enforcing Pin Validation.
If a host sets the PKP-RO header, the UA SHOULD note the Pins and If a host sets the PKP-RO header, the UA SHOULD note the Pins and
directives given in the PKP-RO header as specified by the max-age directives given in the PKP-RO header, ignoring any max-age
directive. If the UA does note the Pins and directives in the PKP-RO directive. If the UA does note the Pins and directives in the PKP-RO
header it SHOULD evaluate the specified policy and SHOULD report any header it SHOULD evaluate the specified policy and SHOULD report any
would-be Pin Validation failures that would occur if the report-only would-be Pin Validation failures that would occur if the report-only
policy were enforced. policy were enforced.
If a host sets both the PKP header and the PKP-RO header, the UA MUST If a host sets both the PKP header and the PKP-RO header, the UA MUST
note and enforce Pin Validation as specified by the PKP header, and note and enforce Pin Validation as specified by the PKP header, and
SHOULD process the Pins and directives given in the PKP-RO header. SHOULD process the Pins and directives given in the PKP-RO header.
If the UA does process the Pins and directives in the PKP-RO header If the UA does process the Pins and directives in the PKP-RO header
it SHOULD evaluate the specified policy and SHOULD report any would- it SHOULD evaluate the specified policy and SHOULD report any would-
skipping to change at page 11, line 32 skipping to change at page 12, line 17
age directive of 90 days in its Valid Pinning Header, the UA MAY age directive of 90 days in its Valid Pinning Header, the UA MAY
behave as if the max-age were effectively 60 days. (One way to behave as if the max-age were effectively 60 days. (One way to
achieve this behavior is for the UA to simply store a value of 60 achieve this behavior is for the UA to simply store a value of 60
days instead of the 90 day value provided by the Pinned Host.) For days instead of the 90 day value provided by the Pinned Host.) For
UA implementation guidance on how to select a maximum max-age, see UA implementation guidance on how to select a maximum max-age, see
Section 4.1. Section 4.1.
The UA MUST NOT modify any pinning metadata of any superdomain The UA MUST NOT modify any pinning metadata of any superdomain
matched Known Pinned Host. matched Known Pinned Host.
The UA MUST NOT cache information derived from a PKP-RO header.
(PKP-RO headers are useful only at the time of receipt and
processing.)
2.3.4. HTTP-Equiv <Meta> Element Attribute 2.3.4. HTTP-Equiv <Meta> Element Attribute
UAs MUST NOT heed http-equiv="Public-Key-Pins" or http-equiv="Public- UAs MUST NOT heed http-equiv="Public-Key-Pins" or http-equiv="Public-
Key-Pins-Report-Only" attribute settings on <meta> elements Key-Pins-Report-Only" attribute settings on <meta> elements
[W3C.REC-html401-19991224] in received content. [W3C.REC-html401-19991224] in received content.
2.4. Semantics of Pins 2.4. Semantics of Pins
An SPKI Fingerprint is defined as the output of a known cryptographic An SPKI Fingerprint is defined as the output of a known cryptographic
hash algorithm whose input is the DER-encoded ASN.1 representation of hash algorithm whose input is the DER-encoded ASN.1 representation of
skipping to change at page 12, line 6 skipping to change at page 12, line 43
the SPKI Fingerprint computed using that algorithm. the SPKI Fingerprint computed using that algorithm.
The SPKI Fingerprint is encoded in base 64 for use in an HTTP header The SPKI Fingerprint is encoded in base 64 for use in an HTTP header
[RFC4648]. [RFC4648].
In this version of the specification, the known cryptographic hash In this version of the specification, the known cryptographic hash
algorithm is SHA-256, identified as "sha256" [RFC6234]. (Future algorithm is SHA-256, identified as "sha256" [RFC6234]. (Future
specifications may add new algorithms and deprecate old ones.) UAs specifications may add new algorithms and deprecate old ones.) UAs
MUST ignore Pins for which they do not recognize the algorithm MUST ignore Pins for which they do not recognize the algorithm
identifier. UAs MUST continue to process the rest of a PKP response identifier. UAs MUST continue to process the rest of a PKP response
header field and note Pins for algorithms they do recognize; UAs MUST header field and note Pins for algorithms they do recognize.
recognize "sha256".
Figure 4 reproduces the definition of the SubjectPublicKeyInfo Figure 5 reproduces the definition of the SubjectPublicKeyInfo
structure in [RFC5280]. 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 4: SPKI Definition Figure 5: SPKI Definition
If the certificate's subjectPublicKeyInfo is incomplete when taken in If the certificate's subjectPublicKeyInfo is incomplete when taken in
isolation, such as when holding a DSA key without domain parameters, isolation, such as when holding a DSA key without domain parameters,
a public key pin cannot be formed. 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
skipping to change at page 13, line 39 skipping to change at page 14, line 30
the policy expressed in the PKP field or in previously-noted Pins for the policy expressed in the PKP field or in previously-noted Pins for
the Known Pinned Host. the Known Pinned Host.
The UA need not note any Pins or other policy expressed in the PKP-RO The UA need not note any Pins or other policy expressed in the PKP-RO
response header field, except for the purpose of determining that it response header field, except for the purpose of determining that it
has already sent a report for a given policy. UAs SHOULD make a best has already sent a report for a given policy. UAs SHOULD make a best
effort not to inundate report-uris with redundant reports. effort not to inundate report-uris with redundant reports.
2.6. 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 using a TLS connection, if the
errors, the UA MUST terminate the connection without allowing the TLS connection has errors, the UA MUST terminate the connection
user to proceed anyway. (This behavior is the same as that required without allowing the user to proceed anyway. (This behavior is the
by [RFC6797].) same as that required by [RFC6797].)
If the connection has no errors, then the UA will determine whether If the connection has no errors, then the UA will determine whether
to apply a new, additional correctness check: Pin Validation. A UA to apply a new, additional correctness check: Pin Validation. A UA
SHOULD perform Pin Validation whenever connecting to a Known Pinned SHOULD perform Pin Validation whenever connecting to a Known Pinned
Host. It is acceptable to allow Pin Validation to be disabled for Host, as soon as possible (e.g. immediately after receiving the
some Hosts according to local policy. For example, a UA may disable Server Certificate message). It is acceptable to allow Pin
Pin Validation for Pinned Hosts whose validated certificate chain Validation to be disabled for some Hosts according to local policy.
terminates at a user-defined trust anchor, rather than a trust anchor For example, a UA may disable Pin Validation for Pinned Hosts whose
built-in to the UA. validated certificate chain terminates at a user-defined trust
anchor, rather than a trust anchor built-in to the UA (or underlying
platform).
To perform Pin Validation, the UA will compute the SPKI Fingerprints To perform Pin Validation, the UA will compute the SPKI Fingerprints
for each certificate in the Pinned Host's validated certificate for each certificate in the Pinned Host's validated certificate
chain, using each supported hash algorithm for each certificate. (As chain, using each supported hash algorithm for each certificate. (As
described in Section 2.4, certificates whose SPKI cannot be taken in described in Section 2.4, certificates whose SPKI cannot be taken in
isolation cannot be pinned.) The UA MUST ignore superfluous isolation cannot be pinned.) The UA MUST ignore superfluous
certificates in the chain that do not form part of the validating certificates in the chain that do not form part of the validating
chain. The UA will then check that the set of these SPKI chain. The UA will then check that the set of these SPKI
Fingerprints intersects the set of SPKI Fingerprints in that Pinned Fingerprints intersects the set of SPKI Fingerprints in that Pinned
Host's Pinning Metadata. If there is set intersection, the UA Host's Pinning Metadata. If there is set intersection, the UA
continues with the connection as normal. Otherwise, the UA MUST continues with the connection as normal. Otherwise, the UA MUST
treat this Pin Validation Failure as a non-recoverable error. Any treat this Pin Validation Failure as a non-recoverable error. Any
procedure that matches the results of this Pin Validation procedure procedure that matches the results of this Pin Validation procedure
is considered equivalent. is considered equivalent.
A UA that has previous noted a host as a Known Pinned Host MUST A UA that has previously noted a host as a Known Pinned Host MUST
perform Pin Validation when setting up the TLS session, before perform Pin Validation when setting up the TLS session, before
beginning an HTTP conversation over the TLS channel. beginning an HTTP conversation over the TLS channel.
UAs send validation failure reports only when Pin Validation is UAs send validation failure reports only when Pin Validation is
actually in effect. Pin Validation might not be in effect e.g. actually in effect. Pin Validation might not be in effect e.g.
because the user has elected to disable it, or because a presented because the user has elected to disable it, or because a presented
certificate chain chains up to a locally-installed anchor. In such certificate chain chains up to a user-defined trust anchor. In such
cases, UAs SHOULD NOT send reports. cases, UAs SHOULD NOT send reports.
2.7. Interactions With Preloaded Pin Lists 2.7. Interactions With Preloaded Pin Lists
UAs MAY choose to implement additional sources of pinning UAs MAY choose to implement additional sources of pinning
information, such as through built-in lists of pinning information. information, such as through built-in lists of pinning information.
Such UAs should allow users to override such additional sources, Such UAs should allow users to override such additional sources,
including disabling them from consideration. including disabling them from consideration.
The effective policy for a Known Pinned Host that has both built-in The effective policy for a Known Pinned Host that has both built-in
skipping to change at page 14, line 51 skipping to change at page 15, line 43
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. Reporting Pin Validation Failure 3. Reporting Pin Validation Failure
When a Known Pinned Host has set the report-uri directive, the UA When a Known Pinned Host has set the report-uri directive, the UA
SHOULD report Pin Validation failures to the indicated URI. The UA SHOULD report Pin Validation failures to the indicated URI. The UA
does this by POSTing a JSON [RFC4627] message to the URI; the JSON does this by POSTing a JSON [RFC7159] message to the URI; the JSON
message takes this form: message takes this form:
{ {
"date-time": date-time, "date-time": date-time,
"hostname": hostname, "hostname": hostname,
"port": port, "port": port,
"effective-expiration-date": expiration-date, "effective-expiration-date": expiration-date,
"include-subdomains": include-subdomains, "include-subdomains": include-subdomains,
"noted-hostname": noted-hostname,
"served-certificate-chain": [ "served-certificate-chain": [
pem1, ... pemN pem1, ... pemN
], ],
"validated-certificate-chain": [ "validated-certificate-chain": [
pem1, ... pemN pem1, ... pemN
], ],
"known-pins": [ "known-pins": [
known-pin1, ... known-pinN known-pin1, ... known-pinN
] ]
} }
Figure 5: JSON Report Format Figure 6: JSON Report Format
Whitespace outside of quoted strings is not significant. The key/ Whitespace outside of quoted strings is not significant. The key/
value pairs may appear in any order, but each MUST appear only once. value pairs may appear in any order, but each MUST appear only once.
The date-time indicates the time the UA observed the Pin Validation The date-time indicates the time the UA observed the Pin Validation
failure. It is provided as a string formatted according to failure. It is provided as a string formatted according to
Section 5.6, "Internet Date/Time Format", of [RFC3339]. Section 5.6, "Internet Date/Time Format", of [RFC3339].
The hostname is the hostname to which the UA made the original The hostname is the hostname to which the UA made the original
request that failed Pin Validation. It is provided as a string. request that failed Pin Validation. It is provided as a string.
skipping to change at page 15, line 45 skipping to change at page 16, line 46
failed Pin Validation. It is provided as an integer. failed Pin Validation. It is provided as an integer.
The effective-expiration-date is the Effective Expiration Date for The effective-expiration-date is the Effective Expiration Date for
the noted Pins. It is provided as a string formatted according to the noted Pins. It is provided as a string formatted according to
Section 5.6, "Internet Date/Time Format", of [RFC3339]. Section 5.6, "Internet Date/Time Format", of [RFC3339].
include-subdomains indicates whether or not the UA has noted the include-subdomains indicates whether or not the UA has noted the
includeSubDomains directive for the Known Pinned Host. It is includeSubDomains directive for the Known Pinned Host. It is
provided as one of the JSON identifiers "true" or "false". provided as one of the JSON identifiers "true" or "false".
noted-hostname indicates the hostname that the UA noted when it noted
the Known Pinned Host. This field allows operators to understand why
Pin Validation was performed for e.g. foo.example.com when the noted
Known Pinned Host was example.com with includeSubDomains set.
The served-certificate-chain is the certificate chain, as served by The served-certificate-chain is the certificate chain, as served by
the Known Pinned Host during TLS session setup. It is provided as an the Known Pinned Host during TLS session setup. It is provided as an
array of strings; each string pem1, ... pemN is the PEM array of strings; each string pem1, ... pemN is the PEM
representation of each X.509 certificate as described in representation of each X.509 certificate as described in
[I-D.josefsson-pkix-textual]. [I-D.josefsson-pkix-textual].
The validated-certificate-chain is the certificate chain, as The validated-certificate-chain is the certificate chain, as
constructed by the UA during certificate chain verification. (This constructed by the UA during certificate chain verification. (This
may differ from the served-certificate-chain.) It is provided as an may differ from the served-certificate-chain.) It is provided as an
array of strings; each string pem1, ... pemN is the PEM array of strings; each string pem1, ... pemN is the PEM
skipping to change at page 16, line 18 skipping to change at page 17, line 24
in more than one way during the validation process, they SHOULD send in more than one way during the validation process, they SHOULD send
the last chain built. In this way they can avoid keeping too much the last chain built. In this way they can avoid keeping too much
state during the validation process. state during the validation process.
The known-pins are the Pins that the UA has noted for the Known 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 Pinned Host. They are provided as an array of strings with the
syntax: syntax:
known-pin = token "=" quoted-string known-pin = token "=" quoted-string
Figure 6: Known Pin Syntax Figure 7: Known Pin Syntax
As in Section 2.4, the token refers to the algorithm name, and the 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. quoted-string refers to the base 64 encoding of the SPKI Fingerprint.
When formulating the JSON POST body, the UA MUST either use single- When formulating the JSON POST body, the UA MUST either use single-
quoted JSON strings, or use double-quoted JSON strings and \-escape quoted JSON strings, or use double-quoted JSON strings and \-escape
the embedded double quotes in the quoted-string part of the known- the embedded double quotes in the quoted-string part of the known-
pin. pin.
Figure 7 shows an example of a Pin Validation failure report. (PEM Figure 8 shows an example of a Pin Validation failure report. (PEM
strings are shown on multiple lines for readability.) strings are shown on multiple lines for readability.)
{ {
"date-time": "2014-04-06T13:00:50Z", "date-time": "2014-04-06T13:00:50Z",
"hostname": "www.example.com", "hostname": "www.example.com",
"port": 443, "port": 443,
"effective-expiration-date": "2014-05-01T12:40:50Z" "effective-expiration-date": "2014-05-01T12:40:50Z"
"include-subdomains": false, "include-subdomains": false,
"served-certificate-chain": [ "served-certificate-chain": [
"-----BEGIN CERTIFICATE-----\n "-----BEGIN CERTIFICATE-----\n
skipping to change at page 17, line 37 skipping to change at page 18, line 37
yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx\n yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx\n
-----END CERTIFICATE-----", -----END CERTIFICATE-----",
... ...
], ],
"known-pins": [ "known-pins": [
'pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="', 'pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="',
"pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\"" "pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\""
] ]
} }
Figure 7: Pin Validation Failure Report Example Figure 8: Pin Validation Failure Report Example
4. Security Considerations 4. Security Considerations
Pinning public keys helps hosts strongly assert their cryptographic Pinning public keys helps hosts strongly assert their cryptographic
identity even in the face of issuer error, malfeasance or compromise. identity even in the face of issuer error, malfeasance or compromise.
But there is some risk that a host operator could lose or lose 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 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 compromise). If the operator had pinned only the key of the
host's end entity certificate, the operator would not be able to 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 serve their web site or application in a way that UAs would trust for
skipping to change at page 18, line 11 skipping to change at page 19, line 11
Therefore, there is a necessary trade-off between two competing Therefore, there is a necessary trade-off between two competing
goods: pin specificity and maximal reduction of the scope of issuers goods: pin specificity and maximal reduction of the scope of issuers
on the one hand; and flexibility and resilience of the host's on the one hand; and flexibility and resilience of the host's
cryptographic identity on the other hand. One way to resolve this 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) 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 of the host's end entity certificate(s). Often, a valid certificate
chain will have at least two certificates above the end entity chain will have at least two certificates above the end entity
certificate: the intermediate issuer, and the trust anchor. certificate: the intermediate issuer, and the trust anchor.
Operators can pin any one or more of the public keys in this chain, 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 and indeed MUST pin to issuers not in the chain (as, for example, a
Backup Pin). Pinning to an intermediate issuer, or even to a trust Backup Pin). Pinning to an intermediate issuer, or even to a trust
anchor or root, still significantly reduces the number of issuers who anchor or root, still significantly reduces the number of issuers who
can issue end entity certificates for the Known Pinned Host, while can issue end entity certificates for the Known Pinned Host, while
still giving that host flexibility to change keys without a still giving that host flexibility to change keys without a
disruption of service. disruption of service.
4.1. Maximum max-age 4.1. Maximum max-age
As mentioned in Section 2.3.3, UAs MAY cap the max-age value at some As mentioned in Section 2.3.3, UAs MAY cap the max-age value at some
upper limit. There is a security trade-off in that low maximum upper limit. There is a security trade-off in that low maximum
skipping to change at page 19, line 8 skipping to change at page 20, line 8
use different Valid Pinning Headers. If a host whose hostname is a use different Valid Pinning Headers. If a host whose hostname is a
parent domain for another host sets the includeSubDomains directive, parent domain for another host sets the includeSubDomains directive,
the two hosts' Pins may conflict with each other. For example, the two hosts' Pins may conflict with each other. For example,
consider two Known Pinned Hosts, example.com and consider two Known Pinned Hosts, example.com and
subdomain.example.com. Assume example.com sets a Valid Pinning subdomain.example.com. Assume example.com sets a Valid Pinning
Header such as this: Header such as this:
Public-Key-Pins: max-age=12000; pin-sha256="ABC..."; Public-Key-Pins: max-age=12000; pin-sha256="ABC...";
pin-sha256="DEF..."; includeSubDomains pin-sha256="DEF..."; includeSubDomains
Figure 8: example.com Valid Pinning Header Figure 9: example.com Valid Pinning Header
Assume subdomain.example.com sets a Valid Pinning Header such as Assume subdomain.example.com sets a Valid Pinning Header such as
this: this:
Public-Key-Pins: pin-sha256="GHI..."; pin-sha256="JKL..." Public-Key-Pins: pin-sha256="GHI..."; pin-sha256="JKL..."
Figure 9: subdomain.example.com Valid Pinning Header Figure 10: subdomain.example.com Valid Pinning Header
Assume a UA that has not previously noted any Pins for either of Assume a UA that has not previously noted any Pins for either of
these hosts. If the UA first contacts subdomain.example.com, it will these hosts. If the UA first contacts subdomain.example.com, it will
note the Pins in the Valid Pinning Header, and perform Pin Validation note the Pins in the Valid Pinning Header, and perform Pin Validation
as normal on subsequent conections. If the UA then contacts as normal on subsequent conections. If the UA then contacts
example.com, again it will note the Pins and perform Pin Validation example.com, again it will note the Pins and perform Pin Validation
on future connections. on future connections.
However, if the UA happened to visit example.com before However, if the UA happened to visit example.com before
subdomain.example.com, the UA would, due to example.com's use of the subdomain.example.com, the UA would, due to example.com's use of the
skipping to change at page 20, line 17 skipping to change at page 21, line 17
side of keeping a not-yet-deployed key pair is that if an attacker side of keeping a not-yet-deployed key pair is that if an attacker
gains control of the private key she will be able to perform a MITM gains control of the private key she will be able to perform a MITM
attack without being discovered. Operators must take care to avoid attack without being discovered. Operators must take care to avoid
leaking the key such as keeping it offline. leaking the key such as keeping it offline.
4.4. Interactions With Cookie Scoping 4.4. Interactions With Cookie Scoping
HTTP cookies [RFC6265] set by a Known Pinned Host can be stolen by a HTTP cookies [RFC6265] set by a Known Pinned Host can be stolen by a
network attacker who can forge web and DNS responses so as to cause a network attacker who can forge web and DNS responses so as to cause a
client to send the cookies to a phony subdomain of the host. To client to send the cookies to a phony subdomain of the host. To
prevent this, hosts SHOULD set the "secure" attribute and omit the prevent this, hosts SHOULD set the "secure" attribute and precisely
"domain" attribute on all security-sensitive cookies, such as session scope the "domain" attribute on all security-sensitive cookies, such
cookies. These settings tell the browser that the cookie should only as session cookies. These settings tell the browser that the cookie
be sent back to the originating host (not its subdomains), and should should only be sent back to the specific host(s) (and not e.g. all
only be sent over HTTPS (not HTTP). subdomains of a given domain), and should only be sent over HTTPS
(not HTTP).
4.5. Hostile Pinning
An attacker who is able to obtain a valid certificate for a domain,
either through misissuance by a Certification Authority or through
other means, such as being the prior owner of a given domain, may
attempt to perform 'hostile' pinning. In this scenario, the attacker
provides a Valid Pinning Header that pins to a set of SPKIs of the
attacker's choice. If a UA has not previously noted pins for that
host, it may note the attacker's pins, preventing access to the
legitimate site.
This attack is mitigated through several means. Most prominantly,
the attack can only persist for the maximum max-age (see
Section 4.1). Web host operators can reduce the opportunity for
attack by working to preload the host's pins within the UA.
Operators may further detect such misissuance through other means,
such as Certificate Transparency ([RFC6962]).
5. Privacy Considerations 5. Privacy Considerations
Hosts can use HSTS or HPKP as a "super-cookie", by setting distinct Hosts can use HSTS or HPKP as a "super-cookie", by setting distinct
policies for a number of subdomains. For example, assume example.com policies for a number of subdomains. For example, assume example.com
wishes to track distinct UAs without explicitly setting a cookie, or wishes to track distinct UAs without explicitly setting a cookie, or
if a previously-set cookie is deleted from the UA's cookie store. if a previously-set cookie is deleted from the UA's cookie store.
Here are two attack scenarios. Here are two attack scenarios.
o example.com can use report-uri and the ability to pin arbitrary o example.com can use report-uri and the ability to pin arbitrary
skipping to change at page 21, line 5 skipping to change at page 22, line 25
distinguishing string and sets it as if it were a pin. distinguishing string and sets it as if it were a pin.
3. The certificate chain served by bad.example.com does not pass 3. The certificate chain served by bad.example.com does not pass
Pin Validation given the pin set the host asserted in (1). Pin Validation given the pin set the host asserted in (1).
The HPKP-conforming UA attempts to report the Pin Validation The HPKP-conforming UA attempts to report the Pin Validation
failure to the specified report-uri, including the certificate failure to the specified report-uri, including the certificate
chain it observed and the SPKI hashes it expected to see. chain it observed and the SPKI hashes it expected to see.
Among the SPKI hashes is the distinguishing string in step Among the SPKI hashes is the distinguishing string in step
(2). (2).
4. Different site operators/origins can optionally collaborate by o Different site operators/origins can optionally collaborate by
setting the report-uri to be in an origin they share setting the report-uri to be in an origin they share
administrative control of. UAs MAY, therefore, refuse to send administrative control of. UAs MAY, therefore, refuse to send
reports outside of the origin that set the PKP or PKP-RO reports outside of the origin that set the PKP or PKP-RO header.
header.
o example.com can use server name indication (SNI; [RFC3546]) and o example.com can use server name indication (SNI; [RFC3546]) and
subdomains to distinguish UAs. subdomains to distinguish UAs.
1. example.com sets a Valid Pinning Header in its response to 1. example.com sets a Valid Pinning Header in its response to
requests. The header asserts the includeSubDomains directive. requests. The header asserts the includeSubDomains directive.
2. On a subsequent page view, the host responds with a page 2. On a subsequent page view, the host responds with a page
including the subresource https://0.fingerprint.example.com/ including the subresource https://0.fingerprint.example.com/
foo.png, and the server responds using a certificate chain foo.png, and the server responds using a certificate chain
that does not pass Pin Validation for the pin-set defined in that does not pass Pin Validation for the pin-set defined in
the Valid Pinning Header in step (1). The HPKP-conforming UA the Valid Pinning Header in step (1). The HPKP-conforming UA
will close the connection, never completing the request to will close the connection, never completing the request to
0.fingerprint.example.com. The host may thus note that this 0.fingerprint.example.com. The host may thus note that this
particular UA had noted the (good) Pins for that subdomain. particular UA had noted the (good) Pins for that subdomain.
3. example.com can distinguish 2^N UAs by serving Valid Pinning 3. example.com can distinguish 2^N UAs by serving Valid Pinning
Headers from an arbitrary number N distinct subdomains, giving Headers from an arbitrary number N distinct subdomains. For
some UAs Valid Pinning Headers for some, but not all any given subdomain n.fingerprint.example.com, the host may
subdomains (causing subsequent requests for deliver a Valid Pinning Header to one UA, but not deliver it
n.fingerprint.example.com to fail), and giving some UAs no to a different UA. The server may then change the
Valid Pinning Header for other subdomains (causing subsequent configuration for n.fingerprint.example.com. If the UA fails
requests for m.fingerprint.example.com to succeed). to connect, it was in the set of UAs that were pinned, which
can be distinguished from the UAs that were not pinned, as
they will succeed in connecting. The host may repeat this for
a sufficient number of subdomains necessary to distinguish
individual UAs.
Conforming implementations (as well as implementations conforming to o Conforming implementations (as well as implementations conforming
[RFC6797]) must store state about which domains have set policies, to [RFC6797]) must store state about which domains have set
hence which domains the UA has contacted. A forensic attacker might policies, hence which domains the UA has contacted. Because these
find this information useful, even if the user has cleared other policies cause remotely-detectable behaviours, it is advisable
parts of the UA's state. that UAs have a way for privacy-sensitive users to clear current
Pins for Pinned Hosts, and to allow users to query the current
state of Pinned Hosts. In addition, note that because Pinning a
Host implies a degree of persistent state, an attacker with
physical access to a device may be able to recover information
about hosts a user has visited, even if the user has cleared other
parts of the UA's state.
o Pin reports, as noted in Section 3, contains information about the
certificate chain that has failed pin validation. In some cases,
such as organization-wide compromise of the end-to-end security of
TLS, this may include information about the interception tools and
design used by the organization that the organization would
otherwise prefer not be disclosed.
6. IANA Considerations 6. IANA Considerations
IANA is requested to register the response headers described in this IANA is requested to register the response headers described in this
document in the "Message Headers" registry ([permanent-headers] with document in the "Message Headers" registry ([permanent-headers] with
the following parameters: the following parameters:
o Header Field Names should be "Public-Key-Pins" and "Public-Key- o Header Field Names should be "Public-Key-Pins" and "Public-Key-
Pins-Report-Only". Pins-Report-Only".
skipping to change at page 22, line 21 skipping to change at page 24, line 9
cryptographic identity of the host. cryptographic identity of the host.
It is advisable that UAs have a way for users to clear current Pins It is advisable that UAs have a way for users to clear current Pins
for Pinned Hosts, and to allow users to query the current state of for Pinned Hosts, and to allow users to query the current state of
Pinned Hosts. Pinned Hosts.
8. Acknowledgements 8. Acknowledgements
Thanks to Tobias Gondrom, Jeff Hodges, Paul Hoffman, Ivan Krstic, Thanks to Tobias Gondrom, Jeff Hodges, Paul Hoffman, Ivan Krstic,
Adam Langley, Barry Leiba, Nicolas Lidzborski, SM, James Manger, Yoav Adam Langley, Barry Leiba, Nicolas Lidzborski, SM, James Manger, Yoav
Nir, Trevor Perrin, Eric Rescorla, Tom Ritter, and Yan Zhu for Nir, Trevor Perrin, Eric Rescorla, Pete Resnick, Tom Ritter, and Yan
suggestions and edits that clarified the text. Zhu for suggestions and edits that clarified the text.
9. What's Changed 9. What's Changed
[RFC EDITOR: PLEASE REMOVE THIS SECTION] [RFC EDITOR: PLEASE REMOVE THIS SECTION]
Added attack scenario for hostile pinning, as well as mitigations.
Added privacy considerations for the report-uri processing.
Moved pin-directive into its own directive section, leaving the
header syntax to only define directive-name and directive-value.
Updated Privacy Considerations to note that UAs should offer ways to
clear data, and in doing so, clarified the term 'forensic attacker'
to indicate an attacker with physical access.
Updated ABNF for Public-Key-Directives to indicate that at least one
directive is required, and that a directive is required between each
semi-colon.
Clarified that max-age is REQUIRED for PKP, but OPTIONAL for PKP-RO Clarified that max-age is REQUIRED for PKP, but OPTIONAL for PKP-RO
(where it has no effect. (where it has no effect.
Updated header field syntax and description to match that in Updated header field syntax and description to match that in
[RFC7230]. [RFC7230].
Updated normative references to current documents. Updated normative references to current documents.
Removed the strict directive. Removed the strict directive.
skipping to change at page 23, line 33 skipping to change at page 25, line 33
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.
10. References 10. References
10.1. Normative References 10.1. Normative References
[I-D.josefsson-pkix-textual] [I-D.josefsson-pkix-textual]
Josefsson, S. and S. Leonard, "Text Encodings of PKIX and Josefsson, S. and S. Leonard, "Textual Encodings of PKIX,
CMS Structures", draft-josefsson-pkix-textual-05 (work in PKCS, and CMS Structures", draft-josefsson-pkix-textual-07
progress), July 2014. (work in progress), September 2014.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997. Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the
Internet: Timestamps", RFC 3339, July 2002. Internet: Timestamps", RFC 3339, July 2002.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66, RFC Resource Identifier (URI): Generic Syntax", STD 66, RFC
3986, January 2005. 3986, January 2005.
[RFC4627] Crockford, D., "The application/json Media Type for
JavaScript Object Notation (JSON)", RFC 4627, July 2006.
[RFC4634] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms [RFC4634] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
(SHA and HMAC-SHA)", RFC 4634, July 2006. (SHA and HMAC-SHA)", RFC 4634, July 2006.
[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
Encodings", RFC 4648, October 2006. Encodings", RFC 4648, October 2006.
[RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234, January 2008. Specifications: ABNF", STD 68, RFC 5234, January 2008.
[RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
skipping to change at page 24, line 28 skipping to change at page 26, line 25
[RFC6234] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms [RFC6234] Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
(SHA and SHA-based HMAC and HKDF)", RFC 6234, May 2011. (SHA and SHA-based HMAC and HKDF)", RFC 6234, May 2011.
[RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265,
April 2011. April 2011.
[RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict [RFC6797] Hodges, J., Jackson, C., and A. Barth, "HTTP Strict
Transport Security (HSTS)", RFC 6797, November 2012. Transport Security (HSTS)", RFC 6797, November 2012.
[RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data
Interchange Format", RFC 7159, March 2014.
[RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol [RFC7230] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol
(HTTP/1.1): Message Syntax and Routing", RFC 7230, June (HTTP/1.1): Message Syntax and Routing", RFC 7230, June
2014. 2014.
[RFC7234] Fielding, R., Nottingham, M., and J. Reschke, "Hypertext [RFC7234] Fielding, R., Nottingham, M., and J. Reschke, "Hypertext
Transfer Protocol (HTTP/1.1): Caching", RFC 7234, June Transfer Protocol (HTTP/1.1): Caching", RFC 7234, June
2014. 2014.
[W3C.REC-html401-19991224] [W3C.REC-html401-19991224]
Raggett, D., Hors, A., and I. Jacobs, "HTML 4.01 Raggett, D., Hors, A., and I. Jacobs, "HTML 4.01
skipping to change at page 25, line 9 skipping to change at page 27, line 9
10.2. Informative References 10.2. Informative References
[I-D.perrin-tls-tack] [I-D.perrin-tls-tack]
Marlinspike, M., "Trust Assertions for Certificate Keys", Marlinspike, M., "Trust Assertions for Certificate Keys",
draft-perrin-tls-tack-02 (work in progress), January 2013. draft-perrin-tls-tack-02 (work in progress), January 2013.
[RFC3546] Blake-Wilson, S., Nystrom, M., Hopwood, D., Mikkelsen, J., [RFC3546] Blake-Wilson, S., Nystrom, M., Hopwood, D., Mikkelsen, J.,
and T. Wright, "Transport Layer Security (TLS) and T. Wright, "Transport Layer Security (TLS)
Extensions", RFC 3546, June 2003. Extensions", RFC 3546, June 2003.
[RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an [RFC6962] Laurie, B., Langley, A., and E. Kasper, "Certificate
IANA Considerations Section in RFCs", BCP 26, RFC 5226, Transparency", RFC 6962, June 2013.
May 2008.
[why-pin-key] [why-pin-key]
Langley, A., "Public Key Pinning", May 2011, Langley, A., "Public Key Pinning", May 2011,
<http://www.imperialviolet.org/2011/05/04/pinning.html>. <http://www.imperialviolet.org/2011/05/04/pinning.html>.
Appendix A. Fingerprint Generation Appendix A. Fingerprint Generation
This POSIX shell program generates SPKI Fingerprints, suitable for This POSIX shell program generates SPKI Fingerprints, suitable for
use in pinning, from PEM-encoded certificates. It is non-normative. use in pinning, from PEM-encoded certificates. It is non-normative.
openssl x509 -noout -in certificate.pem -pubkey | \ openssl x509 -noout -in certificate.pem -pubkey | \
openssl asn1parse -noout -inform pem -out public.key openssl asn1parse -noout -inform pem -out public.key
openssl dgst -sha256 -binary public.key | base64 openssl dgst -sha256 -binary public.key | openssl enc -base64
Figure 10: Example SPKI Fingerprint Generation Code Figure 11: 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. The semantics of an store the backup key pair safely offline. The semantics of an
SPKI Fingerprint do not require the issuance of a certificate to SPKI Fingerprint do not require the issuance of a certificate to
 End of changes. 59 change blocks. 
147 lines changed or deleted 220 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/