Hi all--Opt-in Spectre Mitigation Strategies
Charlie Reis, 5-2-2018
This document considers a few variations of opt-in approaches that sites could use to protect themselves from Spectre attacks, particularly in browsers that support cross-process navigations but not out-of-process iframes. The discussion below identifies challenges for many types of realistic sites (e.g., OAuth providers, maps, videos) where some form of embedding within untrusted pages seems to be a requirement.
Note that this document only focuses on the minimum required for mitigating Spectre, and not other potential benefits that might increase the likelihood that web developers will adopt the proposals. This can hopefully provide some baselines or ways to reason about improved proposals.
1. No cross-site iframes or embedding.
2. Cross-site iframes but no embedding.
3. Allow embedding in trusted pages.
4. Allow embedding in untrusted pages.
There are a few different categories of sites that are worth considering, since they face different tradeoffs for adopting opt-in Spectre mitigations:
I would argue that we should try to support even the hardest category, since it includes sites that arguably need the Spectre protections the most.
Consider an attacker on evil.com who wants to exfiltrate data from a.com using Spectre, by getting a.com's documents or resources to share a process with it. For the more interesting categories of sites above, assume that a.com chooses to embed iframes from b.com, and that it trusts c.com to embed it.
As noted above, the strategies considered here for mitigating Spectre assume that the browser can swap processes on top-level navigations (and ideally support postMessage between processes).
We are aiming for approaches that could upgrade gracefully if out-of-process iframe support is added to browsers, even if only used to isolate certain sites. The protection should further upgrade gracefully if all sites are isolated (as Chrome is attempting).
This section considers approaches that could work for each of the site categories described above.
In this simplest category, a.com could fully protect itself using a From-Origin: SameSite header on every resource. From-Origin would have the following effects on browser behavior:
There would be no concerns with broken iframe/popup scripting, because a.com can't embed cross-site iframes or be embedded by cross-site iframes. It is always safe to do a cross-process navigation when entering or leaving a.com.
Attacks:
The strategy above says to use From-Origin on all resources. Technically the header would only be needed on:
However, it seems hard to guarantee that an HTML document won't ever load sensitive data, and making exceptions might lead to tricky cases with same-origin frames living in different processes. Thus it seems strongly desirable to put the header on at least all HTML documents, plus all resources that have sensitive data. It should be safe to omit from subresources with no sensitive data (e.g., JavaScript, images, CSS, etc).
Supporting this category would be similar to the first strategy, although allowing trusted b.com iframes within a.com does complicate the process model. a.com would do all the same things as before, but now it embeds iframes to b.com.
Consider the following example: a user visits document B1 on b.com, and then B1 does a window.open to document A1 on a.com (which contains iframe B2). At this point B1 might try to synchronously script document B2 within the iframe of A1. Browsers would need to do a process swap when opening A1 in a new window since B1 is in an unrestricted process, but this would break same-origin scripting between B1 and B2.
To avoid this problem, we could consider using rniwa@'s proposed Cross-Origin-Isolate header for all of a.com's resources, such that B1 and B2 have no window references to each other. (For comparison, Chrome's implementation could support this by means of a "BrowsingInstance" swap.)
In the reverse direction, suppose the B2 iframe within A1 tries to open a popup to top-level page B3. b.com's pages have no Cross-Origin-Isolate headers, so B3 must stay in a.com's restricted process, allowing B2 and B3 to script each other. This is different behavior than above and seems acceptable, because we're starting from a restricted process and we already trust b.com not to run a Spectre attack.
In other words, restricted processes are somewhat "sticky." Browsers would do a process swap when entering a.com from a cross-site page and when navigating away, but not when a cross-site iframe within a.com opens a popup to its own site.
Otherwise, all the same properties from the first approach seem to apply.
If a.com has a trust relationship with c.com and wants to let c.com embed its pages as iframes, this would require a few extra steps:
Attacks:
This approach could be feasible to deploy if trust relationships existed with the sites a.com wants to be embedded within. Unfortunately, as noted above it seems unlikely this would work for OAuth providers or many other popular sites, which don't seem to have such trust relationships with embedders. (It may still be useful to build this support for sites that fall into this category and don't want the credential tradeoffs discussed below.)
It seems essentially impossible to let a.com load credentialed iframes within fully untrusted sites in browsers without out-of-process iframes, although this is what many sites expect today: OAuth providers, Google Maps, YouTube, etc. Allowing these sites to protect themselves from Spectre is challenging and may require some larger tradeoffs.
lukasza@ suggests an approach where a.com iframes could be allowed to load in untrusted pages without credentials. For example, the browser could request the a.com document as usual (with credentials) for an iframe on evil.com. If the response comes back with a From-Origin header excluding evil.com, then the browser realizes it can't deliver it to the unrestricted process as is. The browser would cancel and reissue the request without credentials, allowing the (hopefully) non-sensitive content within the iframe. This does not address attacks that use ambient authority (e.g., intranet URLs), but it would allow sites like Maps and YouTube to work with a slightly degraded experience (i.e., not logged in).
For OAuth providers, the non-credentialed iframe would try to open a popup to a.com to let the user log in. There are two ways this could be supported:
Since using non-credentialed iframes would be a degraded experience for a.com, it would be desirable to let browsers transparently upgrade to credentialed iframes as soon as they have support for out-of-process iframes. Such browsers would not need to give *all* sites dedicated processes. Instead, they would just give fully dedicated processes to sites that have From-Origin headers, using out-of-process iframes when needed. This keeps the expected process count low, relative to a "isolate all sites" policy. (This would be similar to Chrome's IsolateOrigins policy, but allow sites themselves to request dedicated processes.)
If a browser does choose to isolate all sites, then the From-Origin headers remain useful to identify which resources should be protected by CORB (beyond the ones that CORB tries to infer using HTML, XML, and JSON with nosniff or confirmation sniffing).
Other options?
Apart from non-credentialed iframes, it's unclear if there are other viable approaches for this category of sites. In theory sites like Google Maps or YouTube could try to load with credentials without bringing any sensitive info in the iframe (e.g., supporting a "Watch Later" link using HttpOnly cookies). It seems highly unlikely that they could avoid loading any sensitive info into the process, though, given the wide range of data that might leak (e.g., CSRF tokens).
The non-credentialed approach does have some parallels with the App Isolation paper, but even the App Isolation approach would let the user log in inside the untrusted app's process (with the same drawbacks as the doubly-keyed cookies approach).
It seems that a combination of From-Origin, CORB, top-level cross-process navigations, and non-credentialed iframes might make it possible to offer Spectre mitigations to most sites that need it. The main caveat is that sites would have to deal with non-credentialed iframes when loaded in pages they do not have trust relationships with, posing some functionality challenges.