Deprecate modification of 'secure' cookies from non-secure origins
Google, Inc
mkwst@google.com
https://mikewest.org/
General
HTTP
Internet-Draft
This document updates RFC6265 by removing the ability for a non-secure origin
to set cookies with a ‘secure’ flag, and to overwrite cookies whose ‘secure’
flag is set. This deprecation improves the isolation between HTTP and HTTPS
origins, and reduces the risk of malicious interference.
Section 8.5 and Section 8.6 of spell out some of the drawbacks of
cookies’ implementation: due to historical accident, non-secure origins can set
cookies which will be delivered to secure origins in a manner indistinguishable
from cookies set by that origin itself. This enables a number of attacks, which
have been recently spelled out in some detail in .
We can mitigate the risk of these attacks by making it more difficult for
non-secure origins to influence the state of secure origins. Accordingly, this
document recommends the deprecation and removal of non-secure origins’ ability
to write cookies with a ‘secure’ flag, and their ability to overwrite cookies
whose ‘secure’ flag is set.
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 .
The scheme component of a URI is defined in Section 3 of .
This document updates Section 5.3 of as follows:
After step 8 of the current algorithm, which sets the cookie’s
secure-only-flag, execute the following step:
If the scheme component of the request-uri does not denote a
“secure” protocol (as defined by the user agent), and the cookie’s
secure-only-flag is true, then abort these steps and ignore the
newly created cookie entirely.
Before step 11, execute the following step:
If the newly created cookie’s secure-only-flag is not set, and the
scheme component of the request-uri does not denote a “secure”
protocol, then abort these steps and ignore the newly created cookie
entirely if the cookie store contains one or more cookies that meet all
of the following criteria:
Their name matches the name of the newly created cookie.
Their secure-only-flag is set.
Their domain domain-matches the domain of the newly created
cookie, or vice-versa.
Note: This comparison intentionally ignores the path component. The
intent is to allow the secure flag to supercede the path
restrictions to protect sites against cookie fixing attacks.
Note: This allows “secure” pages to override secure cookies with
non-secure variants. Perhaps we should restrict that as well?
In order to ensure that a non-secure site can never cause a secure cookie
to be evisted, adjust the “remove excess cookies” priority order at the
bottom of Section 5.3 to be the following:
Expired cookies.
Cookies whose secure-only-flag is not set and which share a
domain field with more than a predetermined number of other cookies.
Cookies that share a domain field with more than a predetermined
number of other cookies.
All cookies.
Note that the eviction algorithm specified here is triggered only after
insertion of a cookie which causes the user agent to exceed some
predetermined upper bound. Conforming user agents MUST ensure that inserting
a non-secure cookie does not cause a secure cookie to be removed.
This specification increases a site’s confidence that secure cookies it sets
will remain unmodified by insecure pages on hosts which it domain-matches.
Ideally, sites would use HSTS as described in to defend more
robustly against the dangers of non-secure transport in general, but until
adoption of that protection becomes ubiquitous, this deprecation this document
recommends will mitigate a number of risks.
The mitigations in this document do not, however, give complete confidence that
a given cookie was set securely. If an attacker is able to impersonate a
response from http://example.com/ before a user visits https://example.com/,
the user agent will accept any cookie that the insecure origin sets, as the
“secure” cookie won’t yet be present in the user agent’s cookie store. An
active network attacker may still be able to use this ability to mount an attack
against example.com, even if that site uses HTTPS exclusively.
The proposal in could mitigate this risk, as could
“preloading” HSTS for example.com into the user agent .
Key words for use in RFCs to Indicate Requirement Levels
In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
Uniform Resource Identifier (URI): Generic Syntax
A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource. This specification defines the generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines and security considerations for the use of URIs on the Internet. The URI syntax defines a grammar that is a superset of all valid URIs, allowing an implementation to parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier. This specification does not define a generative grammar for URIs; that task is performed by the individual specifications of each URI scheme. [STANDARDS-TRACK]
HTTP State Management Mechanism
This document defines the HTTP Cookie and Set-Cookie header fields. These header fields can be used by HTTP servers to store state (called cookies) at HTTP user agents, letting the servers maintain a stateful session over the mostly stateless HTTP protocol. Although cookies have many historical infelicities that degrade their security and privacy, the Cookie and Set-Cookie header fields are widely used on the Internet. This document obsoletes RFC 2965. [STANDARDS-TRACK]
Cookies Lack Integrity: Real-World Implications
Tsinghua University and Tsinghua National Laboratory for Information Science and Technology
University of California, Berkeley
Tsinghua University and Tsinghua National Laboratory for Information Science and Technology;
Tsinghua University, Tsinghua National Laboratory for Information Science and Technology, and International Computer Science Institute;
Microsoft Research Redmond;
Huawei Canada
International Computer Science Institute and University of California, Berkeley
Cookie Prefixes
Google, Inc
HSTS Preload Submission
HTTP Strict Transport Security (HSTS)
This specification defines a mechanism enabling web sites to declare themselves accessible only via secure connections and/or for users to be able to direct their user agent(s) to interact with given sites only over secure connections. This overall policy is referred to as HTTP Strict Transport Security (HSTS). The policy is declared by web sites via the Strict-Transport-Security HTTP response header field and/or by other means, such as user agent configuration, for example. [STANDARDS-TRACK]
Richard Barnes encouraged a formalization of the deprecation proposal.
was a useful exploration of the issues
described.