blob: 8cea6c15e0bbbff4d40d1cba1148fc97835b9aa7 [file] [log] [blame] [view]
Adrian Taylor1bbbf142023-08-29 17:41:171# Chrome Custom Tabs Security FAQ
2
3## Should apps use WebView when building a browser?
4
5[No, WebView is not intended as a framework for building browsers, and lacks
6security features available in modern
7browsers.](https://web.dev/web-on-android/#security-considerations-for-using-webview-as-an-in-app-browser)
8
9## What is the security model for Chrome Custom Tabs?
10
11Chrome Custom Tabs (CCT), and Custom Tabs (CT) more generally, allow
12Android app developers to use the user's default browser to
13serve embedded web content in their apps.
14
15CT, unlike Android's WebView API, share the same browser state (such as
16cookies) with the browser app. Chromium therefore imposes a strict boundary
17between the embedding app and the browsing engine, and the app can normally
18only get very limited access to web page data and state.
19
Adrian Taylor828b5822023-08-29 21:21:1820All considered, there are four parties to consider when evaluating Custom Tabs:
21the user, the embedding app, the web publisher, and the browser. The native
Adrian Taylor1bbbf142023-08-29 17:41:1722app chooses how they want to bring the web in their app, and users choose which
23apps to install and use.
24
25Given this distinct trust relationship between the embedding app and the user
26(which is in general a higher degree of trust than between users and websites
27they happen upon in their browser), we accept some data exchange between Chrome
28and the underlying app. This is intentional because we believe this
29incentivizes apps to use CT rather than WebView, which was [never designed as a
30full browser embedding API and has a number of security shortcomings](https://web.dev/web-on-android/#security-considerations-for-using-webview-as-an-in-app-browser).
31
32## What data does Chrome consider permissible for the embedder to have access to?
33
341. **CCT session specific signals can be shared back to the embedder without user
35 action.** Session specific signals are low-entropy signals about the user's
36 interaction with the tab or page that do not reveal information about the
37 content or identity of the page. Examples of session specific signals include
38 [Custom Tab callbacks](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback) and [engagement signals](https://developer.chrome.com/docs/android/custom-tabs/guide-engagement-signals/). Session specific signals are
39 designed to avoid malicious actors inferring details about the content or the
40 state of the web page. As such, engagement signals are disabled in some
41 circumstances, such as when pages are opened using [text fragments](https://web.dev/text-fragments/#text-fragments).
42
432. **Current page URL can be shared with the embedder with explicit user action.**
44 When a user taps on an embedding app action in CCT, the embedding application
45 can see the full URL and origin of the currently visited page. In some instances,
46 verifiable Google app entities can access the current page URL without user
47 intent.
48
493. **Developers can send and receive messages as if they were a website which they
50 can prove they control.** The postMessage API can be used by developers to
51 establish a 2-way communication channel between the main frame inside the
52 Chrome Custom Tab. For non-verifiable Google entities, this functionality is
53 only supported if a [Digital Asset Link](https://developers.google.com/digital-asset-links)
54 relationship has been established between a website and the embedding app.
55 The website is then used as the origin
56 for the [`window.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage)
57 Web API, which enables cross-origin communication.
58
59## How else might an embedder appear to interact with web content?
60
611. **The app may be able to draw over parts of the Chrome browser UI or the website.**
62 Unlike the Chrome browser app which is always displayed in its own Android
63 Task, Custom Tabs are most commonly displayed in the same Android Task as the
64 embedding app. This makes Custom Tabs susceptible to certain tap jacking and
65 phishing attacks. For example, a malicious actor could launch an
66 Activity positioned over the web content or CT toolbar and draw UI to steal a
67 password. The presence of pre-existing browser state and cookies may make the
68 embedded web experience appear more trustworthy and therefore increase the
69 likelihood of the phishing attack succeeding. Note that Android has been
70 pursuing protections within the OS to mitigate against some attacks, and Chrome will
71 continue to work with Android to protect users on older OS versions.
72
732. **Developers can add app specific actions into CCT**. Chrome provides customization
74 options to embedding apps. The appearance of the bottom toolbar and its
75 contents can be customized and can change during runtime. While this UI surface
76 could be used for malicious purposes, we accept this risk because, overall, CCT
77 has better security properties than WebView, and a high level of UI
78 customisability is necessary to drive Custom Tab adoption. Furthermore, the
79 space that can be occupied by the bottom toolbar is limited and the position is
80 fixed, lowering the risk that users will fall for attacks launched from this
81 surface.
82
83## What data does an embedder not have access to?
84
85**Embedders cannot access data unrelated to the CCT session**. This includes:
86
87* history from past sessions
88* cookies
89* passwords
90* full DOM access
91* arbitrary script injection
92* network request interception
93* etc.
94
95Any future access would require explicit permissions to be accepted.