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