RFC 6797

HTTP Strict Transport Security (HSTS)

๐Ÿ“… published November 2012, from ietf

RFC 6797: HTTP Strict Transport Security (HSTS) ๐ŸŽ€

okay bestie, this RFC is about giving websites a way to say "I only do HTTPS, no exceptions" ๐Ÿ”’โœจ here's the title block, the vibe check, and the whole front matter ๐Ÿ’…

  • Number and title: RFC 6797, HTTP Strict Transport Security (HSTS) ๐Ÿฆ‹
  • Published by: the Internet Engineering Task Force (IETF) ๐ŸŒˆ
  • Category: Standards Track, so this is an official Internet Standard ๐Ÿ‘‘
  • Authors: J. Hodges (PayPal), C. Jackson (Carnegie Mellon University), and A. Barth (Google, Inc.) ๐Ÿซถ
  • Date: November 2012 ๐Ÿ“
  • ISSN: 2070-1721 โœจ
  • Obsoletes and updates: the title block doesn't list anything this document obsoletes or updates ๐Ÿงš

Abstract ๐Ÿ’œ

this spec gives websites a way to declare that they're only reachable over secure connections ๐Ÿ” it also lets users tell their user agent(s) to only talk to certain sites over secure connections ๐Ÿ™ˆ this whole policy is called HTTP Strict Transport Security (HSTS) โœจ sites declare it with the Strict-Transport-Security HTTP response header field, and/or by other means, like user agent configuration, for example ๐ŸŽ€

Status of This Memo ๐ŸŒธ

this is an Internet Standards Track document ๐Ÿ‘‘

it's a product of the Internet Engineering Task Force (IETF) and it represents the consensus of the IETF community ๐Ÿซถ it got public review and was approved for publication by the Internet Engineering Steering Group (IESG) ๐Ÿ’… more info on Internet Standards is in Section 2 of RFC 5741 ๐Ÿ“š

info about the current status of this document, any errata, and how to send feedback on it lives at http://www.rfc-editor.org/info/rfc6797 ๐Ÿ”—

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

this document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as they were in effect on the date this document was published ๐Ÿ“œ please read them carefully, because they explain your rights and restrictions for this document ๐Ÿ™ code components pulled out of this document must include Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions ๐Ÿ’œ and they come without warranty, as described in the Simplified BSD License ๐Ÿฆ‹

Table of Contents ๐Ÿงš

   1. Introduction ....................................................4
      1.1. Organization of This Specification .........................6
      1.2. Document Conventions .......................................6
   2. Overview ........................................................6
      2.1. Use Cases ..................................................6
      2.2. HTTP Strict Transport Security Policy Effects ..............6
      2.3. Threat Model ...............................................6
           2.3.1. Threats Addressed ...................................7
                  2.3.1.1. Passive Network Attackers ..................7
                  2.3.1.2. Active Network Attackers ...................7
                  2.3.1.3. Web Site Development and Deployment Bugs ...8
           2.3.2. Threats Not Addressed ...............................8
                  2.3.2.1. Phishing ...................................8
                  2.3.2.2. Malware and Browser Vulnerabilities ........8
      2.4. Requirements ...............................................9
           2.4.1. Overall Requirement .................................9
                  2.4.1.1. Detailed Core Requirements .................9
                  2.4.1.2. Detailed Ancillary Requirements ...........10
   3. Conformance Criteria ...........................................10
   4. Terminology ....................................................11
   5. HSTS Mechanism Overview ........................................13
      5.1. HSTS Host Declaration .....................................13
      5.2. HSTS Policy ...............................................13
      5.3. HSTS Policy Storage and Maintenance by User Agents ........14
      5.4. User Agent HSTS Policy Enforcement ........................14
   6. Syntax .........................................................14
      6.1. Strict-Transport-Security HTTP Response Header Field ......15
           6.1.1. The max-age Directive ..............................16
           6.1.2. The includeSubDomains Directive ....................16
      6.2. Examples ..................................................16

   7. Server Processing Model ........................................17
      7.1. HTTP-over-Secure-Transport Request Type ...................17
      7.2. HTTP Request Type .........................................18
   8. User Agent Processing Model ....................................18
      8.1. Strict-Transport-Security Response Header Field
           Processing ................................................19
           8.1.1. Noting an HSTS Host - Storage Model ................20
      8.2. Known HSTS Host Domain Name Matching ......................20
      8.3. URI Loading and Port Mapping ..............................21
      8.4. Errors in Secure Transport Establishment ..................22
      8.5. HTTP-Equiv <Meta> Element Attribute .......................22
      8.6. Missing Strict-Transport-Security Response Header Field ...23
   9. Constructing an Effective Request URI ..........................23
      9.1. ERU Fundamental Definitions ...............................23
      9.2. Determining the Effective Request URI .....................24
           9.2.1. Effective Request URI Examples .....................24
   10. Domain Name IDNA-Canonicalization .............................25
   11. Server Implementation and Deployment Advice ...................26
      11.1. Non-Conformant User Agent Considerations .................26
      11.2. HSTS Policy Expiration Time Considerations ...............26
      11.3. Using HSTS in Conjunction with Self-Signed Public-Key
            Certificates .............................................27
      11.4. Implications of includeSubDomains ........................28
            11.4.1. Considerations for Offering Unsecured HTTP
                    Services at Alternate Ports or Subdomains of an
                    HSTS Host ........................................28
            11.4.2. Considerations for Offering Web Applications at
                    Subdomains of an HSTS Host .......................29
   12. User Agent Implementation Advice ..............................30
      12.1. No User Recourse .........................................30
      12.2. User-Declared HSTS Policy ................................30
      12.3. HSTS Pre-Loaded List .....................................31
      12.4. Disallow Mixed Security Context Loads ....................31
      12.5. HSTS Policy Deletion .....................................31
   13. Internationalized Domain Names for Applications (IDNA):
       Dependency and Migration ......................................32

   14. Security Considerations .......................................32
      14.1. Underlying Secure Transport Considerations ...............32
      14.2. Non-Conformant User Agent Implications ...................33
      14.3. Ramifications of HSTS Policy Establishment Only over
            Error-Free Secure Transport ..............................33
      14.4. The Need for includeSubDomains ...........................34
      14.5. Denial of Service ........................................35
      14.6. Bootstrap MITM Vulnerability .............................36
      14.7. Network Time Attacks .....................................37
      14.8. Bogus Root CA Certificate Phish plus DNS Cache
            Poisoning Attack .........................................37
      14.9. Creative Manipulation of HSTS Policy Store ...............37
      14.10. Internationalized Domain Names ..........................38
   15. IANA Considerations ...........................................39
   16. References ....................................................39
      16.1. Normative References .....................................39
      16.2. Informative References ...................................40
   Appendix A. Design Decision Notes .................................44
   Appendix B. Differences between HSTS Policy and Same-Origin
               Policy ................................................45
   Appendix C. Acknowledgments .......................................46

okay so next up is Section 1, the Introduction ๐Ÿงš๐Ÿ’–

1. Introduction โœจ

okay so bestie, HTTP [RFC2616] can run over all kinds of transports, but usually it's on TCP ๐ŸŒธ. The problem is TCP doesn't give you channel integrity protection, confidentiality, or secure host identification ๐Ÿ˜ญ. So enter the Secure Sockets Layer (SSL) protocol [RFC6101] and its successor, Transport Layer Security (TLS) [RFC5246]. These were built to give channel-oriented security, and they usually sit between the application protocols and TCP ๐Ÿ”. [RFC2818] explains how HTTP gets layered onto TLS and defines the Uniform Resource Identifier (URI) scheme of "https" ๐Ÿ’–. Real talk though, HTTP user agents (UAs) typically use either TLS or SSL3, depending on a mix of negotiation with the server and user preferences ๐Ÿ™ˆ.

UAs have their own local security policies for how they interact with web resources ๐ŸŽ€. These policies depend (partly) on whether they're talking to a web resource's host over plain HTTP or over HTTP-over-Secure-Transport. For example, cookies ([RFC6265]) can be flagged as Secure ๐Ÿช. UAs are to send these Secure cookies to their addressed host only over a secure transport. Non-Secure cookies are different, since they get returned to the host regardless of transport (although other rules still apply) ๐Ÿฆ‹.

UAs typically tell their users about any issues with setting up a secure connection ๐Ÿ“ข. Examples include being unable to validate a TLS server certificate trust chain, a TLS server certificate being expired, or a TLS host's domain name showing up incorrectly in the TLS server certificate (see Section 3.1 of [RFC2818]) ๐Ÿ’€. A lot of the time, UAs let users choose to keep going with a web resource's host even with these issues. This behavior is sometimes called "click(ing) through" security [GoodDhamijaEtAl05] [SunshineEgelmanEtAl09], so it can be described as "click-through insecurity" ๐Ÿ™ƒ.

A key vulnerability that click-through insecurity opens up is leaking any cookies the web resource uses to manage a user's session ๐Ÿ˜ฑ. The threat is that an attacker could grab those cookies and then interact with the legit web resource while impersonating the user ๐Ÿ‘€.

Jackson and Barth proposed an approach in [ForceHTTPS] that lets web resources declare that any UA interactions with them must be conducted securely. It also says any issues establishing a secure transport session are to be treated as fatal, with no direct user recourse ๐Ÿšซ. The goal is to stop click-through insecurity and address other potential threats ๐Ÿ‘‘.

This specification embodies and refines the approach from [ForceHTTPS] โœจ. For example, instead of using a cookie to convey policy from a web resource's host to a UA, it defines an HTTP response header field for this purpose ๐Ÿงš. Also, a web resource's host can declare that its policy applies to the entire domain name subtree rooted at its host name ๐ŸŒณ. This is how HTTP Strict Transport Security (HSTS) protects so-called "domain cookies", which get applied to all subdomains of a given web resource's host name ๐Ÿ“.

This spec also picks up some ideas from [JacksonBarth2008]. Policy is applied on an "entire-host" basis, which means it applies to HTTP (only) over any TCP port of the issuing host ๐Ÿ’œ.

Heads up, the policy defined here is totally different from the "same-origin policy" in "The Web Origin Concept" [RFC6454] ๐Ÿ™…โ€โ™€๏ธ. Appendix B summarizes these differences ๐Ÿ“.

1.1. Organization of This Specification

okay so the spec starts with an overview of the use cases, policy effects, threat models, and requirements for HSTS (that's Section 2) ๐Ÿ—บ๏ธ. Then Section 3 lays out conformance requirements ๐Ÿ“‹. Section 4 defines the terminology used in this document ๐Ÿ“–. The HSTS mechanism itself gets formally specified in Sections 5 through 15 ๐Ÿ”ฅ.

1.2. Document Conventions

NOTE: This is a note to the reader. These are points that should be expressly kept in mind and/or considered. ๐Ÿซถ

2. Overview ๐ŸŒˆ

this section covers the use cases, sums up the HSTS Policy, and then talks about the threat model, the threats that aren't addressed, and the requirements we derive from all that ๐Ÿ’….

2.1. Use Cases

the high-level use case is a combo of two things ๐Ÿ’ซ:

  • A web browser user wants to interact with various websites (some arbitrary, some known) in a secure way ๐Ÿฆ‹.
  • A website deployer wants to offer their site in an explicitly secure way, for their own benefit as well as their users' benefit ๐ŸŽ€.

2.2. HTTP Strict Transport Security Policy Effects

the effects of the HSTS Policy are summarized below. This is what happens when a conformant UA applies the policy to a web resource host that has it (known as an HSTS Host) ๐Ÿง:

  1. UAs transform insecure URI references to an HSTS Host into secure URI references before dereferencing them โœจ.
  2. The UA terminates any secure transport connection attempts upon any and all secure transport errors or warnings ๐Ÿ›‘.

2.3. Threat Model

HSTS is concerned with three threat classes: passive network attackers, active network attackers, and imperfect web developers ๐Ÿ•ต๏ธโ€โ™€๏ธ. But it's explicitly not a remedy for two other classes: phishing and malware ๐Ÿšซ. The threats that are addressed, and the ones that aren't, are briefly discussed below ๐Ÿ‘‡.

Readers may wish to refer to Section 2 of [ForceHTTPS] for details and relevant citations ๐Ÿ“š.

2.3.1. Threats Addressed

2.3.1.1. Passive Network Attackers

so picture this ๐ŸŽง: a user is browsing the web on a local wireless network (like an 802.11-based wireless local area network). A nearby attacker can possibly eavesdrop on the user's unencrypted Internet Protocol-based connections, like HTTP. This works regardless of whether the local wireless network itself is secured [BeckTews09] ๐Ÿ˜ณ. Freely available wireless sniffing toolkits (e.g., [Aircrack-ng]) make these passive eavesdropping attacks possible, even if the local wireless network is operating in a secure fashion ๐Ÿ› ๏ธ. A passive network attacker using such tools can steal session identifiers/cookies and hijack the user's web session(s) by obtaining cookies containing authentication credentials [ForceHTTPS] ๐Ÿ’€. For example, there are widely available tools, such as Firesheep (a web browser extension) [Firesheep], that let their wielder grab other local users' session cookies for various web applications ๐Ÿ˜ญ.

To mitigate these threats, some websites support access using end-to-end secure transport, but usually don't force it. For instance, this is signaled through URIs built with the "https" scheme [RFC2818] ๐Ÿ”’. This can make users think that accessing these services with secure transport protects them from passive network attackers ๐Ÿฅบ. Unfortunately, that's often not the case in real-world deployments. Session identifiers are often stored in non-Secure cookies so they stay interoperable with versions of the service offered over insecure transport. ("Secure cookies" are the cookies that have the "Secure" attribute [RFC6265].) For example, if the session identifier for a website (an email service, say) lives in a non-Secure cookie, an attacker can hijack the user's session if the user's UA makes a single insecure HTTP request to the site ๐Ÿ™…โ€โ™€๏ธ.

2.3.1.2. Active Network Attackers

a determined attacker can run an active attack, either by impersonating a user's DNS server or, on a wireless network, by spoofing network frames or offering a similarly named evil twin access point ๐Ÿ‘น. If the user is behind a wireless home router, an attacker can try to reconfigure the router using default passwords and other vulnerabilities ๐Ÿ . Some sites, like banks, rely on end-to-end secure transport to protect themselves and their users from these active attackers ๐Ÿฆ. Unfortunately, browsers let their users easily opt out of these protections so they can be used with sites that deploy secure transport incorrectly. For example, a site might generate and self-sign its own certificates without also distributing its certification authority (CA) certificate to its users' browsers ๐Ÿคฆโ€โ™€๏ธ.

2.3.1.3. Web Site Development and Deployment Bugs

the security of an otherwise uniformly secure site (meaning all of its content is materialized via "https" URIs) can be completely compromised by an active attacker exploiting one simple mistake ๐Ÿ˜ฑ. Like loading a cascading style sheet or a SWF (Shockwave Flash) movie over an insecure connection. Both cascading style sheets and SWF movies can script the embedding page, which surprises a lot of web developers. On top of that, some browsers don't issue so-called "mixed content warnings" when SWF files are embedded via insecure connections ๐Ÿ™ˆ. Even if the site's developers carefully check their login page for "mixed content", a single insecure embedding anywhere on the overall site compromises the security of that login page. An attacker can script (i.e., control) the login page by injecting code (e.g., a script) into another, insecurely loaded, site page ๐ŸŽฃ.

NOTE: "Mixed content" as used above (see also Section 5.3 in [W3C.REC-wsc-ui-20100812]) refers to the notion termed "mixed security context" in this specification and should not be confused with the same "mixed content" term used in the context of markup languages such as XML and HTML. ๐Ÿง 

2.3.2. Threats Not Addressed

2.3.2.1. Phishing

phishing attacks happen when an attacker asks the user for authentication credentials by hosting a fake site on a different domain than the real one. They might drive traffic to the fake site by sending a link in an email message ๐Ÿ“ง. Phishing can be super effective because users find it hard to tell the real site from a fake one ๐Ÿ˜ฉ. HSTS is not a defense against phishing per se. Instead, it complements many existing phishing defenses by telling the browser to protect session integrity and long-lived authentication tokens [ForceHTTPS] ๐Ÿ›ก๏ธ.

2.3.2.2. Malware and Browser Vulnerabilities

because HSTS is implemented as a browser security mechanism, it relies on the trustworthiness of the user's system to protect the session ๐Ÿ’ป. Malicious code running on the user's system can compromise a browser session, whether or not HSTS is used ๐Ÿ‘พ.

2.4. Requirements

this section identifies and lists the requirements derived from the use cases and threats above ๐Ÿ“. It also lays out the detailed core requirements that HTTP Strict Transport Security addresses, plus the ancillary requirements that aren't directly addressed ๐ŸŽฏ.

2.4.1. Overall Requirement

  • Minimize, for web browser users and web site deployers, the risks that come from passive and active network attackers, web site development and deployment bugs, and insecure user actions ๐Ÿ’–๐ŸŒŸ.

2.4.1.1. Detailed Core Requirements โœจ

okay so these core requirements come straight out of the overall one, and this spec is literally where they get handled ๐Ÿ’…

  1. Websites need to be able to tell UAs (aka browsers and friends) that they should be accessed using a strict security policy ๐Ÿ”’
  2. Websites need to be able to instruct UAs that contact them insecurely to do so securely ๐Ÿ”
  3. UAs need to keep persistent data about websites that signal strict security policy enablement, for the time spans the websites declare ๐Ÿ—“๏ธ Also, UAs need to cache the "freshest" strict security policy info so websites can update it whenever they want ๐ŸŒธ
  4. UAs need to rewrite all insecure UA "http" URI loads to use the "https" secure scheme for those websites where secure policy is enabled ๐ŸŽ€
  5. Website admins need to be able to signal strict security policy application to subdomains of higher-level domains where strict security policy is enabled, and UAs need to enforce that policy ๐Ÿซถ

For example, both example.com and foo.example.com could set policy for bar.foo.example.com. ๐Ÿงš

  1. UAs need to disallow security policy application to peer domains and/or higher-level domains by domains where strict security policy is enabled ๐Ÿ™…โ€โ™€๏ธ

For example, neither bar.foo.example.com nor foo.example.com can set policy for example.com, nor can bar.foo.example.com set policy for foo.example.com. Also, foo.example.com cannot set policy for sibling.example.com. ๐Ÿ’€

  1. UAs need to prevent users from "clicking through" security warnings. Halting connection attempts in the face of secure transport exceptions is acceptable. See also Section 12.1 ("No User Recourse"). ๐Ÿšซ๐Ÿ‘†
NOTE: A means for uniformly securely meeting the first core requirement above is not specifically addressed by this specification (see Section 14.6 ("Bootstrap MITM Vulnerability")). It may be addressed by a future revision of this specification or some other specification. Note also that there are means by which UA implementations may more fully meet the first core requirement; see Section 12 ("User Agent Implementation Advice"). ๐Ÿ“

2.4.1.2. Detailed Ancillary Requirements

these ancillary requirements also come from the overall requirement, but they aren't normatively addressed in this spec ๐Ÿฆ‹ UA implementations could meet them at their implementor's discretion, although meeting them may be pretty complex ๐Ÿ˜ญ

  1. Disallow "mixed security context" loads (see Section 2.3.1.3). ๐Ÿ™ˆ
  2. Facilitate user declaration of websites for which strict security policy is enabled, regardless of whether the sites signal HSTS Policy. ๐Ÿ‘‘

3. Conformance Criteria

this spec is written for hosts and user agents ๐ŸŽ€

a conformant host is one that implements all the requirements listed in this specification that apply to hosts ๐Ÿ 

a conformant user agent is one that implements all the requirements listed in this specification that apply to user agents ๐ŸŒ

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 [RFC2119]. ๐Ÿ“–โœจ

4. Terminology

okay the terms get defined in this section, so bookmark it bestie ๐Ÿ”–

ASCII case-insensitive comparison: means comparing two strings exactly, codepoint for codepoint, except that the characters in the range U+0041 .. U+005A (i.e., LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range U+0061 .. U+007A (i.e., LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also match. See [Unicode] for details. ๐Ÿ”ค

codepoint: is a colloquial contraction of Code Point, which is any value in the Unicode codespace; that is, the range of integers from 0 to 10FFFF(hex) [Unicode]. ๐Ÿ”ข

domain name: is also referred to as "DNS name" and is defined in [RFC1035] to be represented outside of the DNS protocol itself (and implementations thereof) as a series of labels separated by dots, e.g., "example.com" or "yet.another.example.org". In the context of this specification, domain names appear in that portion of a URI satisfying the reg-name production in "Appendix A. Collected ABNF for URI" in [RFC3986], and the host component from the Host HTTP header field production in Section 14.23 of [RFC2616]. ๐ŸŒ

NOTE: The domain names appearing in actual URI instances and matching the aforementioned production components may or may not be a fully qualified domain name. ๐Ÿคทโ€โ™€๏ธ

domain name label: is that portion of a domain name appearing "between the dots". Consider "foo.example.com": "foo", "example", and "com" are all domain name labels. ๐Ÿงฉ

Effective Request URI: is a URI, identifying the target resource, that can be inferred by an HTTP host for any given HTTP request it receives. Such inference is necessary because HTTP requests often do not contain a complete "absolute" URI identifying the target resource. See Section 9 ("Constructing an Effective Request URI"). ๐ŸŽฏ

HTTP Strict Transport Security: is the overall name for the combined UA- and server-side security policy defined by this specification. ๐Ÿ‘‘

HTTP Strict Transport Security Host: is a conformant host implementing the HTTP server aspects of the HSTS Policy. This means that an HSTS Host returns the "Strict-Transport-Security" HTTP response header field in its HTTP response messages sent over secure transport. ๐Ÿฐ

HTTP Strict Transport Security Policy: is the name of the combined overall UA- and server-side facets of the behavior defined in this specification. ๐Ÿ’œ

HSTS: See HTTP Strict Transport Security. ๐Ÿฆ‹

HSTS Host: See HTTP Strict Transport Security Host. ๐ŸŒธ

HSTS Policy: See HTTP Strict Transport Security Policy. โœจ

Known HSTS Host: is an HSTS Host for which the UA has an HSTS Policy in effect; i.e., the UA has noted this host as a Known HSTS Host. See Section 8.1.1 ("Noting an HSTS Host - Storage Model") for particulars. ๐Ÿ“

Local policy: comprises policy rules that deployers specify and that are often manifested as configuration settings. โš™๏ธ

MITM: is an acronym for "man in the middle". See "man-in-the-middle attack" in [RFC4949]. ๐Ÿ•ต๏ธโ€โ™€๏ธ

Request URI: is the URI used to cause a UA to issue an HTTP request message. See also "Effective Request URI". ๐Ÿ“จ

UA: is an acronym for "user agent". For the purposes of this specification, a UA is an HTTP client application typically actively manipulated by a user [RFC2616]. ๐Ÿ“ฑ

unknown HSTS Host: is an HSTS Host that the user agent has not noted. ๐Ÿ‘€

5. HSTS Mechanism Overview

this section gives you the overview of how an HSTS Host conveys its HSTS Policy to UAs, and how UAs process the HSTS Policies they get from HSTS Hosts ๐Ÿง The mechanism details are specified in Sections 6 through 15.

5.1. HSTS Host Declaration

an HTTP host declares itself an HSTS Host by issuing an HSTS Policy to UAs ๐Ÿ“ฃ That policy is represented by and conveyed via the Strict-Transport-Security HTTP response header field over secure transport (e.g., TLS). Upon error-free receipt and processing of this header by a conformant UA, the UA regards the host as a Known HSTS Host. ๐Ÿ’…

5.2. HSTS Policy

an HSTS Policy directs UAs to communicate with a Known HSTS Host only over secure transport, and it specifies the policy retention time duration โณ

HSTS Policy explicitly overrides the UA processing of URI references, user input (e.g., via the "location bar"), or other information that, in the absence of HSTS Policy, might otherwise cause UAs to communicate insecurely with the Known HSTS Host. ๐Ÿ›‘

an HSTS Policy may contain an optional directive, includeSubDomains, specifying that this HSTS Policy also applies to any hosts whose domain names are subdomains of the Known HSTS Host's domain name. ๐ŸŒณ

5.3. HSTS Policy Storage and Maintenance by User Agents

UAs store and index HSTS Policies based strictly upon the domain names of the issuing HSTS Hosts ๐Ÿ—‚๏ธ

this means UAs keep the HSTS Policy of any given HSTS Host separate from any HSTS Policies issued by other HSTS Hosts whose domain names are superdomains or subdomains of the given HSTS Host's domain name ๐Ÿง  Only the given HSTS Host can update or cause deletion of its issued HSTS Policy. It does this by sending Strict-Transport-Security HTTP response header fields to UAs with new values for policy time duration and subdomain applicability. So, UAs cache the "freshest" HSTS Policy info on behalf of an HSTS Host โœจ Specifying a zero time duration signals the UA to delete the HSTS Policy (including any asserted includeSubDomains directive) for that HSTS Host. See Section 8.1 ("Strict-Transport-Security Response Header Field Processing") for details. Also, Section 6.2 presents examples of Strict-Transport-Security HTTP response header fields. ๐ŸŽ€

5.4. User Agent HSTS Policy Enforcement

when establishing an HTTP connection to a given host, however it was instigated, the UA checks its cache of Known HSTS Hosts to see if any have domain names that are superdomains of the given host's domain name ๐Ÿ” If any are found, and of those, if any have the includeSubDomains directive asserted, then HSTS Policy applies to the given host. Otherwise, HSTS Policy applies to the given host only if the given host is itself known to the UA as an HSTS Host. See Section 8.3 ("URI Loading and Port Mapping") for details. ๐Ÿซถ

6. Syntax

this section defines the syntax of the Strict-Transport-Security HTTP response header field and its directives, and it presents some examples ๐Ÿ“โœจ

Section 7 ("Server Processing Model") then details how hosts employ this header field to declare their HSTS Policy, and Section 8 ("User Agent Processing Model") details how user agents process the header field and apply the HSTS Policy. ๐Ÿงš

6.1. Strict-Transport-Security HTTP Response Header Field ๐Ÿ’–

okay bestie, the Strict-Transport-Security HTTP response header field (aka the STS header field) is basically the host telling a UA "hey, you MUST enforce the HSTS Policy for me" ๐Ÿ”’ It applies to the host that sent the response containing this header field โœจ

the ABNF (Augmented Backus-Naur Form) grammar for the STS header field is below ๐ŸŽ€ it's built on the Generic Grammar from Section 2 of [RFC2616], which includes that "implied linear whitespace" thing (aka "implied *LWS") ๐ŸŒธ

   Strict-Transport-Security = "Strict-Transport-Security" ":"
                               [ directive ]  *( ";" [ directive ] )

   directive                 = directive-name [ "=" directive-value ]
   directive-name            = token
   directive-value           = token | quoted-string

where:

   token          = <token, defined in [RFC2616], Section 2.2>
   quoted-string  = <quoted-string, defined in [RFC2616], Section 2.2>

there are two directives defined in this spec, and here are the overall rules for directives ๐Ÿ‘‘

  1. The order of appearance of directives is not significant.
  2. All directives MUST appear only once in an STS header field. Directives are either optional or required, as stipulated in their definitions.
  3. Directive names are case-insensitive.
  4. UAs MUST ignore any STS header field containing directives, or other header field value data, that does not conform to the syntax defined in this specification.
  5. If an STS header field contains directive(s) not recognized by the UA, the UA MUST ignore the unrecognized directives, and if the STS header field otherwise satisfies the above requirements (1 through 4), the UA MUST process the recognized directives.

future directives can extend the STS header field's powers through other specs ๐Ÿฆ‹ they'd go into a registry (with an IANA policy of IETF Review [RFC5226]) whenever that happens.

NOTE: Such future directives will be ignored by UAs implementing only this specification, as well as by generally non-conforming UAs. See Section 14.2 ("Non-Conformant User Agent Implications") for further discussion. ๐Ÿ™ˆ

6.1.1. The max-age Directive โณ

the REQUIRED "max-age" directive is the number of seconds, counted from when the STS header field was received, during which the UA treats the host (the one that sent the message) as a Known HSTS Host โœจ see also Section 8.1.1 ("Noting an HSTS Host - Storage Model"). the delta-seconds production comes from [RFC2616].

the max-age directive's REQUIRED value (after quoted-string unescaping, if needed) is defined like this:

    max-age-value = delta-seconds

    delta-seconds = <1*DIGIT, defined in [RFC2616], Section 3.3.2>

NOTE: A max-age value of zero (i.e., "max-age=0") signals the UA to cease regarding the host as a Known HSTS Host, including the includeSubDomains directive (if asserted for that HSTS Host). See also Section 8.1 ("Strict-Transport-Security Response Header Field Processing"). ๐Ÿ’€

6.1.2. The includeSubDomains Directive ๐ŸŒˆ

the OPTIONAL "includeSubDomains" directive has no value, just vibes ๐Ÿ˜Œ if it's there (aka "asserted"), it tells the UA that the HSTS Policy covers this HSTS Host AND every subdomain under the host's domain name ๐Ÿ’…

6.2. Examples ๐Ÿ“

this HSTS header field says the policy sticks around for one year (roughly 31536000 seconds), and it only covers the domain of the HSTS Host that sent it:

   Strict-Transport-Security: max-age=31536000

this one keeps the policy for about six months, and it covers the issuing HSTS Host's domain plus all of its subdomains ๐Ÿฆ‹

   Strict-Transport-Security: max-age=15768000 ; includeSubDomains

the max-age value can be quoted if you want, totally optional ๐ŸŽ€

   Strict-Transport-Security: max-age="31536000"

this one tells the UA to delete the entire HSTS Policy for the HSTS Host that sent it. bye bye ๐Ÿ‘‹

   Strict-Transport-Security: max-age=0

and this one does exactly the same thing as the one right above it, because includeSubDomains gets ignored when max-age is zero ๐Ÿ™ƒ

   Strict-Transport-Security: max-age=0; includeSubDomains

7. Server Processing Model ๐Ÿ–ฅ๏ธ

this section is about the processing model that HSTS Hosts implement โœจ it has two parts: the rules for HTTP request messages that come in over a secure transport (TLS [RFC5246] or SSL [RFC6101]; see also Section 14.1 ("Underlying Secure Transport Considerations")), and the rules for HTTP request messages that come in over non-secure transports, like TCP ๐ŸŒธ

7.1. HTTP-over-Secure-Transport Request Type ๐Ÿ”

when an HSTS Host replies to an HTTP request that came over a secure transport, it SHOULD include an STS header field in its response message ๐Ÿ’– that STS header field MUST satisfy the grammar from Section 6.1 ("Strict-Transport-Security HTTP Response Header Field"). if an STS header field is included, the HSTS Host MUST include only one such header field ๐Ÿซถ

establishing a given host as a Known HSTS Host (in the context of a given UA) MAY be done over HTTP, which runs over a secure transport, by correctly returning at least one valid STS header field (per this specification) to the UA โœจ other mechanisms, like a client-side pre-loaded Known HSTS Host list, MAY also be used too ๐Ÿงš for example, see Section 12 ("User Agent Implementation Advice").

NOTE: Including the STS header field is stipulated as a "SHOULD" in order to accommodate various server- and network-side caches and load-balancing configurations where it may be difficult to uniformly emit STS header fields on behalf of a given HSTS Host. ๐Ÿ™ˆ

7.2. HTTP Request Type ๐Ÿ”€

if an HSTS Host gets an HTTP request message over a non-secure transport, it SHOULD send back an HTTP response message with a status code that means a permanent redirect, like status code 301 (Section 10.3.2 of [RFC2616]) ๐Ÿ’… the Location header field value should be either the HTTP request's original Effective Request URI (see Section 9 ("Constructing an Effective Request URI")) changed as needed so the URI scheme is "https", or a URI generated according to local policy with a URI scheme of "https" โœจ

NOTE: The above behavior is a "SHOULD" rather than a "MUST" due to:

  • Risks in server-side non-secure-to-secure redirects [OWASP-TLSGuide].
  • Site deployment characteristics. For example, a site that incorporates third-party components may not behave correctly when doing server-side non-secure-to-secure redirects in the case of being accessed over non-secure transport but does behave correctly when accessed uniformly over secure transport. The latter is the case given an HSTS-capable UA that has already noted the site as a Known HSTS Host (by whatever means, e.g., prior interaction or UA configuration). ๐ŸŒˆ

an HSTS Host MUST NOT include the STS header field in HTTP responses that go over non-secure transport ๐Ÿšซ

8. User Agent Processing Model ๐Ÿ‘‘

this section is the HTTP Strict Transport Security processing model for UAs ๐Ÿ’œ it has a bunch of facets, listed in the subsections below.

this processing model assumes the UA implements IDNA2008 [RFC5890], or possibly IDNA2003 [RFC3490], as noted in Section 13 ("Internationalized Domain Names for Applications (IDNA): Dependency and Migration") ๐Ÿฆ‹ it also assumes every domain name handled in this spec has already been IDNA-canonicalized as outlined in Section 10 ("Domain Name IDNA-Canonicalization") before this processing happens.

NOTE: [RFC3490] is referenced due to its ongoing relevance to actual deployments for the foreseeable future. ๐Ÿ“

so basically, this model also assumes that the IDNA and Unicode validations and character list testing have already happened on the domain names, along with their IDNA-canonicalization, before anything in this section runs. for the rationale and details, check the IDNA-specific security considerations in Section 14.10 ("Internationalized Domain Names") ๐Ÿ”ฅ

8.1. Strict-Transport-Security Response Header Field Processing ๐Ÿง

if an HTTP response comes in over a secure transport and includes an STS header field that follows the grammar in Section 6.1 ("Strict-Transport-Security HTTP Response Header Field"), and there are no underlying secure transport errors or warnings (see Section 8.4), the UA MUST do one of these:

  • Note the host as a Known HSTS Host if it is not already noted (see Section 8.1.1 ("Noting an HSTS Host - Storage Model")),

or

  • Update the UA's cached information for the Known HSTS Host if either or both of the max-age and includeSubDomains header field value tokens are conveying information different than that already maintained by the UA.

the max-age value is basically a "time to live" value, counted from when the STS header field was received โณ

if the max-age header field value token is zero, the UA MUST remove its cached HSTS Policy information (including the includeSubDomains directive, if asserted) when the HSTS Host is known, or the UA MUST NOT note this HSTS Host if it is not yet known ๐Ÿ’€

if a UA gets more than one STS header field in an HTTP response message over a secure transport, the UA MUST process only the first such header field ๐Ÿซถ

Otherwise:

  • If an HTTP response is received over insecure transport, the UA MUST ignore any present STS header field(s).
  • The UA MUST ignore any STS header fields not conforming to the grammar specified in Section 6.1 ("Strict-Transport-Security HTTP Response Header Field"). ๐Ÿ™…

8.1.1. Noting an HSTS Host - Storage Model ๐Ÿ—ƒ๏ธ

if the substring matching the host production from the Request-URI (of the message the host responded to) syntactically matches the IP-literal or IPv4address productions from Section 3.2.2 of [RFC3986], then the UA MUST NOT note this host as a Known HSTS Host ๐Ÿšซ

otherwise, if the substring does not congruently match a Known HSTS Host's domain name (using the matching procedure in Section 8.2 ("Known HSTS Host Domain Name Matching")), then the UA MUST note this host as a Known HSTS Host โœจ it caches the HSTS Host's domain name, plus the expiry time of this info (effectively set by the given max-age value), and whether includeSubDomains is asserted or not ๐ŸŒธ see also Section 11.2 ("HSTS Policy Expiration Time Considerations").

the UA MUST NOT modify the expiry time or the includeSubDomains directive of any superdomain matched Known HSTS Host ๐Ÿ™ˆ

a Known HSTS Host is "expired" if its cache entry has an expiry date in the past ๐Ÿ’€ the UA MUST evict all expired Known HSTS Hosts from its cache if, at any time, an expired Known HSTS Host exists in the cache ๐Ÿงน

8.2. Known HSTS Host Domain Name Matching

Okay so a given domain name can match a Known HSTS Host's domain name in one or both of two fashions: a congruent match, or a superdomain match. Or it can just not match at all, which is a totally valid vibe too ๐Ÿฆ‹

The steps below figure out whether there are any matches, and if so, which fashion:

Compare the given domain name with the domain name of each of the UA's unexpired Known HSTS Hosts. For each Known HSTS Host's domain name, the comparison is done with the given domain name label-by-label (comparing only labels) using an ASCII case-insensitive comparison beginning with the rightmost label, and continuing right-to-left. See also Section 2.3.2.4 of [RFC5890]. ๐Ÿ”

  • Superdomain Match

If a label-for-label match between an entire Known HSTS Host's domain name and a right-hand portion of the given domain name is found, then this Known HSTS Host's domain name is a superdomain match for the given domain name. There could be multiple superdomain matches for a given domain name. ๐Ÿ‘ฏโ€โ™€๏ธ

For example:

Given domain name (DN):   qaz.bar.foo.example.com

Superdomain matched
Known HSTS Host DN:           bar.foo.example.com

Superdomain matched
Known HSTS Host DN:               foo.example.com
  • Congruent Match

If a label-for-label match between a Known HSTS Host's domain name and the given domain name is found -- i.e., there are no further labels to compare -- then the given domain name congruently matches this Known HSTS Host. ๐Ÿ’…

For example:

Given domain name:                foo.example.com

Congruently matched
Known HSTS Host DN:               foo.example.com
  • Otherwise, if no matches are found, the given domain name does not represent a Known HSTS Host. ๐Ÿซฅ

8.3. URI Loading and Port Mapping

Whenever the UA prepares to "load" (also known as "dereference") any "http" URI [RFC3986] (including when following HTTP redirects [RFC2616]), the UA MUST first determine whether a domain name is given in the URI and whether it matches a Known HSTS Host, using these steps: ๐Ÿง

  1. Extract from the URI any substring described by the host component of the authority component of the URI.
  2. If the substring is null, then there is no match with any Known HSTS Host.
  3. Else, if the substring is non-null and syntactically matches the IP-literal or IPv4address productions from Section 3.2.2 of [RFC3986], then there is no match with any Known HSTS Host.
  4. Otherwise, the substring is a given domain name, which MUST be matched against the UA's Known HSTS Hosts using the procedure in Section 8.2 ("Known HSTS Host Domain Name Matching").
  5. If, when performing domain name matching, any superdomain match with an asserted includeSubDomains directive is found, or, if no superdomain matches with asserted includeSubDomains directives are found and a congruent match is found (with or without an asserted includeSubDomains directive), then before proceeding with the load:
    • The UA MUST replace the URI scheme with "https" [RFC2818], and
    • if the URI contains an explicit port component of "80", then the UA MUST convert the port component to be "443", or
    • if the URI contains an explicit port component that is not equal to "80", the port component value MUST be preserved; otherwise,
    • if the URI does not contain an explicit port component, the UA MUST NOT add one.
NOTE: These steps ensure that the HSTS Policy applies to HTTP over any TCP port of an HSTS Host. ๐ŸŒˆ
NOTE: In the case where an explicit port is provided (and to a lesser extent with subdomains), it is reasonably likely that there is actually an HTTP (i.e., non-secure) server running on the specified port and that an HTTPS request will thus fail (see item 6 in Appendix A ("Design Decision Notes")). ๐Ÿ™ˆ

8.4. Errors in Secure Transport Establishment

When connecting to a Known HSTS Host, the UA MUST terminate the connection (see also Section 12 ("User Agent Implementation Advice")) if there are any errors, whether "warning" or "fatal" or any other error level, with the underlying secure transport. For example, this includes any errors found in certificate validity checking that UAs employ, such as via Certificate Revocation Lists (CRLs) [RFC5280], or via the Online Certificate Status Protocol (OCSP) [RFC2560], as well as via TLS server identity checking [RFC6125]. ๐Ÿ”’๐Ÿ’€


8.5. HTTP-Equiv <Meta> Element Attribute

UAs MUST NOT heed http-equiv="Strict-Transport-Security" attribute settings on <meta> elements [W3C.REC-html401-19991224] in received content. ๐Ÿšซ


8.6. Missing Strict-Transport-Security Response Header Field

If a UA receives HTTP responses from a Known HSTS Host over a secure channel but the responses are missing the STS header field, the UA MUST continue to treat the host as a Known HSTS Host until the max-age value for the knowledge of that Known HSTS Host is reached. Note that the max-age value could be effectively infinite for a given Known HSTS Host. For example, this would be the case if the Known HSTS Host is part of a pre-configured list that is implemented such that the list entries never "age out". โณ๐Ÿ‘‘


9. Constructing an Effective Request URI โœจ

This section specifies how an HSTS Host must construct the Effective Request URI for a received HTTP request.

HTTP requests often do not carry an absoluteURI for the target resource. Instead, the URI needs to be inferred from the Request-URI, Host header field, and connection context ([RFC2616], Sections 3.2.1, 5.1.2, and 5.2). The result of this process is called the "effective request URI (ERU)". The "target resource" is the resource identified by the effective request URI. ๐ŸŽฏ


9.1. ERU Fundamental Definitions

The first line of an HTTP request message, Request-Line, is specified by the following ABNF from [RFC2616], Section 5.1:

  Request-Line   = Method SP Request-URI SP HTTP-Version CRLF

The Request-URI, within the Request-Line, is specified by the following ABNF from [RFC2616], Section 5.1.2:

  Request-URI    = "*" | absoluteURI | abs_path | authority

The Host request header field is specified by the following ABNF from [RFC2616], Section 14.23:

  Host = "Host" ":" host [ ":" port ]

9.2. Determining the Effective Request URI

If the Request-URI is an absoluteURI, then the effective request URI is the Request-URI.

If the Request-URI uses the abs_path form or the asterisk form, and the Host header field is present, then the effective request URI is constructed by concatenating:

  • the scheme name: "http" if the request was received over an insecure TCP connection, or "https" when received over a TLS/SSL-secured TCP connection, and
  • the octet sequence "://", and
  • the host, and the port (if present), from the Host header field, and
  • the Request-URI obtained from the Request-Line, unless the Request-URI is just the asterisk "*".

If the Request-URI uses the abs_path form or the asterisk form, and the Host header field is not present, then the effective request URI is undefined.

Otherwise, when Request-URI uses the authority form, the effective request URI is undefined.

Effective request URIs are compared using the rules described in [RFC2616] Section 3.2.3, except that empty path components MUST NOT be treated as equivalent to an absolute path of "/". ๐Ÿงฉ


9.2.1. Effective Request URI Examples

Example 1: the effective request URI for the message

  GET /pub/WWW/TheProject.html HTTP/1.1
  Host: www.example.org:8080

(received over an insecure TCP connection) is "http", plus "://", plus the authority component "www.example.org:8080", plus the request-target "/pub/WWW/TheProject.html". Thus, it is "http://www.example.org:8080/pub/WWW/TheProject.html". ๐ŸŒธ

Example 2: the effective request URI for the message

  OPTIONS * HTTP/1.1
  Host: www.example.org

(received over an SSL/TLS secured TCP connection) is "https", plus "://", plus the authority component "www.example.org". Thus, it is "https://www.example.org". ๐Ÿ”


10. Domain Name IDNA-Canonicalization ๐ŸŒ

An IDNA-canonicalized domain name is the output string generated by the following steps. The input is a putative domain name string ostensibly composed of any combination of "A-labels", "U-labels", and "NR-LDH labels" (see Section 2 of [RFC5890]) concatenated using some separator character (typically ".").

  1. Convert the input putative domain name string to an order-preserving sequence of individual label strings.
  2. When implementing IDNA2008, convert, validate, and test each A-label and U-label found among the sequence of individual label strings, using the procedures defined in Sections 5.3 through 5.5 of [RFC5891].

Otherwise, when implementing IDNA2003, convert each label using the "ToASCII" conversion in Section 4 of [RFC3490] (see also the definition of "equivalence of labels" in Section 2 of [RFC3490]).

  1. If no errors occurred during the foregoing step, concatenate all the labels in the sequence, in order, into a string, separating each label from the next with a %x2E (".") character. The resulting string, known as an IDNA-canonicalized domain name, is appropriate for use in the context of Section 8 ("User Agent Processing Model").

Otherwise, errors occurred. The input putative domain name string was not successfully IDNA-canonicalized. Invokers of this procedure should attempt appropriate error recovery.

See also Sections 13 ("Internationalized Domain Names for Applications (IDNA): Dependency and Migration") and 14.10 ("Internationalized Domain Names") of this specification for further details and considerations. ๐Ÿซถ


11. Server Implementation and Deployment Advice ๐Ÿ› ๏ธ

This section is non-normative.


11.1. Non-Conformant User Agent Considerations

Non-conformant UAs ignore the Strict-Transport-Security header field; thus, non-conformant user agents do not address the threats described in Section 2.3.1 ("Threats Addressed"). Please refer to Section 14.2 ("Non-Conformant User Agent Implications") for further discussion. ๐Ÿ™…โ€โ™€๏ธ

11.2. HSTS Policy Expiration Time Considerations ๐Ÿ•ฐ๏ธ

okay so server implementations and deploying web sites need to think about whether they're setting an expiry time that's a constant value into the future, or a fixed point in time. ๐Ÿ’…

The "constant value into the future" approach can be accomplished by constantly sending the same max-age value to UAs. it's giving steady and predictable ๐ŸŒธ

For example, a max-age value of 7776000 seconds is 90 days:

Strict-Transport-Security: max-age=7776000

Note that each receipt of this header by a UA will require the UA to update its notion of when it must delete its knowledge of this Known HSTS Host. so every single time the header shows up, the UA bumps its countdown โณ

The "fixed point in time" approach can be accomplished by sending max-age values that represent the remaining time until the desired expiry time. This would require the HSTS Host to send a newly calculated max-age value in each HTTP response. that's more math on every response, bestie ๐Ÿงฎ

A consideration here is whether a deployer wishes to have the signaled HSTS Policy expiry time match that for the web site's domain certificate. good question to ask yourself ๐Ÿค”

Additionally, server implementers should consider employing a default max-age value of zero in their deployment configuration systems. This will require deployers to willfully set max-age in order to have UAs enforce the HSTS Policy for their host, and it will protect them from inadvertently enabling HSTS with some arbitrary non-zero duration. zero by default is such a safe, cute move ๐Ÿ›ก๏ธ


11.3. Using HSTS in Conjunction with Self-Signed Public-Key Certificates ๐Ÿ”

If all four of the following conditions are true...

  • a web site/organization/enterprise is generating its own secure transport public-key certificates for web sites, and
  • that organization's root certification authority (CA) certificate is not typically embedded by default in browser and/or operating system CA certificate stores, and
  • HSTS Policy is enabled on a host identifying itself using a certificate signed by the organization's CA (i.e., a "self-signed certificate"), and
  • this certificate does not match a usable TLS certificate association (as defined by Section 4 of the TLSA protocol specification [RFC6698]),

...then secure connections to that site will fail, per the HSTS design. This is to protect against various active attacks, as discussed above. this is the whole point, so no sneaking around it ๐Ÿšซ

However, if said organization wishes to employ its own CA, and self-signed certificates, in concert with HSTS, it can do so by deploying its root CA certificate to its users' browsers or operating system CA root certificate stores. It can also, in addition or instead, distribute to its users' browsers the end-entity certificate(s) for specific hosts. There are various ways in which this can be accomplished (details are out of scope for this specification). Once its root CA certificate is installed in the browsers, it may employ HSTS Policy on its site(s). ๐Ÿง

Alternatively, that organization can deploy the TLSA protocol; all browsers that also use TLSA will then be able to trust the certificates identified by usable TLS certificate associations as denoted via TLSA. โœจ

NOTE: Interactively distributing root CA certificates to users, e.g., via email, and having the users install them, is arguably training the users to be susceptible to a possible form of phishing attack. See Section 14.8 ("Bogus Root CA Certificate Phish plus DNS Cache Poisoning Attack"). Thus, care should be taken in the manner in which such certificates are distributed and installed on users' systems and browsers. ๐ŸŽฃ so please don't just email root certs to people and call it a day

11.4. Implications of includeSubDomains ๐ŸŒ

The includeSubDomains directive has practical implications meriting careful consideration; two example scenarios are:

  • An HSTS Host offers unsecured HTTP-based services on alternate ports or at various subdomains of its HSTS Host domain name.
  • Distinct web applications are offered at distinct subdomains of an HSTS Host, such that UAs often interact directly with these subdomain web applications without having necessarily interacted with a web application offered at the HSTS Host's domain name (if any).

The sections below discuss each of these scenarios in turn. ๐Ÿ‘€

11.4.1. Considerations for Offering Unsecured HTTP Services at Alternate Ports or Subdomains of an HSTS Host ๐Ÿง

For example, certification authorities often offer their CRL distribution and OCSP services [RFC2560] over plain HTTP, and sometimes at a subdomain of a publicly available web application that may be secured by TLS/SSL. For example, <https://ca.example.com/> is a publicly available web application for "Example CA", a certification authority. Customers use this web application to register their public keys and obtain certificates. "Example CA" generates certificates for customers containing <http://crl-and-ocsp.ca.example.com/> as the value for the "CRL Distribution Points" and "Authority Information Access:OCSP" certificate fields.

If ca.example.com were to issue an HSTS Policy with the includeSubDomains directive, then HTTP-based user agents implementing HSTS that have interacted with the ca.example.com web application would fail to retrieve CRLs and fail to check OCSP for certificates, because these services are offered over plain HTTP. ๐Ÿ˜ฑ oop, that's a whole mess

In this case, Example CA can either:

  • not use the includeSubDomains directive, or
  • ensure that HTTP-based services offered at subdomains of ca.example.com are also uniformly offered over TLS/SSL, or
  • offer plain HTTP-based services at a different domain name, e.g., crl-and-ocsp.ca.example.NET, or
  • utilize an alternative approach to distributing certificate status information, obviating the need to offer CRL distribution and OCSP services over plain HTTP (e.g., the "Certificate Status Request" TLS extension [RFC6066], often colloquially referred to as "OCSP Stapling").
NOTE: The above points are expressly only an example and do not purport to address all the involved complexities. For instance, there are many considerations -- on the part of CAs, certificate deployers, and applications (e.g., browsers) -- involved in deploying an approach such as "OCSP Stapling". Such issues are out of scope for this specification. ๐Ÿ“

11.4.2. Considerations for Offering Web Applications at Subdomains of an HSTS Host ๐Ÿ 

In this scenario, an HSTS Host declares an HSTS Policy with an includeSubDomains directive, and there also exist distinct web applications offered at distinct subdomains of the HSTS Host such that UAs often interact directly with these subdomain web applications without having necessarily interacted with the HSTS Host. In such a case, the UAs will not receive or enforce the HSTS Policy. the sneaky gap, bestie

For example, the HSTS Host is "example.com", and it is configured to emit the STS header field with the includeSubDomains directive. However, example.com's actual web application is addressed at "www.example.com", and example.com simply redirects user agents to https://www.example.com/.

If the STS header field is only emitted by "example.com" but UAs typically bookmark -- and links (from anywhere on the web) are typically established to -- "www.example.com", and "example.com" is not contacted directly by all user agents in some non-zero percentage of interactions, then some number of UAs will not note "example.com" as an HSTS Host, and some number of users of "www.example.com" will be unprotected by HSTS Policy. ๐Ÿ’”

To address this, HSTS Hosts should be configured such that the STS header field is emitted directly at each HSTS Host domain or subdomain name that constitutes a well-known "entry point" to one's web application(s), whether or not the includeSubDomains directive is employed. ๐Ÿšช

Thus, in our example, if the STS header field is emitted from both "example.com" and "www.example.com", this issue will be addressed. Also, if there are any other well-known entry points to web applications offered by "example.com", such as "foo.example.com", they should also be configured to emit the STS header field. ๐Ÿ’–


12. User Agent Implementation Advice ๐Ÿ› ๏ธ

This section is non-normative.

In order to provide users and web sites more effective protection, as well as controls for managing their UA's caching of HSTS Policy, UA implementers should consider including features such as the following:


12.1. No User Recourse ๐Ÿšซ

Failing secure connection establishment on any warnings or errors (per Section 8.4 ("Errors in Secure Transport Establishment")) should be done with "no user recourse". This means that the user should not be presented with a dialog giving her the option to proceed. Rather, it should be treated similarly to a server error where there is nothing further the user can do with respect to interacting with the target web application, other than wait and retry. ๐Ÿ™…โ€โ™€๏ธ

Essentially, "any warnings or errors" means anything that would cause the UA implementation to announce to the user that something is not entirely correct with the connection establishment.

Not doing this, i.e., allowing user recourse such as "clicking through warning/error dialogs", is a recipe for a man-in-the-middle attack. If a web application issues an HSTS Policy, then it is implicitly opting into the "no user recourse" approach, whereby all certificate errors or warnings cause a connection termination, with no chance to "fool" users into making the wrong decision and compromising themselves. no clicking through the scary popups, periodt ๐Ÿ’€


12.2. User-Declared HSTS Policy ๐Ÿ“ฃ

A user-declared HSTS Policy is the ability for users to explicitly declare a given domain name as representing an HSTS Host, thus seeding it as a Known HSTS Host before any actual interaction with it. This would help protect against the bootstrap MITM vulnerability as discussed in Section 14.6 ("Bootstrap MITM Vulnerability"). users basically getting to be the bouncer ๐Ÿ˜ค

NOTE: Such a feature is difficult to get right on a per-site basis. See the discussion of "rewrite rules" in Section 5.5 of [ForceHTTPS]. For example, arbitrary web sites may not materialize all their URIs using the "https" scheme and thus could "break" if a UA were to attempt to access the site exclusively using such URIs. Also note that this feature would complement, but is independent of, an "HSTS pre-loaded list" feature (see Section 12.3). ๐Ÿงฉ

12.3. HSTS Pre-Loaded List ๐Ÿ“‹

An HSTS pre-loaded list is a facility whereby web site administrators can have UAs pre-configured with HSTS Policy for their site(s) by the UA vendor(s) -- a so-called "pre-loaded list" -- in a manner similar to how root CA certificates are embedded in browsers "at the factory". This would help protect against the bootstrap MITM vulnerability (Section 14.6). pre-installed protection, iconic ๐ŸŒˆ

NOTE: Such a facility would complement a "user-declared HSTS Policy" feature (Section 12.2). ๐ŸŽ€

12.4. Disallow Mixed Security Context Loads โœจ

okay so "mixed security context" loads happen when a web app resource gets fetched by the UA over a secure transport, and then that resource goes and fetches other stuff WITHOUT secure transport ๐Ÿ˜ญ this is also called "mixed content" loads (see Section 5.3 ("Mixed Content") in [W3C.REC-wsc-ui-20100812]), but pls don't mix it up with the other "mixed content" term used for markup languages like XML and HTML ๐Ÿ™ˆ

NOTE: In order to provide behavioral uniformity across UA implementations, the notion of mixed security context will require further standardization work, e.g., to define the term(s) more clearly and to define specific behaviors with respect to it. ๐Ÿงš

12.5. HSTS Policy Deletion ๐Ÿ—‘๏ธ

HSTS Policy deletion is the ability to delete a UA's cached HSTS Policy on a per-HSTS Host basis. Main character energy, but make it intentional ๐Ÿ’…

NOTE: Adding such a feature should be done very carefully in both the user interface and security senses. Deleting a cache entry for a Known HSTS Host should be a very deliberate and well-considered act -- it shouldn't be something that users get used to doing as a matter of course: e.g., just "clicking through" in order to get work done. Also, implementations need to guard against allowing an attacker to inject code, e.g., ECMAscript, into the UA that silently and programmatically removes entries from the UA's cache of Known HSTS Hosts. ๐Ÿšจ

13. Internationalized Domain Names for Applications (IDNA): Dependency and Migration ๐ŸŒ

Textual domain names on the modern Internet may contain one or more "internationalized" domain name labels. Such domain names are referred to as "internationalized domain names" (IDNs). The specification suites defining IDNs and the protocols for their use are named "Internationalized Domain Names for Applications (IDNA)". Right now there are two of these suites: IDNA2008 [RFC5890] and its predecessor IDNA2003 [RFC3490] ๐Ÿฆ‹

IDNA2008 obsoletes IDNA2003, but there are differences between the two, so processing (e.g., converting) domain name labels registered under one can come out different from ones registered under the other. There will be a transition period of some time during which IDNA2003-based domain name labels will exist in the wild. So to make the IDNA transition smoother, user agents SHOULD implement IDNA2008 [RFC5890] and MAY implement [RFC5895] (see also Section 7 of [RFC5894]) or [UTS46]. If a user agent does not implement IDNA2008, the user agent MUST implement IDNA2003. Bestie, that last one is a hard rule ๐Ÿซถ

14. Security Considerations ๐Ÿ”

This specification is all about the expression, conveyance, and enforcement of the HSTS Policy. The overall HSTS Policy threat model, including addressed and unaddressed threats, is given in Section 2.3 ("Threat Model").

Additionally, the sections below discuss the operational ramifications of the HSTS Policy, provide feature rationale, discuss potential HSTS Policy misuse, and highlight some known vulnerabilities in the HSTS Policy regime. Buckle up, it's about to get dramatic ๐Ÿ’€

14.1. Underlying Secure Transport Considerations ๐Ÿš‡

This specification is fashioned to be independent of the secure transport underlying HTTP. However, the threat analysis and requirements in Section 2 ("Overview") actually presume TLS or SSL as the underlying secure transport. So if you employ HSTS in the context of HTTP running over some other secure transport protocol, you'd need to assess that transport's security model together with the specifics of how HTTP is layered over it, so you can figure out HSTS's security properties in that setup ๐Ÿง

14.2. Non-Conformant User Agent Implications ๐Ÿ™…โ€โ™€๏ธ

Non-conformant user agents ignore the Strict-Transport-Security header field, so they do not address the threats described in Section 2.3.1 ("Threats Addressed"). Not it. ๐Ÿ˜ค

This means the web application and its users wielding non-conformant UAs will be vulnerable to both of the following:

  • Passive network attacks due to web site development and deployment bugs:
    • For example, if the web application contains any insecure references (e.g., http) to the web application server, and if not all of its cookies are flagged as Secure, then its cookies will be vulnerable to passive network sniffing and, potentially, subsequent misuse of user credentials. ๐Ÿช๐Ÿ’€
  • Active network attacks:
    • For example, if an attacker is able to place a "man in the middle", secure transport connection attempts will likely yield warnings to the user, but without HSTS Policy being enforced, the present common practice is to allow the user to "click through" and proceed. This renders the user and possibly the web application open to abuse by such an attacker. ๐Ÿ˜ญ

This is essentially the status quo for all web applications and their users in the absence of HSTS Policy. Since web application providers typically don't control the type or version of UAs their web applications interact with, HSTS Host deployers must generally exercise the same level of care to avoid web site development and deployment bugs (see Section 2.3.1.3) as they would if they weren't asserting HSTS Policy. Care is the vibe ๐ŸŒธ

14.3. Ramifications of HSTS Policy Establishment Only over Error-Free Secure Transport ๐Ÿงฑ

The user agent processing model defined in Section 8 ("User Agent Processing Model") stipulates that a host is initially noted as a Known HSTS Host, or that updates are made to a Known HSTS Host's cached information, only if the UA receives the STS header field over a secure transport connection having no underlying secure transport errors or warnings. Clean connection or nothing, babe โœจ

The rationale behind this is that if there's a "man in the middle" (MITM) -- whether a legitimately deployed proxy or an illegitimate entity -- it could cause various mischief (see also Appendix A ("Design Decision Notes") item 3, as well as Section 14.6 ("Bootstrap MITM Vulnerability")). For example:

  • Unauthorized notation of the host as a Known HSTS Host, potentially leading to a denial-of-service situation if the host does not uniformly offer its services over secure transport (see also Section 14.5 ("Denial of Service")).
  • Resetting the time to live for the host's designation as a Known HSTS Host by manipulating the max-age header field parameter value that is returned to the UA. If max-age is returned as zero, this will cause the host to cease being regarded as a Known HSTS Host by the UA, leading to either insecure connections to the host or possibly denial of service if the host delivers its services only over secure transport. ๐Ÿ™ƒ

However, this means that if a UA is "behind" a MITM non-transparent TLS proxy -- within a corporate intranet, for example -- and interacts with an unknown HSTS Host beyond the proxy, the user could possibly be presented with the legacy secure connection error dialogs. Even if the risk is accepted and the user "clicks through", the host will not be noted as an HSTS Host. So as long as the UA is behind such a proxy, the user will be vulnerable and might keep getting those legacy secure connection error dialogs for as-yet unknown HSTS Hosts ๐Ÿ˜ฉ

Once the UA successfully connects to an unknown HSTS Host over error-free secure transport, the host will be noted as a Known HSTS Host. This will result in the failure of subsequent connection attempts from behind interfering proxies. Lowkey iconic, the proxy gets locked out ๐Ÿ”’๐Ÿ‘‘

The above discussion relates to the recommendation in Section 12 ("User Agent Implementation Advice") that the secure connection be terminated with "no user recourse" whenever there are warnings and errors and the host is a Known HSTS Host. Such a posture protects users from "clicking through" security warnings and putting themselves at risk. No cap, that's the whole point ๐Ÿซถ

14.4. The Need for includeSubDomains ๐Ÿ“

Without the includeSubDomains directive, a web application would not be able to adequately protect so-called "domain cookies" (even if these cookies have their "Secure" flag set and thus are conveyed only on secure channels). These are cookies the web application expects UAs to return to any and all subdomains of the web application.

For example, suppose example.com represents the top-level DNS name for a web application. Further suppose that this cookie is set for the entire example.com domain, i.e., it is a "domain cookie", and it has its Secure flag set. Suppose example.com is a Known HSTS Host for this UA, but the includeSubDomains directive is not set. ๐Ÿค”

Now, if an attacker causes the UA to request a subdomain name that is unlikely to already exist in the web application, such as https://uxdhbpahpdsf.example.com/, but that the attacker has managed to register in the DNS and point at an HTTP server under the attacker's control, then:

  1. The UA is unlikely to already have an HSTS Policy established for uxdhbpahpdsf.example.com.
  2. The HTTP request sent to uxdhbpahpdsf.example.com will include the Secure-flagged domain cookie.
  3. If uxdhbpahpdsf.example.com returns a certificate during TLS establishment, and the user "clicks through" any warning that might be presented (it is possible, but not certain, that one may obtain a requisite certificate for such a domain name such that a warning may or may not appear), then the attacker can obtain the Secure-flagged domain cookie that's ostensibly being protected. ๐Ÿ˜ฑ

Without the "includeSubDomains" directive, HSTS is unable to protect such Secure-flagged domain cookies. That's the tea, and it's why we always set it ๐Ÿตโœจ

14.5. Denial of Service ๐Ÿ’€

okay so HSTS can actually be used to mount some DoS attacks against websites ๐Ÿ˜ญ a DoS attack is when one or more network entities go after a victim and try to stop it from doing useful work. this section walks through the HSTS-flavoured versions, but the list isn't exhaustive, so don't treat it as the full tea ๐Ÿต for the wider picture on internet DoS, check out [RFC4732] ๐Ÿงš

  • Web applications available over HTTP ๐ŸŒธ

there's an opening for DoS if web applications (or the important parts of them) are only reachable over HTTP without secure transport, and attackers can get UAs to set HSTS Policy for those apps' host(s) ๐Ÿ™ˆ

it's giving domino effect: once the HSTS Policy is set for a web app's host in a UA, the UA will only talk to that host over secure transport. if the host isn't using secure transport, or isn't using it for the critical parts of its app, the web app becomes unusable for the UA's user ๐Ÿ’”

NOTE: This is a use case for UAs to offer an "HSTS Policy deletion" feature as noted in Section 12.5 ("HSTS Policy Deletion").

there are a few ways an HSTS Policy can get set on a victim host ๐Ÿ‘€

  • if the web app has an HTTP response splitting vulnerability [CWE-113] (which can be abused to pull off "HTTP header injection") ๐Ÿ’…
  • if an attacker can spoof a redirect from an insecure victim site, e.g., <http://example.com/> to <https://example.com/>, where the latter is attacker-controlled and has an apparently valid certificate. in that case the attacker can set an HSTS Policy for example.com and also for all subdomains of example.com ๐Ÿ˜ฑ
  • if an attacker can convince users to manually configure HSTS Policy for a victim host. this assumes their UAs offer that capability (see Section 12 ("User Agent Implementation Advice")). alternatively, if that UA configuration is scriptable, then an attacker can make UAs run his script and set HSTS Policies for whichever domains he wants ๐Ÿซ 
  • Inadvertent use of includeSubDomains ๐ŸŽ€

the includeSubDomains directive tells UAs to automatically treat all subdomains of the given HSTS Host as Known HSTS Hosts. if any of those subdomains don't support properly configured secure transport, they'll be unreachable from those UAs. oof ๐Ÿ˜ญ


14.6. Bootstrap MITM Vulnerability ๐Ÿ•ต๏ธโ€โ™€๏ธ

the bootstrap MITM (man-in-the-middle) vulnerability is one that users and HSTS Hosts run into when a user manually types in, or follows a link to, an unknown HSTS Host using an "http" URI instead of an "https" URI. the UA's first attempt to talk to that server happens over an insecure channel, so that initial interaction is open to various attacks (see Section 5.3 of [ForceHTTPS]) ๐Ÿฅบ

NOTE: There are various features/facilities that UA implementations may employ to mitigate this vulnerability. Please see Section 12 ("User Agent Implementation Advice").

14.7. Network Time Attacks โฐ

active network attacks can subvert network time protocols (like the Network Time Protocol (NTP) [RFC5905]), which makes HSTS less effective against clients that trust NTP or don't have a real time clock ๐Ÿซฅ network time attacks are out of scope for this specification. fun fact: modern operating systems use NTP by default. see also Section 2.10 of [RFC4732] โœจ


14.8. Bogus Root CA Certificate Phish plus DNS Cache Poisoning Attack ๐ŸŽฃ

an attacker could conceivably get users' login credentials for a victim HSTS-protected web app through a bogus root CA certificate phish plus a DNS cache poisoning attack ๐Ÿ˜ค

here's how that goes: the attacker first convinces users of a victim web app (which is protected by HSTS Policy) to install the attacker's version of a root CA certificate that falsely claims to represent the victim app's CA. this could happen with a phishing email that links to such a certificate, which their browsers may offer to install when clicked ๐Ÿ“ง

then, if the attacker can attack the users' DNS servers (e.g., via cache poisoning) and turn on HSTS Policy for their fake web app, the affected users' browsers would end up at the attacker's web app instead of the legit one ๐Ÿ’€

this type of attack uses vectors that are outside the scope of HSTS. however, the feasibility of these threats can be reduced by building appropriate security facilities into a web app's overall deployment approach, alongside HSTS. examples include DNS Security Extensions [RFC4033], plus techniques for blocking email phishing and fake certificate injection ๐Ÿ›ก๏ธ๐Ÿ’œ


14.9. Creative Manipulation of HSTS Policy Store ๐Ÿง 

since an HSTS Host can pick its own host name and subdomains thereof, and this info gets cached in the HSTS Policy store of conforming UAs, the people who control one or more HSTS Hosts can encode information into domain names they control. this makes the UAs cache that info as a matter of course while noting the HSTS Host ๐Ÿคฏ other hosts can then retrieve it through cleverly built web resources, which make the UA send queries to (variations of) the encoded domain names. those queries can reveal whether the UA had previously visited the original HSTS Host (and its subdomains) ๐Ÿ‘€

this technique could potentially be abused as yet another form of "web tracking" [WebTracking] ๐Ÿ“


14.10. Internationalized Domain Names ๐ŸŒ

internet security relies partly on the DNS and the domain names it hosts. users use domain names to identify and connect to Internet hosts and other network resources. for example, internet security is compromised if a user who enters an internationalized domain name (IDN) gets connected to different hosts based on different interpretations of that IDN ๐Ÿ˜ฌ

the processing models in this specification assume that the domain names they handle are IDNA-canonicalized, and that the canonicalization process correctly did all the appropriate IDNA and Unicode validations and character list testing per the requisite specifications (e.g., as noted in Section 10 ("Domain Name IDNA-Canonicalization")). these steps are necessary to avoid various potentially compromising situations ๐Ÿซถ

in short, problems that could come from inconsistent or careless Unicode and IDNA validation include unexpected processing exceptions, truncation errors, and buffer overflows, as well as false-positive and/or false-negative domain name matching results. attackers could possibly leverage any of these in various ways ๐Ÿ˜ญ

IDNA2008 [RFC5890] also differs from IDNA2003 [RFC3490] when it comes to disallowed characters and character mapping conventions. this can lead to false-positive and/or false-negative domain name matching results too, so users might end up communicating with unintended hosts or not being able to reach intended ones ๐Ÿ™ƒ

for details, check the Security Considerations sections of [RFC5890], [RFC5891], and [RFC3490], plus the specifications they normatively reference. [RFC5894] also gives detailed background and rationale for IDNA2008 in particular, along with IDNA and its issues in general, and should be read alongside the former specifications ๐Ÿ“šโœจ


15. IANA Considerations ๐Ÿ“‹

below is the Internet Assigned Numbers Authority (IANA) Permanent Message Header Field registration information per [RFC3864] ๐Ÿฆ‹

  Header field name:           Strict-Transport-Security
  Applicable protocol:         http
  Status:                      standard
  Author/Change controller:    IETF
  Specification document(s):   this one

16. References ๐Ÿ“–

16.1. Normative References ๐ŸŽ€

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

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

[RFC2818]  Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000.

[RFC3490]  Faltstrom, P., Hoffman, P., and A. Costello,
           "Internationalizing Domain Names in Applications (IDNA)",
           RFC 3490, March 2003.

[RFC3864]  Klyne, G., Nottingham, M., and J. Mogul, "Registration
           Procedures for Message Header Fields", BCP 90, RFC 3864,
           September 2004.

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

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

[RFC5890]  Klensin, J., "Internationalized Domain Names for
           Applications (IDNA): Definitions and Document Framework",
           RFC 5890, August 2010.

[RFC5891]  Klensin, J., "Internationalized Domain Names in
           Applications (IDNA): Protocol", RFC 5891, August 2010.

[RFC5895]  Resnick, P. and P. Hoffman, "Mapping Characters for
           Internationalized Domain Names in Applications
           (IDNA) 2008", RFC 5895, September 2010.

[RFC6698]  Hoffman, P. and J. Schlyter, "The DNS-Based Authentication
           of Named Entities (DANE) Transport Layer Security (TLS)
           Protocol: TLSA", RFC 6698, August 2012.

[UTS46]    Davis, M. and M. Suignard, "Unicode IDNA Compatibility
           Processing", Unicode Technical Standard #46,
           <http://unicode.org/reports/tr46/>.

[Unicode]  The Unicode Consortium, "The Unicode Standard",
           <http://www.unicode.org/versions/latest/>.

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

16.2. Informative References โœจ

Okay bestie, this is the "further reading" pile, aka the sources the spec leans on for background, attack stories, and tooling ๐Ÿ”. These are informative, so the spec doesn't need you to read them to implement HSTS, but they're seriously good receipts ๐Ÿงพ.

[Aircrack-ng] d'Otreppe, T., "Aircrack-ng", Accessed: 11-Jul-2010, <http://www.aircrack-ng.org/>.

[BeckTews09] Beck, M. and E. Tews, "Practical Attacks Against WEP and WPA", Second ACM Conference on Wireless Network Security Zurich, Switzerland, 2009, <http://dl.acm.org/citation.cfm?id=1514286>.

[CWE-113] "CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')", Common Weakness Enumeration <http://cwe.mitre.org/>, The Mitre Corporation <http://www.mitre.org/>, <http://cwe.mitre.org/data/definitions/113.html>.

[Firesheep] Various, "Firesheep", Wikipedia Online, ongoing, <https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Firesheep&oldid=517474182>.

[ForceHTTPS] Jackson, C. and A. Barth, "ForceHTTPS: Protecting High-Security Web Sites from Network Attacks", In Proceedings of the 17th International World Wide Web Conference (WWW2008), 2008, <https://crypto.stanford.edu/forcehttps/>.

[GoodDhamijaEtAl05] Good, N., Dhamija, R., Grossklags, J., Thaw, D., Aronowitz, S., Mulligan, D., and J. Konstan, "Stopping Spyware at the Gate: A User Study of Privacy, Notice and Spyware", In Proceedings of Symposium On Usable Privacy and Security (SOUPS) Pittsburgh, PA, USA, July 2005, <http://www.law.berkeley.edu/files/Spyware_at_the_Gate.pdf>.

[HTTP1_1-UPD] Fielding, R., Ed., and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", Work in Progress, October 2012.

[JacksonBarth2008] Jackson, C. and A. Barth, "Beware of Finer-Grained Origins", Web 2.0 Security and Privacy Workshop, Oakland, CA, USA, 2008, <http://seclab.stanford.edu/websec/origins/fgo.pdf>.

[OWASP-TLSGuide] Coates, M., Wichers, D., Boberski, M., and T. Reguly, "Transport Layer Protection Cheat Sheet", Accessed: 11-Jul-2010, <http://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet>.

[RFC1035] Mockapetris, P., "Domain names - implementation and specification", STD 13, RFC 1035, November 1987.

[RFC2560] Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. Adams, "X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP", RFC 2560, June 1999.

[RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, "DNS Security Introduction and Requirements", RFC 4033, March 2005.

[RFC4732] Handley, M., Rescorla, E., and IAB, "Internet Denial-of-Service Considerations", RFC 4732, December 2006.

[RFC4949] Shirey, R., "Internet Security Glossary, Version 2", RFC 4949, August 2007.

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

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

[RFC5894] Klensin, J., "Internationalized Domain Names for Applications (IDNA): Background, Explanation, and Rationale", RFC 5894, August 2010.

[RFC5905] Mills, D., Martin, J., Burbank, J., and W. Kasch, "Network Time Protocol Version 4: Protocol and Algorithms Specification", RFC 5905, June 2010.

[RFC6066] Eastlake, D., "Transport Layer Security (TLS) Extensions: Extension Definitions", RFC 6066, January 2011.

[RFC6101] Freier, A., Karlton, P., and P. Kocher, "The Secure Sockets Layer (SSL) Protocol Version 3.0", RFC 6101, August 2011.

[RFC6125] Saint-Andre, P. and J. Hodges, "Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS)", RFC 6125, March 2011.

[RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, April 2011.

[RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, December 2011.

[SunshineEgelmanEtAl09] Sunshine, J., Egelman, S., Almuhimedi, H., Atri, N., and L. Cranor, "Crying Wolf: An Empirical Study of SSL Warning Effectiveness", In Proceedings of 18th USENIX Security Symposium Montreal, Canada, August 2009, <http://www.usenix.org/events/sec09/tech/full_papers/sunshine.pdf>.

[W3C.REC-wsc-ui-20100812] Roessler, T. and A. Saldhana, "Web Security Context: User Interface Guidelines", World Wide Web Consortium Recommendation REC-wsc-ui-20100812, August 2010, <http://www.w3.org/TR/2010/REC-wsc-ui-20100812>.

[WebTracking] Schmucker, N., "Web Tracking", SNET2 Seminar Paper - Summer Term, 2011, <http://www.snet.tu-berlin.de/fileadmin/fg220/courses/SS11/snet-project/web-tracking_schmuecker.pdf>.


Appendix A. Design Decision Notes

Here's the behind-the-scenes tea on why the spec is shaped the way it is ๐ŸŽ€. This appendix is a log of the design choices.

  1. Cookies were a no-go for HSTS Policy ๐Ÿช. They can be changed while they're stored in the UA, so the spec uses an HTTP header field instead.
  2. The spec deliberately skips saying how "mixed security context loads" (also called "mixed content loads") get handled ๐Ÿ™ˆ. The reasons are UA implementation headaches and the fact that they're really hard to classify.
  3. An HSTS Host can update what the UA thinks its HSTS Policy is by sending new HSTS header field parameter values ๐Ÿ”„. The UA is told to honor the "freshest" info it gets from the server, because a site could accidentally send a bad policy, like a multi-year max-age, or a wrong includeSubDomains directive ๐Ÿ˜ฌ. If the HSTS Host couldn't fix that over the protocol, it would need to tell users somehow and have them step in manually, which would be a real pain for both web app providers and their users.
  4. HSTS Hosts get identified only by domain names ๐ŸŒ. Every form of explicit IP address identification is excluded. That keeps things simple, and it also acknowledges the issues that come with using direct IP addresses alongside PKI-based security.
  5. For the cached HSTS Policy time-to-live, the Host gives a simple integer number of seconds (the max-age approach), not a future expiration time โณ. The reasons: no clock synchronization needed, no date and time value syntaxes to define (simpler spec), and simpler implementations.
  6. When deciding about port mapping, one option was to just refuse to dereference any URL with an explicit port ๐Ÿšซ. The team decided against it. There could be a valid HTTPS server on that port even if the URI is wrong, and the cost of a few wasted HTTPS fetches to HTTP servers is small enough to accept ๐Ÿ’….

Appendix B. Differences between HSTS Policy and Same-Origin Policy

Okay so this is the "how is HSTS different from SOP" comparison, and the difference is kind of iconic ๐Ÿ‘‘.

HSTS Policy has these main characteristics:

  • HSTS Policy sets requirements for the security characteristics of UA-to-host connection establishment, on a per-host basis ๐Ÿ”.
  • Hosts explicitly declare HSTS Policy to UAs. Conformant UAs are obliged to implement the HSTS Policies that hosts declare ๐Ÿ“ฃ.
  • HSTS Policy is conveyed over protocol from the host to the UA ๐Ÿ“จ.
  • The UA keeps a cache of Known HSTS Hosts ๐Ÿ—‚๏ธ.
  • UAs apply HSTS Policy whenever they make an HTTP connection to a Known HSTS Host, no matter the port number. In other words, it covers all ports on a Known HSTS Host. Hosts can't change this part of HSTS Policy ๐Ÿ™…โ€โ™€๏ธ.
  • Hosts may optionally declare that their HSTS Policy applies to all subdomains of their host domain name ๐Ÿงš.

Now the Same-Origin Policy (SOP) [RFC6454] has these main characteristics:

  • An origin is the scheme, host, and port of a URI that identifies a resource ๐ŸŒธ.
  • A UA may dereference a URI, which loads a representation of the resource that URI identifies. UAs label resource representations with their origins, and those origins come from their URIs ๐Ÿท๏ธ.
  • The SOP is a collection of principles, implemented within UAs, that govern how resource representations are isolated from each other, how they communicate, and how they access network resources ๐Ÿงฑ.

The big takeaway: both HSTS Policy and SOP are enforced by UAs, but HSTS Policy is optionally declared by hosts and isn't origin-based, while the SOP applies to all resource representations loaded from all hosts by conformant UAs ๐Ÿ’œ.


Appendix C. Acknowledgments

Big shoutout time ๐Ÿซถ. The authors thank Devdatta Akhawe, Michael Barrett, Ben Campbell, Tobias Gondrom, Paul Hoffman, Murray Kucherawy, Barry Leiba, James Manger, Alexey Melnikov, Haevard Molland, Yoav Nir, Yngve N. Pettersen, Laksh Raghavan, Marsh Ray, Julian Reschke, Eric Rescorla, Tom Ritter, Peter Saint-Andre, Brian Smith, Robert Sparks, Maciej Stachowiak, Sid Stamm, Andy Steingrubl, Brandon Sterne, Martin Thomson, Daniel Veditz, and Jan Wrobel, plus all the websec working group participants and everyone else who reviewed and helped out ๐ŸŒˆ.

Extra love to Julian Reschke for his elegant rewrite of the effective request URI text ๐Ÿ‘‘. He did that while folding the ERU notion into the updates to HTTP/1.1 [HTTP1_1-UPD]. Later, the ERU text in this spec was lifted from Julian's work in the updated HTTP/1.1 (part 1) specification and adapted to the [RFC2616] ABNF ๐Ÿ’–.


Authors' Addresses

Here's how to reach the authors ๐Ÿ“ฎ โœจ.

Jeff Hodges
PayPal
2211 North First Street
San Jose, California  95131
US

EMail: Jeff.Hodges@PayPal.com


Collin Jackson
Carnegie Mellon University

EMail: collin.jackson@sv.cmu.edu


Adam Barth
Google, Inc.

EMail: ietf@adambarth.com
URI:   `http://www.adambarth.com/`
๐Ÿ“ฆ where this page comes from