blob: f68cf3368b40218e827e761e5b06b8811e12085b [file] [log] [blame] [view]
Dominick Ngf384207e2019-04-05 18:40:211# Controlling Access to Powerful Web Platform Features
2
Felipe Andrade239aaf3c2019-09-11 12:31:583_Author: [dominickn@chromium.org](mailto:dominickn@chromium.org)_
Dominick Ng0e7a62c2021-10-07 06:03:064_Contributors: [mgiuca@chromium.org](mailto:mgiuca@chromium.org), [rorymcclelland@chromium.org](mailto:rorymcclelland@chromium.org)_
Dominick Ngf384207e2019-04-05 18:40:215
6# Overview
7
8[Fugu](https://blog.chromium.org/2018/11/our-commitment-to-more-capable-web.html)
9 is a renewed effort to bring
10 [powerful new capabilities](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=Proj%3DFugu+&colspec=ID+Pri+M+Stars+ReleaseBlock+Component+Status+Owner+Summary+OS+Modified&x=m&y=releaseblock&cells=ids)
11to the web -- e.g. filesystem read/write access. Allowing users to control
12which sites are able to access such APIs is crucial for maintaining the
13security and privacy properties of the web. The impact of restrictions on the
14developer ergonomics and user utility of the API and the web platform overall
15must also be considered.
16
17This document explores approaches to guarding powerful APIs, e.g. using
18[installed web app state](https://developers.google.com/web/progressive-web-apps/)
19or some other proxy for high user
20[engagement](https://www.chromium.org/developers/design-documents/site-engagement).
21The following general principles summarise the overall approach of the
22Chromium project to evaluating how powerful new features should be controlled
23on the web:
24
25+ __Access to powerful APIs__ should be available to the entire web platform
26 of secure contexts, with control managed exclusively by choosers, prompts,
27 or other user consent UX at time-of-use.
28+ __API-specific restrictions__ on the scope of access may also be used to
29 guard against potential abuse (e.g. constraints on available directories /
30 files, no access without a currently open foreground tab).
31+ Usage of powerful APIs should be clearly __disclosed__ to users, ideally
32 using a central hub that offers users __control__ over what sites can use
33 which capabilities.
34+ Installing a web app is associated with __persistence__, and thus
35 persistent and/or background access to powerful APIs may only be granted
36 (possibly subject to additional requirements) to installed web apps.
37 Non-installed sites may still request and be granted permission to use
38 powerful APIs, but should not have their access persisted.
39+ Installation or engagement alone __should not act as a vote of trust__ for
40 either granting access or enabling the ability to ask for access to
41 powerful APIs.
42+ Separately, efforts should be made to __curtail the existing persistency__
43 on the web platform outside of installed web apps, e.g. time-limiting
44 permission grants, more aggressively expiring cookies, and restricting
45 background task execution.
46
47The remainder of this document explains the reasoning behind these principles,
48and summarises why alternative proposals were not taken up.
49
50# Definition of Terms
51
52+ [__Powerful Web Platform APIs__](https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features)
53 are capabilities which carry inherent security or privacy risks when used,
54 but also provide users of web apps with significant utility. A canonical
Austin Sullivan670e9262021-01-26 21:56:5255 example is local file system access (i.e. allowing web sites to directly
Dominick Ngf384207e2019-04-05 18:40:2156 read and write from certain locations on the user's device). Many such
57 capabilities already exist on the web in every browser (e.g. access to
58 camera and microphone hardware), while new capabilities are under constant
59 development.
60+ [__Installation__](https://www.w3.org/TR/appmanifest/#installable-web-applications)
61 is the process where a web site may be elevated to run with a more native
62 UX treatment on a given platform and device. It is usually tied with being
63 granted a presence in the platform launcher (e.g. the desktop).
64+ [__Progressive Web Apps__](https://developers.google.com/web/progressive-web-apps/)
65 (PWAs) are web sites which are designed to be installable.
66+ [__Engagement__](https://www.chromium.org/developers/design-documents/site-engagement)
67 is a mechanism for measuring how much users interact with a site. Higher
68 engagement may be a signal that the user derives significant utility from
69 a site.
70
71
72# Principles for Access to Powerful APIs
73
74This section outlines the general principles that the Chromium team believes
75are critical when designing access to powerful new web platform APIs. These
76principles will be considered when evaluating how new APIs are designed.
77
78## Control and Transparency
79
80+ Users must be able to see when the powerful APIs in use, and what sites
81 are using them.
82+ Users may revoke access to powerful APIs at any time, and preferably,
83 the revocation UI should be intuitive to locate based on how permission is
84 granted and/or disclosed to the user.
85+ The principle of least privilege should apply as broadly as possible:
86 users should not have to grant access to more resources than necessary to
87 achieve their goals.
88
89## User Ergonomics
90
91+ The web platform should be fully functional without requiring
92 installation.
93+ Sites must not be able to easily socially-engineer the user into
94 granting permissions they wouldn't otherwise want to.
95+ As much as is practical, users should not be bombarded with permission
96 prompts, as this leads to decision fatigue.
97
98## Developer Predictability
99
100+ Developers must be able to know when they can and cannot access
101 powerful APIs.
102+ Access mechanisms should be cross-browser compatible.
103
104# Proposal
105
106### Baseline: secure contexts, top-level frames, user gesture
107
108Minimally, all new powerful APIs must only be available in
109[secure contexts](https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins).
110Ideally, availability is restricted to top-level frames and requires a user
111gesture to trigger. When a webpage is running in a secure context in
112a top-level frame with an active user gesture, we call this situation
113a __baseline context__.
114
115[Browser extensions](https://developer.chrome.com/extensions) are also
116included as a baseline context, as they can already make use of web platform
117APIs (subject to the same access checks as web sites).
118
119The
120[permission delegation](https://docs.google.com/document/d/1x5QejvpyQ71LPWhMLsaM1lWCfSsBsSQ8Dap9kJ6uLv0/preview?ts=5b857603#heading=h.ib6rctasbt3y)
121mechanism may be used to extend privileges to iframes on a page if it makes
122sense for a powerful capability to be delegated in this way.
123
124### The entire web platform may access new powerful APIs
125
126In general, any baseline context may access powerful APIs, regardless of its
127windowing state (in the tabbed browser or in a standalone app window),
128installation state (installed or not), or user engagement (highly interacted
129with or not). This avoids the __fragmentation of the web__ into different,
130sometimes unpredictable states, and encourages careful consideration of new
131API surfaces such that they are exposed in a way that is safe for the web at
132large.
133
134### Session-based access is granted by direct user consent
135
136In general, access to powerful APIs must be mediated by direct, informed user
137consent while the requesting site is open in a foreground tab via mechanisms
138which may include:
139
140+ choosers
141+ prompts
142
143These mechanisms must clearly disclose the origin of the request, and follow
144Chromium's
John Palmer046f9872021-05-24 01:24:56145[guidelines on displaying URLs](https://chromium.googlesource.com/chromium/src/+/main/docs/security/url_display_guidelines/url_display_guidelines.md).
Dominick Ngf384207e2019-04-05 18:40:21146Implementations may be tested using tools such as
147[Trickuri](https://github.com/chromium/trickuri).
148
149As much as possible, APIs should avoid a "double prompt", e.g. a permission
150prompt requesting access to the file system, followed by a chooser to pick the
151file/directory to access. There is little security or privacy benefit to such
152a double prompt, and it detrimentally affects user and developer ergonomics.
153
154There are cases where double prompts are unavoidable, e.g. a web site may
155request access to contact information, and if the user grants access, the
156browser may need to request OS-level permission to service the request.
157
158In some cases, Chromium may implicitly grant access to an API if it is not
159particularly dangerous or does not make sense to guard behind a permission
160consent. An example of this is the
161[Badging API](https://github.com/WICG/badging/blob/master/explainer.md), which
162only works for installed web apps, and results in a subtle badging effect on
163the installed app icon that is not invasive or privacy-sensitive. These cases
164should be relatively rare considering the powerful APIs that are covered by
165this document.
166
167The scope of access to APIs follows the web's same-origin model.
168
169### Persistent and/or background access is restricted to installed apps
170
171The only definite capability granted by installation is __persistence__. By
172installing, the user has explicitly indicated that they want the web app to
173have a persistent presence on their system.
174
175New powerful APIs should exclusively use session-based permissions for web
176sites that are not installed. In particular, there should be no access while
177the site is not open in a tab, and access cannot be requested from a
178non-foreground tab. When the site is closed or navigated away from, it loses
179any granted access to powerful APIs it had, and must re-ask for access the
180next time the user visits.
181
182Installed web sites _may_ instead receive a permanent grant, which is removed
183when the site is uninstalled. In this way, installed web sites _may_ be
184granted the ability to access capabilities in the background, depending on the
185particular details of each capability. It also avoids overloading the
186installation decision with consequences that users may not expect.
187
188Persistency for installed web sites may have other requirements, but
189non-installed sites may never receive persistent grants to access powerful new
190APIs.
191
192Some powerful APIs act as a proxy for persistence (e.g. a web site with
193permission to write files to disk). We distinguish persistence via a currently
194granted capability from __persistent access to the capability itself__; it is
195the latter privilege which is granted by being installed.
196
197### Disclose access and provide obvious user controls
198
199It should be obvious to users when sites are using powerful APIs, and they
200should be given the tools needed to effectively manage and revoke access when
201necessary.
202
203### Improve permissions and installation UX to avoid decision fatigue
204
205Removing persistent access from the drive-by web may drive up
206[decision fatigue](https://en.wikipedia.org/wiki/Decision_fatigue) due to
207overprompting. However, we anticipate that many of these capabilities will
208have relatively niche applications that the drive-by web should not commonly
209access.
210
211Repeated granting of access to powerful APIs can be used as a signal for
212installation. For instance, after two successful powerful permission grants,
213Chromium could present the user with the option to install the app on the
214third permission request.
215
216### Administrator policies may override prompts and enforce persistence
217
218Powerful new capabilities may be paired with
Felipe Andrade239aaf3c2019-09-11 12:31:58219[Chromium policies](https://cloud.google.com/docs/chrome-enterprise/policies)
Dominick Ngf384207e2019-04-05 18:40:21220which permit administrators to enforce persisted access to capabilities
221without prompts. Capabilities may also be restricted or blocked by such
222policies. This is in line with how many existing permissions have admin policy
223overrides.
224
225### Explore ways of curtailing the lifetime of existing persistence
226
227Currently, web sites which are not installed have access to significant
228persistence mechanisms:
229
230+ all existing permissions have their decisions persisted indefinitely
231+ cookie and local storage lifetime may be indefinite
232
233To better align the existing web to the proposal presented here, we suggest a
234parallel effort to apply new lifetime limits on existing persistence
235mechanisms. For example, some of the following measures could be explored:
236
237+ forget any granted permissions if the site has not been visited in X weeks
238 + this could be challenging to apply for some capabilities such as push
239 notifications, where there is a use case for a site being able to send
240 informative notifications without ever needing to be opened.
241+ ignore cookie Max-Age headers for non-installed sites, and erase cookies
242 when the associated URL is no longer in browser history.
243+ restrict durable/persistent storage to installed apps.
244+ limit the storage quota available to sites unless they are installed (and
245 conversely, raise storage quota limits for installed sites).
246+ restrict what Service Workers may do in the background unless they control
247 a site that is installed.
248
Austin Sullivan670e9262021-01-26 21:56:52249# Case Study -- File System Access
Dominick Ngf384207e2019-04-05 18:40:21250
251We describe a high level case study based on the principles in this document
252for granting a web site access to a) read any file in a certain directory; b)
253write files to a directory.
254
255## Granting access
256
257+ The user must give direct consent via a file picker.
258+ The browser should disclose that access to the chosen file or directory
259 will be granted to the web site.
260+ A non-installed site will trigger the picker each page load that the API
261 to read or write to a directory is invoked.
262+ An installed site will have its access to reading or writing persisted.
263
264## Additional considerations for writing to a directory
265
266+ Existing Downloads UI and protections (e.g. malicious file scanning)
267 could be employed to ensure sites cannot use writing to a directory as a
268 bypass.
269+ Where such scanning isn't accessible, confirmation prompts for opening
270 dangerous files in the Downloads UI may be employed instead to ensure the
271 user knows if a potentially malicious file type is being stored.
272+ Non-installed sites may have additional restrictions on which folders
273 are available to choose (e.g. only allowing the user's Downloads directory,
274 or excluding the user's Documents directory).
275
276# Alternatives Considered
277
278## Guard API Access Behind Installation
279
280Apps on any desktop or mobile platform require installation to run, and when
281installed, apps are automatically granted many privileges. We could extend
Austin Sullivan670e9262021-01-26 21:56:52282this concept to the web by restricting powerful APIs like the File System
283Access API only to installed web apps. That is, the drive-by web could not even
Dominick Ngf384207e2019-04-05 18:40:21284ask for permission to access an API -- the site would need to be installed.
285
286A key argument for using installation in this manner is that some APIs are
287simply so powerful that the drive-by web should not be able to ask for them.
288However, this document takes the position that installation alone as a
289restriction is undesirable.
290
291### Pros:
292
293+ This is a simple model that is both user controllable and
294 developer-accessible (via installation APIs such as
295 [beforeinstallpromptevent](https://developers.google.com/web/fundamentals/app-install-banners/)).
296+ Installation is already synonymous with some amount of elevated privilege
297 on most platforms.
298
299### Cons:
300
301+ Fragments the web platform into installed and not installed, with
302 different APIs available depending on installed state.
303+ Disempowers the drive-by web, and undermines the "try-before-you-buy"
304 ability that the web affords today. Users may also not be willing to
305 install a site from which they cannot ascertain any benefit.
306+ Forces users to install a site to use it, even if they don't want to
307 install.
308+ May encourage web sites to prompt users on every visit to install the PWA
309 to get access to powerful features.
310+ Creates confusing scenarios when web apps are running in tabs:
311 + If a web app is installed but the user opens the site in a
312 tab, does it get access to the capability or not?
313 + What about if the web app starts off in a standalone window, but
314 the user reparents it into a tab? Or if a user sets an installed app to
315 open in a tab?
316+ Platforms where installation grants privilege all incur additional
317 friction during installation that the web currently does not exhibit.
318 Examples include:
319 + requiring something to be downloaded,
320 + requiring a confirmation prompt, installer, or some explicit
321 privilege or grant during installation,
322 + requiring an explicit display of permissions that are implicitly
323 granted.
324+ The implicit granting of privilege by installation has proven to be a
325 security and privacy challenge on many platforms, e.g. Android native apps
326 can access many
327 [powerful features](https://developer.android.com/guide/topics/permissions/overview#normal-dangerous)
328 with no permission prompt and without user recourse to revoke access.
329+ The amount of friction generated by PWA installation over the drive-by
330 web is unclear, and gating APIs behind installation increases the
331 incentive for tricking users into installing.
332
333### Security considerations:
334
335Restricting APIs to installed web apps is not a meaningful security improvement
336for users for several reasons:
337
338+ While it eliminates the drive-by web as an attack surface, per-API
339 security mitigations (e.g. restricting which directories are accessible
340 for reading and writing) would still be necessary to protect users of
341 installed web apps.
342+ The effectiveness of installation as a gate on access to powerful APIs
343 weakens as the installed web app model becomes more successful.
344+ Developers are incentivised to ask for installation to utilise powerful
345 capabilities, contributing to the erosion of installation as an effective
346 security mitigation.
347+ Per-API permission requests would still be necessary in the installed
348 state, making installation effectively equivalent to an implicit permission
349 grant to ask for permission to access powerful features. We should simply
350 ask users directly if they wish to grant permission, rather than use such a
351 two-tiered requirement.
352
353## Guard API Access Behind Engagement
354
355This is a more general concept than installation: that continual, significant
356usage of a web site should allow that site to access more powerful APIs.
357
358### Pros:
359
360+ Continual usage of a web site can be taken as a signal of trust
361
362### Cons:
363
364+ Engagement is not standardised or exposed to the web platform, making
365 it a highly unpredictable and unergonomic mechanism of controlling access.
366 + Standardisation and a web-exposed API would both be requirements for
367 using engagement in this way. Chromium's current engagement
368 implementation is local-only and not web-exposed. There are serious
369 privacy questions about exposing such data to the web.
370+ Solving the first-run problem is non-trivial: engagement requires usage
371 to accumulate, but there are apps which legitimately require access to a
372 powerful API immediately to function (e.g. an editor -> files, or a
373 weather site -> location).
374
375### Security considerations:
376
377+ There is no real evidence to support the implicit assumption under
378 this model that continual usage of a web site correlates with user consent
379 to access powerful features.
380 + Consider users who frequently use some web site for which location
381 data is useful, but denies that site persistent, background access to
382 geolocation permission.
383 + A proportion of web traffic goes to sites which users may interact
384 with frequently, but may not necessarily want to grant powerful
385 capabilities.
386
387Similar to installation, the Chromium team does not regard engagement as a
388robust way of controlling access to APIs.