One document matched: draft-ietf-websec-key-pinning-03.xml


<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC822 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.0822.xml">
<!ENTITY RFC2616 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616.xml">
<!ENTITY RFC3864 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3864.xml">
]>
<rfc category="std" ipr="trust200902" docName="draft-ietf-websec-key-pinning-03">
<front>
<title>Public Key Pinning Extension for HTTP</title>

<author initials="C." surname="Evans" fullname="Chris Evans">
<organization>Google, Inc.</organization>
<address>
<postal>
<street>1600 Amphitheatre Pkwy</street>
<city>Mountain View</city>
<region>CA</region>
<code>94043</code>
<country>US</country>
</postal>
<email>cevans@google.com</email>
</address>
</author>

<author initials="C." surname="Palmer" fullname="Chris Palmer">
<organization>Google, Inc.</organization>
<address>
<postal>
<street>1600 Amphitheatre Pkwy</street>
<city>Mountain View</city>
<region>CA</region>
<code>94043</code>
<country>US</country>
</postal>
<email>palmer@google.com</email>
</address>
</author>

<date month="October" year="2012" />

<area>General</area>
<workgroup>Web Security</workgroup>

<keyword>I-D</keyword>
<keyword>Internet-Draft</keyword>
<keyword>Certificate</keyword>
<keyword>Public key</keyword>
<keyword>X.509</keyword>
<keyword>Certification authority</keyword>
<keyword>Public key pinning</keyword>
<keyword>HTTPS</keyword>
<keyword>TLS</keyword>
<keyword>SSL</keyword>

<abstract>

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

</abstract>

</front>

<middle>

<section anchor="introduction" title="Introduction">

<t>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 MUST
expect to be present in the host's certificate chain in future connections
using TLS (see <xref target="rfc-5246"/>). We call this "public key
pinning". At least one user agent (Google Chrome) has experimented with
shipping with a user-extensible embedded set of pins. Although effective,
this does not scale. This proposal addresses the scale problem.</t>

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

<t>We intend for hosts to use public key pinning together with HSTS (as
defined in <xref target="hsts-draft"/>, but is possible to pin keys without
requiring HSTS.</t>

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

<section anchor="requirements-language" title="Requirements Language">

<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref target="rfc-2119">RFC
2119</xref>.</t>

</section><!-- requirements-language -->

</section><!-- introduction -->

<section anchor="server-client-behavior" title="Server and Client
Behavior">

<section anchor="header-syntax" title="Response Header Field Syntax">

<t>To set a pin, hosts use a new HTTP header field, Public-Key-Pins, in
their HTTP responses. <xref target="header-abnf"/> describes the syntax of
the header field.</t>

<figure anchor="header-abnf">
<artwork>
Public-Key-Pins = "Public-Key-Pins" ":" LWS directives

directives      = max-age LWS ";" LWS pins
                  / pins LWS ";" LWS max-age

max-age         = "max-age" LWS "=" LWS delta-seconds

pins            = pin
                  / pin LWS ";" LWS pins

pin             = "pin-" token LWS "=" LWS quoted-string
</artwork>
</figure>

<t>In the pin rule, the token is the name of a cryptographic hash algorithm,
and MUST be either "sha1" or "sha256". (Future versions of this
specification may change the hash functions.) The quoted-string is a
sequence of base64 digits: a base64-encoded hash. See <xref
target="pin-semantics"/>.</t>

<t><xref target="pins-examples"/> shows some example response header fields
using the pins extension (folded for clarity).</t>

<figure anchor="pins-examples">
<artwork>
Public-Key-Pins: max-age=500;
    pin-sha1="4n972HfV354KP560yw4uqe/baXc=";
    pin-sha1="IvGeLsbqzPxdI0b0wuj2xVTdXgc="

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

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

</section><!-- header-syntax -->

<section anchor="pin-semantics" title="Semantics of Pins">

<t>The fingerprint is the SHA-1 or SHA-256 hash of the DER-encoded ASN.1
representation of the SubjectPublicKeyInfo (SPKI) field of the X.509
certificate. <xref target="spki-definition"/> reproduces the definition of
the SubjectPublicKeyInfo structure in <xref target="rfc-5280"/>.</t>

<figure anchor="spki-definition">
<artwork>
SubjectPublicKeyInfo  ::=  SEQUENCE  {
    algorithm            AlgorithmIdentifier,
    subjectPublicKey     BIT STRING  }

AlgorithmIdentifier  ::=  SEQUENCE  {
    algorithm            OBJECT IDENTIFIER,
    parameters           ANY DEFINED BY algorithm OPTIONAL  }
</artwork>
</figure>

<t>The SPKI hash is then encoded in base-64 for use in an HTTP header. (See
<xref target="rfc-4648"/>.)</t>

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

<t>We pin public keys, rather than entire certificates, to enable operators
to generate new certificates containing old public keys (see <xref
target="why-pin-key" />).</t>

<t>See <xref target="fingerprint-generation" /> for an example non-normative
program that generates public key fingerprints from SubjectPublicKeyInfo
fields in certificates.</t>

</section><!-- pin-semantics -->

<section anchor="noting-pins" title="Noting Pins">

<t>Upon receipt of the Public-Key-Pins response header field, the UA notes
the host as a Pinned Host, storing the pins and their associated max-age in
non-volatile storage (for example, along with the HSTS metadata). The pins
and their associated max-age are collectively known as Pinning Metadata.</t>

<t>The UA MUST observe these conditions when noting a host:</t>

<t><list style="symbols">
<t>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. The UAs MUST ignore
Public-Key-Pins response header fields received on HTTP (non-HTTPS)
connections.</t>

<t>The UA MUST note the pins if and only if the TLS connection was
authenticated with a certificate chain containing at least one of the SPKI
structures indicated by at least one of the given fingerprints. (See <xref
target="validating-pinned-connections"/>.)</t>

<t>The UA MUST note the pins if and only if the given set of pins contains
at least one pin that does NOT refer to an SPKI in the certificate chain.
(That is, the host must set a Backup Pin; see <xref
target="backup-pins"/>.)</t>
</list></t>

<t>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, and MUST
discard any previously set Pinning Metadata for that host in its
non-volatile store. Public-Key-Pins response header fields that meet all
these critera are known as Valid Pinning Headers.</t>

<t>Whenever a UA receives a Valid Pinning Header, it MUST set its Pinning
Metadata to the exact pins and max-age given in the most recently received
Valid Pinning Header.</t>

<section anchor="max-age" title="max-age">

<t>max-age specifies the number of seconds, after the reception of the
Public-Key-Pins HTTP Response Header, during which the UA regards the host
as a Pinned Host (up to a maximum of 30 days; see <xref
target="pin-validity-times" />). The delta-seconds production is specified
in <xref target="rfc-2616"/>.</t>

<t>Note that by setting a low or 0 value for max-age, hosts effectively
instruct UAs to cease regarding them as Pinned Hosts.</t>

</section><!-- max-age -->

</section><!-- noting-pins -->

<section anchor="validating-pinned-connections" title="Validating Pinned
Connections">

<t>When a UA connects to a Pinned Host, if the TLS connection has errors,
the UA MUST terminate the connection without allowing the user to proceed
anyway. (This behavior is the same as that required by <xref
target="hsts-draft"/>.)</t>

<t>If the connection has no errors, the UA will then apply a new, additional
correctness check: Pin Validation. To perform Pin Validation, the UA will
compute the fingerprints of the SPKI structures in each certificate in the
host's validated certificate chain. (For the purposes of Pin Validation, the
UA MUST ignore certificates who 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 fingerprints
intersects the set of fingerprints in that host's Pinning Metadata. If there
is set intersection, the UA continues with the connection as normal.
Otherwise, the UA MUST treat this Pin Failure as a non-recoverable
error.</t>

<t>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
<xref target="tack-draft" />).</t>

</section><!-- validating-pinned-connections -->

<section anchor="pin-validity-times" title="Pin Validity Times">

<t>In harmony with section 5.3.4 "Create and activate pins" of <xref
target="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:</t>

<figure anchor="pin-validity-time-formula">
<artwork>
active_period_end = MIN(current + current - initial,
                        time_pin_noted + max-age,
                        current + 30 days)
</artwork>
</figure>

</section><!-- pin-validity-times -->

<section anchor="interactions-built-in" title="Interactions With
Preloaded Pin Lists">

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

<t>UAs MUST use the newest information — built-in or set via Valid Pinning
Header — when performing Pin Validation for the host.</t>

</section><!-- interactions-built-in -->

<section anchor="pinning-self-signed" title="Pinning Self-Signed End
Entities">

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

</section><!-- pinning-self-signed -->

</section><!-- server-client-behavior -->

<section anchor="security-considerations" title="Security Considerations">

<t>Pinning public keys helps hosts assert their cryptographic identity, but
there is some risk that a host operator could lose or lose control of their
host's private key. In this case, 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.)</t>

<section anchor="backup-pins" title="Backup Pins">

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

<t>Because having a backup key pair is so important to recovery, UAs MUST
require that hosts set a Backup Pin. (See <xref target="noting-pins"/>.)</t>

</section><!-- backup-pins -->

</section><!-- security-considerations -->

<section anchor="iana-considerations" title="IANA Considerations">

<t>This document has no actions for IANA.</t>

</section><!-- iana-considerations -->

<section anchor="usability" title="Usability Considerations">

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

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

</section><!-- usability -->

<section anchor="acknowledgements" title="Acknowledgements">

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

</section><!-- acknowledgements -->

<section anchor="what-changed" title="What's Changed">

<t>Removed the section on pin break codes and verifiers, in favor the of
most-recently-received policy (<xref target="noting-pins"/>).</t>

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

<t>Explicitly requiring that UAs perform Pin Validation before the HTTP
conversation begins.</t>

<t>Backup Pins are now required.</t>

<t>Separated normative from non-normative material. Removed tangential and
out-of-scope non-normative discussion.</t>

</section><!-- what-changed -->

</middle>

<back>

<references title="Normative References">

<reference anchor="hsts-draft"
target="http://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-03">
<front>
<title>HTTP Strict Transport Security (HSTS)</title>
<author initials="J." surname="Hodges" fullname="Jeff Hodges">
<organization>PayPal, Inc.</organization>
</author>
<author initials="C." surname="Jackson" fullname="Collin Jackson">
<organization>Carnegie Mellon University</organization>
</author>
<author initials="A." surname="Barth" fullname="Adam Barth">
<organization>Google, Inc.</organization>
</author>
<date month="October" year="2011" />
</front>
</reference>

<reference anchor="rfc-2119" target="http://www.ietf.org/rfc/rfc2119.txt">
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials="S." surname="Bradner" fullname="Scott Bradner" />
<date month="March" year="1997" />
</front>
</reference>

<reference anchor="rfc-2616" target="http://www.ietf.org/rfc/rfc2616.txt">
<front>
<title>Hypertext Transfer Protocol -- HTTP/1.1</title>
<author initials="R." surname="Fielding" />
<author initials="J." surname="Gettys" />
<author initials="J." surname="Mogul" />
<author initials="H." surname="Frystyk" />
<author initials="L." surname="Masinter" />
<author initials="P." surname="Leach" />
<author initials="T." surname="Berners-Lee" />
<date month="June" year="1999" />
</front>
</reference>

<reference anchor="rfc-4648" target="http://www.ietf.org/rfc/rfc4648.txt">
<front>
<title>The Base16, Base32, and Base64 Data Encodings</title>
<author initials="S." surname="Josefsson" fullname="Simon Josefsson" />
<date month="October" year="2006" />
</front>
</reference>

<reference anchor="rfc-5246" target="http://www.ietf.org/rfc/rfc5246.txt">
<front>
<title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
<author initials="E." surname="Rescorla" fullname="Eric Rescorla" />
<author initials="T." surname="Dierks" fullname="Tim Dierks" />
<date month="August" year="2008" />
</front>
</reference>

<reference anchor="rfc-5280" target="http://www.ietf.org/rfc/rfc5280.txt">
<front>
<title>Internet X.509 Public Key Infrastructure Certificate and Certificate
Revocation List (CRL) Profile</title>
<author initials="D." surname="Cooper" />
<author initials="S." surname="Santesson" />
<author initials="S." surname="Farrell" />
<author initials="S." surname="Boeyen" />
<author initials="R." surname="Housley" />
<author initials="W." surname="Polk" />
<date month="May" year="2008" />
</front>
</reference>

</references>

<references title="Informative References">

<reference anchor="why-pin-key"
target="http://www.imperialviolet.org/2011/05/04/pinning.html">
<front>
<title>Public Key Pinning</title>
<author initials="A." surname="Langley" fullname="Adam Langley" />
<date month="May" year="2011" />
</front>
</reference>

<reference anchor="pin-break-codes" target="http://trevp.net/SAKP/">
<front>
<title>Self-Asserted Key Pinning</title>
<author initials="T." surname="Perrin" fullname="Trevor Perrin" />
<date month="September" year="2011" />
</front>
</reference>

<reference anchor="tack-draft"
target="http://tools.ietf.org/html/draft-perrin-tls-tack">
<front>
<title>Trust Assertions for Certificate Keys</title>
<author initials="T." surname="Perrin" fullname="Trevor Perrin" />
<author initials="M." surname="Marlinspike" fullname="Moxie Marlinspike" />
<date month="May" year="2012" />
</front>
</reference>

</references>

<section anchor="fingerprint-generation" title="Fingerprint Generation">

<t>This Go program generates public key fingerprints, suitable for use
in pinning, from PEM-encoded certificates. It is non-normative.</t>

<figure anchor="fingerprint-generation-figure">
<artwork>
package main

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

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

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

</section><!-- fingerprint-generation -->

<section anchor="deployment-guidance" title="Deployment Guidance">

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

<t><list style="symbols">

<t>Operators SHOULD get the backup public key signed by a different (root
and/or intermediary) CA than their primary certificate, and store the backup
key pair safely offline.</t>

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

<t>Operators SHOULD periodically exercise their Backup Pin plan — an
untested backup is no backup at all.</t>

<t>Operators SHOULD start small. Operators SHOULD first deploy public key
pinning by setting a max-age of minutes or a few hours, and gradually
increase max-age as they gain confidence in their operational
capability.</t>

</list></t>

</section><!-- deployment-guidance -->

</back>
</rfc>


PAFTECH AB 2003-20262026-04-23 20:35:57