blob: e7cd3a12b6536c402a4a8207a563931a55182918 [file] [log] [blame] [view]
Lukasz Anforowicz11dbb06d2020-05-12 00:14:341# Threat Model And Defenses Against Compromised Renderers
Lukasz Anforowiczf4e58ce2020-05-11 18:18:582
3Given the complexity of the browser, our threat model must use a "defense
4in depth" approach to limit the damage that occurs if an attacker
5finds a way around the Same Origin Policy or other security logic in the
6renderer process.
7For example, the combination of Chrome's sandbox, IPC security checks, and Site
8Isolation limit what an untrustworthy renderer process can do. They
9protect Chrome users against attackers, even when such attackers are able to
10bypass security logic in the renderer process.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3411For other arguments for the "defense in depth" approach and why our
12threat model covers compromised renderers, please see
13[the Site Isolation motivation](https://www.chromium.org/Home/chromium-security/site-isolation#TOC-Motivation).
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5814
15In a compromised renderer, an attacker is able to execute
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3416arbitrary native (i.e. non-JavaScript) code within the renderer
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5817process's sandbox. A compromised renderer can forge
18malicious IPC messages, impersonate a Chrome Extension content script,
19or use other techniques to trick more privileged parts of the browser.
20
21The document below gives an overview of features that Chrome attempts to
22protect against attacks from a compromised renderer. Newly discovered
23holes in this protection would be considered security bugs and possibly
24eligible for the
25[Chrome Vulnerability Rewards Program](https://www.google.com/about/appsecurity/chrome-rewards/).
26
27[TOC]
28
29
30## Site Isolation foundations
31
32Most of the other protections listed in this document implicitly assume that
33attacker-controlled execution contexts (e.g. HTML documents or service workers)
34are hosted in a separate renderer process from other, victim contexts.
35This separation is called
36[Site Isolation](https://www.chromium.org/Home/chromium-security/site-isolation)
37and allows the privileged browser
38process to restrict what origins a renderer process is authorized to read or
39control.
40
41The privilege restriction can be implemented in various ways - see the
42"protection techniques" listed in other sections in this document.
43One example is validating in the browser process whether an incoming IPC can
44legitimately claim authority over a given origin (e.g. by checking via
45`CanAccessDataForOrigin` if the process lock matches).
46Another example is making sure that capabilities handed over to renderer
Lukasz Anforowiczdcd286f2020-08-18 22:16:3147processes are origin-bound (e.g. by setting `request_initiator_origin_lock`
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5848on a `URLLoaderFactory` given to renderer processes).
49Yet another example is making security decisions based on trustworthy knowledge,
50calculated within the privileged browser process (e.g. using
51`RenderFrameHost::GetLastCommittedOrigin()`).
52
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3453Compromised renderers shouldnt be able to commit an execution context
54(e.g. commit a navigation to a HTML document, or create a service worker)
55in a renderer process hosting other, cross-site execution contexts.
56On desktop platforms all sites (site = scheme plus eTLD+1) should be isolated
57from each other.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5858On Android, sites where the user entered a password should be isolated
59from each other and from other sites.
60
61**Known gaps in protection**:
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3462- No form of Site Isolation is active in Android WebView.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5863 See also https://crbug.com/769449.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5864- Frames with `<iframe sandbox>` attribute are not isolated
65 from their non-opaque precursor origin.
66 See also https://crbug.com/510122.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3467- `file:` frames may share a process with other `file:` frames.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5868 See also https://crbug.com/780770.
69
70
71## Cross-Origin HTTP resources
72
73Compromised renderers shouldn't be able to read the contents (header + body) of
74a cross-site HTTP response, unless it is a valid subresource needed for
75compatibility (e.g., JavaScript, images, etc), or is successfully allowed via
76CORS.
77
78Protection techniques:
79- Enforcing
80 [Cross-Origin Read Blocking
81 (CORB)](https://www.chromium.org/Home/chromium-security/corb-for-developers)
82 in the NetworkService process
83 (i.e. before the HTTP response is handed out to the renderer process).
84- Only allowing the privileged browser process to create
85 `network::mojom::URLLoaderFactory` objects that handle HTTP requests.
86 This lets the browser process carefully control security-sensitive
87 `network::mojom::URLLoaderFactoryParams` of such factories (such as
Daniel Vogelheimbe92f4cc2024-02-14 10:03:3388 `request_initiator_origin_lock`, `is_orb_enabled`, `disable_web_security` or
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5889 `isolation_info`).
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5890
91**Known gaps in protection**:
92- Content types for which CORB does not apply
93 (e.g. `image/png`, `application/octet-stream`) are not protected by
94 default. We recommend that HTTP servers protect such resources by
95 either serving a `Cross-Origin-Resource-Policy: same-origin` response header
96 or validating the `Sec-Fetch-Site` request header.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5897
98
99## Contents of cross-site frames
100
101Compromised renderers shouldn't be able to read the contents of cross-site
102frames. Examples:
103- Text or pixels of cross-site frames.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34104- Full URL (e.g. URL path or query) of cross-site frames.
105 Note that the origin of other frames
106 needs to be exposed via `window.origin` for legacy reasons.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58107
108Protection techniques:
109- Compositing tab contents (both for display and for printing)
110 outside the renderer processes.
111- Isolating PDF plugins.
112- Being careful what URLs are exposed in console messages.
113
114**Known gaps in protection**:
115- Mixed content console messages may disclose cross-site URLs
116 (see also https://crbug.com/726178).
117
118
119## Cookies
120
121Compromised renderers shouldnt be able to read or write
122any cookies of another site,
123or `httpOnly` cookies even from the same site.
124
125Protection techniques:
126- Renderer processes are only given `network::mojom::RestrictedCookieManager`
127 for origins within their site
128 (see `StoragePartitionImpl::CreateRestrictedCookieManager`).
129- Mojo serialization does not send any cookies from HTTP headers to the renderer
130 process (see
131 `ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write`).
132
133
134## Passwords
135
136Compromised renderers shouldnt be able to read or write passwords of
137other sites.
138
139Protection techniques:
140- Using `CanAccessDataForOrigin` to verify IPCs sent by a renderer process
141 (e.g. `//components/password_manager/content/browser/bad_message.cc`)
142- Using trustworthy, browser-side knowledge
143 to determine which credentials to read or write
144 (e.g. `content::RenderFrameHost::GetLastCommittedURL` in
145 `password_manager::CredentialManagerImpl::GetOrigin`).
146
147
148## Security-sensitive UI/chrome elements (e.g. Omnibox)
149
150Compromised renderers shouldnt be able to influence/spoof
151security-sensitive UI elements.
152
153Examples:
154- Omnibox
155 - URL (e.g. renderer process locked to foo.com shouldnt
156 be able to trick the Omnibox into displaying bar.com)
157 - Secure / not secure chip (e.g. a renderer process locked to a HTTP
158 site shouldnt be able to trick the Omnibox into displaying a
159 HTTPS-associated lock)
160 - Content settings (e.g. a renderer process that has been granted
161 microphone access shouldnt be able to suppress the mic/camera
162 icon in the Omnibox)
163- Dialogs and prompts (for example a permissions dialog asking to allow
164 a site to show notifications)
165 - Origin in dialogs (e.g. a renderer process locked to foo.com
166 shouldnt be able to trick the Omnibox into displaying a bar.com
167 URL in permission dialogs)
168
169Protection techniques:
170- `RenderFrameHostImpl::CanCommitOriginAndUrl` verifies that the renderer
171 process is able to commit what it claims, and kills the process otherwise.
172- Work-in-progress: calculating the origin in the browser process,
173 before a navigation commits (https://crbug.com/888079).
174
175
176## Permissions
177
178Compromised renderers shouldnt be able to gain permissions without user
179consent.
180
181Examples: microphone access permission, geolocation permission, etc.
182
183Protection techniques:
184- Requesting permissions based on browser-side knowledge of frame's origin
185 (e.g. see `GeolocationServiceImplContext::RequestPermission`).
186
187
188## Web storage
189
190Compromised renderers shouldn’t be able to read from or write into
191storage of another site.
192
193Examples of protected storage technologies:
194- localStorage
195- sessionStorage
196- indexedDB
197- blob storage
198- webSQL
199
200Protection techniques:
Lukasz Anforowicz482366732020-05-12 01:34:54201- Using `CanAccessDataForOrigin` to verify IPCs sent by a renderer process
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58202 (e.g. see `StoragePartitionImpl::OpenLocalStorage`).
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34203- Binding Mojo interfaces to a single origin obtained from browser-side
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58204 information in `RenderFrameHost::GetLastCommittedOrigin()`
Lukasz Anforowicz482366732020-05-12 01:34:54205 (e.g. see `RenderFrameHostImpl::CreateIDBFactory`).
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58206
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58207
208## Messaging
209
210Compromised renderers shouldn’t be able to:
211- Spoof the `MessageEvent.origin` seen by a recipient of a `postMessage`.
212- Bypass enforcement of the `targetOrigin` argument of `postMessage`.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34213- Send or receive `BroadcastChannel` messages for another origin.
Lukasz Anforowicz288f8302022-10-28 01:32:24214- Spoof the `MessageSender.url`, nor `MessageSender.origin`, nor
215 `MessageSender.id` (i.e. an extension id which can differ from the origin when
216 the message is sent from a content script), as seen by a recipient of a
Lukasz Anforowiczcc9524172022-08-24 18:31:20217 `chrome.runtime.sendMessage`.
218 See also [MessageSender documentation](https://developers.chrome.com/extensions/runtime#type-MessageSender) and [content script security guidance](https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/0ei-UCHNm34).
Lukasz Anforowicz67c9cbc2022-08-30 19:18:15219- Spoof the id of a Chrome extension initiating
220 [native messaging](https://developer.chrome.com/docs/apps/nativeMessaging/)
221 communication.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58222
223Protection techniques:
Lukasz Anforowicz482366732020-05-12 01:34:54224- Using `CanAccessDataForOrigin` to verify IPCs sent by a renderer process
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58225 (e.g. in `RenderFrameProxyHost::OnRouteMessageEvent` or
226 `BroadcastChannelProvider::ConnectToChannel`).
Lukasz Anforowicz67c9cbc2022-08-30 19:18:15227- Using `ContentScriptTracker` to check if IPCs from a given renderer process
228 can legitimately claim to act on behalf content scripts of a given extension.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58229
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58230
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34231## JavaScript code cache
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58232
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34233Compromised renderers shouldn't be able to poison the JavaScript code cache
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58234used by scripts executed in cross-site execution contexts.
235
236Protection techniques:
Lukasz Anforowicza288a132020-05-19 17:18:22237- Using trustworthy, browser-side origin lock while writing to and fetching from
238 the code cache by using `ChildProcessSecurityPolicyImpl::GetOriginLock` in
239 `GetSecondaryKeyForCodeCache` in
240 `//content/browser/renderer_host/code_cache_host_impl.cc`
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58241
242
243## Cross-Origin-Resource-Policy response header
244
245A compromised renderer shouldnt be able to bypass
Lukasz Anforowicz482366732020-05-12 01:34:54246[Cross-Origin-Resource-Policy (CORP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-Origin_Resource_Policy_%28CORP%29),
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58247which prevents or allows responses from being requested cross-origin, more
248explicitly than CORB.
249
250Protection techniques:
251- Enforcing Cross-Origin-Resource-Policy in the NetworkService process
252 (i.e. before the HTTP response is handed out to the renderer process).
253- Preventing spoofing of `network::ResourceRequest::request_initiator`
Lukasz Anforowiczbc9875032021-06-24 18:37:42254 by comparing against `request_initiator_origin_lock` in
255 `network::CorsURLLoaderFactory::IsValidRequest`.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58256
257
258## Frame-ancestors CSP and X-Frame-Options response headers
259
260A compromised renderer shouldnt be able to bypass `X-Frame-Options`
261or `frame-ancestors` CSP.
262
263For example, if example.com/page.html sends a `X-Frame-Options: deny` header,
264then it should never commit in a subframe, even if some renderers have
265been compromised.
266
267Protection techniques:
268- `X-Frame-Options: deny` is enforced in the browser process
269 via `content::AncestorThrottle`, an implementation of
270 `content::NavigationThrottle`.
271- `frame-ancestors` is enforced in a renderer process, but
272 this process is considered trustworthy in this scenario
273 (because it hosts the frame that is requesting protection).
274 See also https://crbug.com/759184 which tracks
275 moving this enforcement into the browser process.
276
277
278## HTTP request headers
279
280Compromised renderers shouldnt be able to control security sensitive HTTP
Lukasz Anforowicz17373d72021-06-28 23:19:58281request headers like `Host`, `Origin`, or `Sec-Fetch-Site`.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58282
283Protection techniques:
284- Using `AreRequestHeadersSafe` to reject `Host` and other headers that
285 should only be generated internally within the NetworkService.
Lukasz Anforowiczbc9875032021-06-24 18:37:42286- Preventing spoofing of `network::ResourceRequest::request_initiator`
287 by comparing against `request_initiator_origin_lock` in
288 `network::CorsURLLoaderFactory::IsValidRequest`.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58289
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58290
291## (WIP) SameSite cookies
292
293Compromised renderers shouldnt be able to send a cross-site HTTP request with
294SameSite cookies.
295
296**Work-in-progress / not protected today**.
297
298TODO(morlovich): Add details. I assume that this requires trustworthy
299|request_initiator| (similar to the `Origin` header), but probably more
300than that.
301
302See also https://crbug.com/927967.
303
304
305## (WIP) User gestures / activations.
306
307Compromised renderers shouldn't be able to spoof user gestures to perform
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34308actions requiring them:
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58309
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34310- A compromised renderer should not be able to forge a gesture that affects
311 the trusted browser UI. For example, a compromised renderer should not be
312 able to interact with the Omnibox or the WebBluetooth chooser.
313
314- A compromised renderer should not be able to forge a gesture that grants
315 extra capabilities to a web origin. For example, a compromised renderer
316 should not be able to open an unlimited number of popup
317 windows by forging user gestures.
318 **Work-in-progress / not protected today** - see https://crbug.com/848778.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58319
320
321## Web Accessible Resources of Chrome Extensions
322
323Compromised non-extension renderers shouldn’t be able to access
324non-web-accessible-resources of a Chrome Extension.
325
326Protection techniques:
327- Navigations: Enforcement in the browser process
328 via `extensions::ExtensionNavigationThrottle`, an implementation of
329 `content::NavigationThrottle`. This relies on non-spoofability
330 of `content::NavigationHandle::GetInitiatorOrigin`.
331- Subresources: Enforcement in the browser process via
332 `ExtensionURLLoaderFactory::CreateLoaderAndStart`. This relies
333 on process boundaries and therefore doesn't rely on non-spoofability
334 of `network::ResourceRequest::request_initiator`.
335
336
337## Non-Web resources
338
339Compromised *web* renderer processes shouldnt be able to access
340*local* resources (e.g. `file://...` or `chrome://settings`).
341
342Protection techniques:
343- TODO(lukasza, nasko): need to research
344
345
346## Android-specific protection gaps
347
348Due to resource constraints, on Android platforms only some sites get a
349dedicated renderer process, isolated from other sites.
350(Current heuristic is to isolate the sites where the user has entered a password
351in the past.)
352This means that some sites are hosted in a renderer process that is
353*not* locked to any particular site. If an attacker compromises
354an unlocked renderer process, they may try to abuse protection gaps listed
355below.
356
357**Known gaps in protection**:
358- When `CanAccessDataForOrigin` runs on the IO thread, it cannot protect
359 isolated sites against being accessed from an unlocked renderer process.
360 Some web storage protections depend on `CanAccessDataForOrigin` calls
361 on the IO thread.
362 See also https://crbug.com/764958.
Lukasz Anforowicz0481d82f2020-05-27 22:08:24363
364
365## Renderer processes hosting DevTools frontend
366
367If an attacker could take control over the DevTools frontend then the attacker
368would gain access to all the cookies, storage, etc. of any origin within the
369page and would be able to execute arbitrary scripts in any frame of the page.
370This means that treating the DevTools renderer as untrustworthy wouldn't in
371practice offer additional protection for the same-origin-policy.
372
373Because of the above:
374
375- Chrome ensures that the DevTools frontend is always hosted in a renderer
376 process separate from renderers hosting web origins.
377- Chrome assumes that the DevTools frontend is always trustworthy
378 (i.e. never compromised, or under direct control of an attacker).
379 For example, when the DevTools process asks to initiate a HTTP request on
380 behalf of https://example.com, the browser process trusts the DevTools
381 renderer to claim authority to initiate requests of behalf of this origin
382 (e.g. attach SameSite cookies, send appropriate Sec-Fetch-Site request header,
383 etc.).