blob: d32276e3028cc1cf130c0ff1a66f74ad6f5cd690 [file] [log] [blame] [view]
Adrian Taylor094e3dd2021-05-04 17:09:061# The browser process should not handle messages from web content
2
3Sometimes features are proposed in which the Chrome user interface (in the
4browser process) handles messages directly from web content (JavaScript, HTML
5etc.). For example, this could be done using the `postMessage` APIs which have
6been put in place for Android WebView apps. This is not allowed, because:
7
8* Overall system security relies on simple and predictable security properties.
9 Adding extra message channels causes complexity, non-discoverability and
10 non-predictability.
11* Chrome's security strategy relies on isolating web content using sandboxed
12 renderer processes and site isolation. Any communication outside of that
13 renderer process presents a risk of a sandbox escape. All such communication
14 has to be via Mojo such that the `mojom` interface definition files go through
15 our [IPC security review process](mojo.md) (and will benefit from other future
16 Mojo security improvements).
Adrian Taylor0933042b2021-05-04 20:59:0717* Websites are untrustworthy. TLS can’t guarantee the provenance of a website —
Adrian Taylor094e3dd2021-05-04 17:09:0618 even pinning has limits — and so you must assume any messages from websites
19 are malicious. Processing such messages in the browser process in C++ is
20 likely a violation of the [Rule of Two](rule-of-2.md) and is extremely
21 dangerous.
22* Even if you can comply with the Rule of Two (for example by using a safe
23 language) it's simply difficult to produce robust APIs that are safe against
Adrian Taylor0933042b2021-05-04 20:59:0724 malicious data: the open web platform [API review
25 process](https://www.chromium.org/blink/launching-features) is designed to
26 flush out any concerns. Any APIs or functionality accessible to web content
Adrian Taylor094e3dd2021-05-04 17:09:0627 therefore needs to go via that process to give the best chance of spotting
28 danger.
29* There are non-security concerns: It does not comply with the spirit of an open
30 web platform which should be equally available on all user agents.
31
Adrian Taylor094e3dd2021-05-04 17:09:0632In order to support WebView, WebLayer, and CCT, APIs exist in Chrome to
33establish web message channels between the embedding application and web page.
34These exist only to support these "embedding the web" scenarios, which are often
35used to build site- or purpose-specific browsers. General browser features
36should not use them because of the reasons stated above.
37
Adrian Taylor0933042b2021-05-04 20:59:0738Other mechanisms of bypassing normal processes might include exposing unreviewed
39APIs to a component extension, and making its APIs available to web content.
40These are similarly not allowed.