Adrian Taylor | 1bbbf14 | 2023-08-29 17:41:17 | [diff] [blame] | 1 | # 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 |
| 6 | security features available in modern |
| 7 | browsers.](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 | |
| 11 | Chrome Custom Tabs (CCT), and Custom Tabs (CT) more generally, allow |
| 12 | Android app developers to use the user's default browser to |
| 13 | serve embedded web content in their apps. |
| 14 | |
| 15 | CT, unlike Android's WebView API, share the same browser state (such as |
| 16 | cookies) with the browser app. Chromium therefore imposes a strict boundary |
| 17 | between the embedding app and the browsing engine, and the app can normally |
| 18 | only get very limited access to web page data and state. |
| 19 | |
Adrian Taylor | 828b582 | 2023-08-29 21:21:18 | [diff] [blame] | 20 | All considered, there are four parties to consider when evaluating Custom Tabs: |
| 21 | the user, the embedding app, the web publisher, and the browser. The native |
Adrian Taylor | 1bbbf14 | 2023-08-29 17:41:17 | [diff] [blame] | 22 | app chooses how they want to bring the web in their app, and users choose which |
| 23 | apps to install and use. |
| 24 | |
| 25 | Given 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 |
| 27 | they happen upon in their browser), we accept some data exchange between Chrome |
| 28 | and the underlying app. This is intentional because we believe this |
| 29 | incentivizes apps to use CT rather than WebView, which was [never designed as a |
| 30 | full 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 | |
| 34 | 1. **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 | |
| 43 | 2. **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 | |
| 49 | 3. **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 | |
| 61 | 1. **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 | |
| 73 | 2. **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 | |
| 95 | Any future access would require explicit permissions to be accepted. |