This section is not normative.
As the Web platform is extended to enable more useful and powerful applications, it becomes increasingly important to ensure that the features which enable those applications are enabled only in contexts which meet a minimum security bar. This document outlines threat models for feature abuse on the Web and outline normative requirements which should be incorporated into documents specifying new features.
The most obvious of the requirements discussed here is that application code with access to sensitive or private data be delivered over authenticated and confidential channels that guarantee data integrity. Delivering code securely cannot ensure that an application will always meet a user’s security and privacy requirments, but it is a necessary precondition.
2. Key Concepts and Terminology
2.1. Terms defined by this specification
- powerful feature
- Defined in §3 Is [insert feature here] powerful? .
- sufficiently secure context
Documentis considered sufficiently secure if the algorithm defined in §4.1 Is Document a sufficiently secure context? returns
Sufficiently Securewhen executed upon it.
Likewise, a settings object is considered sufficiently secure if the algorithm defined in §4.2 Is settings object a sufficiently secure context? returns
Sufficiently Securewhen executed upon it.
- embedding document
DocumentA, the embedding document of A is the
Documentthrough which A’s browsing context is nested.
2.2. Terms defined by reference
An origin defines the scope of authority or privilege under which a resource operates. It boils down to a tuple of scheme, host, and port. The concept is defined in detail in [RFC6454].
A potentially secure origin is an origin that isn’t insecure a priori, defined in detail in [MIX].
The TLS State of a
defined in [FETCH].
The following terms are defined in [HTML5]:
3. Is [insert feature here] powerful?
Certain web platform features that have a distinct impact on a user’s security or privacy should be available for use only in sufficiently secure contexts.
Broadly speaking, we consider a feature powerful enough to restrict when it fits into one or more of the following categories:
- The feature provides access to sensitive data (personally-identifying information, credentials, payment instruments, and so on). [CREDENTIAL-MANAGEMENT] is an example of such an API.
- The feature provides access to sensor data on a user’s device (camera, microphone, and GPS being particularly noteworthy, but certainly including less obviously dangerous sensors like the accelerometer). [GEOLOCATION-API] and [MEDIACAPTURE-STREAMS] are historical examples.
- The feature provides access to or information about other devices a user has access to. [DISCOVERY] and [BLUETOOTH] are good examples.
- The feature exposes temporary or persistent identifiers, including identifying hardware features the user can’t easily reset. [ENCRYPTED-MEDIA] for instance.
- The feature introduces some state for an origin which persists across browsing sessions. [SERVICE-WORKERS] is a great example.
- The feature introduces some functionality for which user permission will be required.
This list is non-exhaustive, but should give you a feel for the types of features you should be concerned about.
We need to distinguish between legacy features like cookies,
localStorage, IndexedDB, etc, which all persist state (and
potentially identifiers) across browsing sessions. They’re certainly not
features we can reasonably limit to secure contexts in the forseeable future.
This might involve language along the lines of what mnot@ proposed in
Note: While restricting the feature itself to sufficiently secure contexts is critical, we ought not forget that facilities that carry such information (such as new network access mechanisms, or other generic functions with access to network data) are equally sensitive.
3.1. Threat Models
Granting permissions to unauthenticated origins is, in the presence of a network attacker, equivalent to granting the permissions to any origin. The state of the Internet is such that we must indeed assume that a network attacker is present. Generally, network attackers fall into 2 classes: passive and active.
3.1.1. Passive Network Attacker
A "Passive Network Attacker" is a party who is able to observe traffic flows but who lacks the ability or chooses not to modify traffic at the layers which this specification is concerned with.
Surveillance of networks in this manner "subverts the intent of communicating parties without the agreement of these parties" and one "cannot defend against the most nefarious actors while allowing monitoring by other actors no matter how benevolent some might consider them to be." [RFC7258] Therefore, the algorithms defined in this document require mechansims that provide for the privacy of data at the application layer, not simply integrity.
3.1.2. Active Network Attacker
An "Active Network Attacker" has all the capabilities of a "Passive Network Attacker" and is additionally able to modify, block or replay any data transiting the network. These capabilties are available to potential adversaries at many levels of capability, from compromised devices offering or simply participating in public wireless networks, to Internet Service Providers indirectly introducing security and privacy vulnerabilities while manipulating traffic for financial gain ([VERIZON] and [COMCAST] are recent examples), to parties with direct intent to compromise security or privacy who are able to target individual users, organizations or even entire populations.
4.1. Is Document a sufficiently secure context?
Document document, this algorithm returns
Sufficiently Secure if the
Document represents a
sufficiently secure context or
While document corresponds to an iframe srcdoc
Document, let document be that Document’s browsing
context’s browsing context container’s
- Let origin be the origin of document.
If document’s active sandboxing flag set has its
sandboxed origin browsing context flag set:
- Set origin to the origin of document’s address.
- Let result be the result of executing the §4.2 Is settings object a sufficiently secure context? algorithm on document’s incumbent settings object.
If result is
If document has an embedding document, return the
result of executing §4.1
Is Document a sufficiently secure context?
document’s embedding document with the
ancestors flag set to
- Otherwise, return result.
- If document has an embedding document, return the result of executing §4.1 Is Document a sufficiently secure context? on document’s embedding document with the ancestors flag set to
Note: Sandboxed documents will have a unique origin. This algorithm uses the
location of a sandboxed document to determine whether it should be considered
authenticated. That is, the document inside
<iframe src="https://example.com/" sandbox="allow-script">
would be considered to allow powerful features.
Need to consider how contexts created from blob: and data: are treated here, e.g. when used to create a Worker or SharedWorker.
4.2. Is settings object a sufficiently secure context?
Given an settings object settings, this algorithm returns
Sufficiently Secure if the object represents a sufficiently
secure context, and
If settings' TLS state is
- Let origin be settings' origin.
If the result of executing the §4.3
Is origin potentially trustworthy?
on origin is
Potentially Trustworthy, return
4.3. Is origin potentially trustworthy?
Certain origins are always potentially trustworthy. In particular, UAs
file URLs and URLs with hostnames names equivalent
to "localhost" as potentially trustworthy. In principle the UA could treat
local files and local web servers as untrustworthy. However, given the
information that is available to the UA at runtime, the resources
appear to have been transported securely. Additionally, treating such
resources as potentially trustworthy is convenient for developers building
an application before deploying it to the public.
A user agent MAY choose to extend this trust to other, vendor-specific URL
Given an origin origin, the following algorithm returns
Potentially Trustworthy or
Not Trustworthy as
If origin is a potentially secure origin,
Note: The origin of
filesystem:URLs is the origin of the context in which they were created. Therefore, blobs created in an potentially secure origin will themselves be potentially secure. The origin of
hostcomponent is or falls within
hostcomponent matches one of the CIDR notations
schemecomponent is one which the user agent considers to be authenticated, return
Note: See §5.1 Packaged Applications for detail here.
If origin has been configured as a trustworthy origin,
Note: See §5.2 Development Environments for detail here.
5. Implementation Considerations
5.1. Packaged Applications
User agents that support packaged applications MAY whitelist specific URL
schemes whose contents are authenticated by the user agent. For example,
FirefoxOS application resources are referred to by a URL whose
scheme component is
app:. Likewise, Chrome’s
extensions and apps live on
chrome-extension: schemes. These
could reasonably be considered trusted origins.
5.2. Development Environments
In order to support developers who run staging servers on non-loopback hosts,
user agents MAY allow users to configure specific sets of origins as
trustworthy, even though §4.3
Is origin potentially trustworthy?
would normally return
This document is largely based on the Chrome Security team’s work on [POWERFUL-NEW-FEATURES]. Chris Palmer, Ryan Sleevi, and David Dorwin have been particularly engaged. Anne van Kesteren and Henri Sivonen have also provided very helpful feedback.