rfc-7469

Public Key Pinning Extension for HTTP

C. Evans, C. Palmer, R. Sleevi
date2015-04 streamIETF areaapp wgwebsec statusPROPOSED STANDARD pages28 canonicalhttps://www.rfc-editor.org/rfc/rfc7469 doi10.17487/RFC7469 errataview
This document defines a new HTTP header that allows web host operators to instruct user agents to remember ("pin") the hosts' cryptographic identities over a period of time. During that time, user agents (UAs) will require that the host presents a certificate chain including at least one Subject Public Key Info structure whose fingerprint matches one of the pinned fingerprints for that host. By effectively reducing the number of trusted 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.

Extracted elements (30)

design-rationale §4.1

A max-age value around 60 days (5,184,000 seconds) is suggested as a balance between providing a narrow window of protection for infrequent visitors (low max-age) and risking UA inability to validate if pinned keys diverge (high max-age). No single ideal value exists for all use cases.

security, http

design-rationale §2.4

Pins are computed over the SubjectPublicKeyInfo (SPKI) structure rather than over entire certificates, so that operators can generate new certificates reusing existing public keys without breaking pinned clients. This enables certificate renewal without re-pinning.

pkix, crypto, security

design-rationale §1

Public Key Pinning is a trust-on-first-use (TOFU) mechanism: the UA cannot detect a MITM on the very first connection because it has no prior pinning state. A MITM on the first connection can also inject a hostile PKP header. The spec acknowledges nothing short of pre-shared keys can defend against a first-connection MITM.

security, tls, crypto

interoperability-note §2.3

Internationalized domain names used in UA processing MUST be canonicalized according to the scheme in Section 10 of RFC 6797 (HSTS). HPKP is designed to be used together with HSTS but can also be deployed independently.

http, security, tls

interoperability-note §2.1.4

When the host in a report-uri is itself a Known Pinned Host, UAs MUST perform Pin Validation for that report-uri connection; similarly, HSTS MUST be applied if the report-uri host is a Known HSTS Host. This prevents report delivery from bypassing security policies.

http, security, tls

normative-requirement §2.5 MUST

A UA MUST note Pins for a host only if all three conditions hold: the PKP header was received over an error-free TLS connection; the TLS connection was authenticated with a certificate chain containing at least one SPKI matching a given fingerprint; and the pin set contains at least one Backup Pin not referencing an SPKI in the current chain.

tls, security, pkix, http

normative-requirement §2.3.1 MUST

If a UA receives more than one PKP header field or more than one PKP-RO header field in an HTTP response, it MUST process only the first of each kind. PKP and PKP-RO headers received over insecure transport or that are not Valid Pinning Headers MUST be ignored.

http, security

normative-requirement §2.1.4 MUST

If connecting to the report-uri itself incurs a Pin Validation failure or other certificate validation failure, the UA MUST cancel the connection. The UA SHOULD detect and break reporting loops between mutually-pinned hosts that both fail Pin Validation.

http, security, tls

normative-requirement §2.3.3 MUST NOT

Known Pinned Hosts are identified only by domain names, never IP addresses. If the host in the Request-URI matches an IP-literal or IPv4address production, the UA MUST NOT note this host as a Known Pinned Host.

http, security, ip

normative-requirement §2.2.2 MUST

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

http, security, tls

normative-requirement §2.1.2 REQUIRED

The max-age directive is REQUIRED in a Public-Key-Pins header and specifies the number of seconds the UA SHOULD treat the host as a Known Pinned Host. The max-age directive is meaningless in a PKP-RO header and UAs MUST ignore it there and not cache the header.

http, security

normative-requirement §2.3.3 MUST NOT

The UA MUST NOT modify any pinning metadata of any superdomain-matched Known Pinned Host, and MUST NOT cache information derived from a PKP-RO header (PKP-RO headers are ephemeral).

http, security

normative-requirement §2.3.3 MAY

UAs MAY set an upper limit on the max-age value to allow recovery from erroneous or maliciously set pins. If the server's max-age exceeds the UA's cap, the UA MAY behave as if the server set max-age to the UA's upper limit.

http, security

normative-requirement §2.1 MUST

UAs MUST ignore any PKP header fields that do not conform to the specified grammar, and MUST NOT attempt to fix malformed header fields. If a directive is unrecognized, it MUST be ignored; recognized directives MUST be processed if the header otherwise conforms.

http, security

normative-requirement §2.3.4 MUST NOT

UAs MUST NOT heed http-equiv='Public-Key-Pins' or http-equiv='Public-Key-Pins-Report-Only' attributes on HTML <meta> elements; pinning can only be established via HTTP response headers over secure transport.

http, security

normative-requirement §2.6 MUST

When a UA connects to a Known Pinned Host via TLS and the connection has errors, the UA MUST terminate the connection without allowing the user to proceed. If connection is error-free, the UA SHOULD perform Pin Validation by checking that the set of SPKI fingerprints in the certificate chain intersects the noted Pinning Metadata; if not, the UA MUST treat this as a non-recoverable error.

tls, security, pkix

normative-requirement §3 MUST

When formulating the JSON POST body for a failure report, the UA MUST either use single-quoted JSON strings or use double-quoted JSON strings and backslash-escape the embedded double quotes in the known-pin quoted-string part.

http, json, security

normative-requirement §2.3.1 MUST

When max-age is 0, the UA MUST remove its cached Pinning Policy for a Known Pinned Host, or MUST NOT note the host if not yet known. This provides a way for operators to de-pin a host.

http, security

normative-requirement §2.3.2 MUST NOT

When the PKP-RO header is used, the UA MUST NOT enforce Pin Validation — it performs the check only to determine whether to POST a report. The UA MUST process the PKP header and SHOULD process both headers when both are present.

http, security

privacy-consideration §5

HPKP can be abused as a 'super-cookie' to track users: a host can encode distinct arbitrary identifiers in pin values and use report-uri callbacks or subdomain connection failures to fingerprint individual UAs across sessions, even after cookies are cleared. UAs should allow users to clear pinning state and query current pinned hosts.

privacy, security, http

privacy-consideration §5

Pin Validation failure reports contain certificate chain information; in cases of organization-wide TLS interception, these reports may disclose the interception infrastructure to the report-uri operator. Additionally, the pinning state store reveals which domains a UA has visited, even after other browser state is cleared.

privacy, security, tls

protocol-element §2.4

An SPKI Fingerprint is the output of SHA-256 applied to the DER-encoded ASN.1 SubjectPublicKeyInfo structure of an X.509 certificate, base64-encoded for use in the HTTP header. A Pin is the combination of the algorithm identifier and the computed SPKI Fingerprint.

crypto, pkix, http

protocol-element §2.1.3

The OPTIONAL includeSubDomains directive, when asserted, extends the Pinning Policy to all subdomains of the host's domain name. The OPTIONAL report-uri directive specifies a URI to which the UA SHOULD POST Pin Validation failure reports as a JSON object.

http, security

protocol-element §2.1

The Public-Key-Pins (PKP) and Public-Key-Pins-Report-Only (PKP-RO) response header fields instruct user agents to perform Pin Validation for the host emitting the response. Both headers share the same ABNF grammar: a semicolon-separated list of directives, each a token optionally followed by '=' and a token or quoted-string value.

http, security, pkix, tls, crypto

registry §6

This document registers two permanent HTTP response header field names — 'Public-Key-Pins' and 'Public-Key-Pins-Report-Only' — in the IANA 'Message Headers' registry with protocol 'http' and status 'standard'.

http, registry, security

security-consideration §4.5

Hostile pinning: an attacker who obtains a valid certificate for a domain (through CA misissuance or prior domain ownership) can serve a Valid Pinning Header that pins the UA to the attacker's keys, blocking access to the legitimate site for the duration of max-age. Mitigation includes capping max-age and preloading legitimate pins.

security, pkix, tls

security-consideration §4.3

Operators MUST include at least one Backup Pin — a fingerprint for a secondary not-yet-deployed key pair kept offline. Without a backup pin, loss of the primary private key would make the host inaccessible to UAs for the entire pin lifetime. UAs enforce this requirement by rejecting PKP headers without a backup pin.

security, pkix, crypto

security-consideration §4.2

Using the includeSubDomains directive can cause Pin Validation failures for subdomains that legitimately use different certificate chains, depending on the order in which a UA encounters Valid Pinning Headers. Operators must use overlapping pin sets or coordinate pin sets across parent and subdomain hosts.

security, http

wire-format §3

Pin Validation failure reports are JSON objects POSTed to the report-uri, containing: date-time (RFC 3339), hostname, port (integer), effective-expiration-date (RFC 3339), include-subdomains (boolean), noted-hostname, served-certificate-chain (PEM array), validated-certificate-chain (PEM array), and known-pins (array of 'pin-<alg>="<base64>"' strings).

http, security, json

wire-format §2.1.1

The pin-directive encodes a cryptographic identity as 'pin-<algorithm>=<base64-encoded-SPKI-fingerprint>'. The only currently allowed algorithm token is 'sha256'; the value is the base64-encoded SHA-256 hash of the DER-encoded SubjectPublicKeyInfo structure of an X.509 certificate.

http, crypto, pkix