blob: ead4005f3f6fa5de03e5c88e781d46ab1339f3a9 [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
47processes are origin-bound (e.g. by setting `request_initiator_site_lock`
48on 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.
64- No form of Site Isolation is active in content hosted within
65 `<webview>` HTML tags. See also https://crbug.com/614463.
66- Frames with `<iframe sandbox>` attribute are not isolated
67 from their non-opaque precursor origin.
68 See also https://crbug.com/510122.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:3469- `file:` frames may share a process with other `file:` frames.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:5870 See also https://crbug.com/780770.
71
72
73## Cross-Origin HTTP resources
74
75Compromised renderers shouldn't be able to read the contents (header + body) of
76a cross-site HTTP response, unless it is a valid subresource needed for
77compatibility (e.g., JavaScript, images, etc), or is successfully allowed via
78CORS.
79
80Protection techniques:
81- Enforcing
82 [Cross-Origin Read Blocking
83 (CORB)](https://www.chromium.org/Home/chromium-security/corb-for-developers)
84 in the NetworkService process
85 (i.e. before the HTTP response is handed out to the renderer process).
86- Only allowing the privileged browser process to create
87 `network::mojom::URLLoaderFactory` objects that handle HTTP requests.
88 This lets the browser process carefully control security-sensitive
89 `network::mojom::URLLoaderFactoryParams` of such factories (such as
90 `request_initiator_site_lock`, `is_corb_enabled`, `disable_web_security` or
91 `isolation_info`).
92 This also lets the CORB implementation in the NetworkService process
93 prevent spoofing of `network::ResourceRequest::request_initiator`
94 by using `network::GetTrustworthyInitiator` for comparison with
95 the trustworthy `request_initiator_site_lock`.
96
97**Known gaps in protection**:
98- Content types for which CORB does not apply
99 (e.g. `image/png`, `application/octet-stream`) are not protected by
100 default. We recommend that HTTP servers protect such resources by
101 either serving a `Cross-Origin-Resource-Policy: same-origin` response header
102 or validating the `Sec-Fetch-Site` request header.
103- CORB protection is relaxed in presence of
104 - Adobe Flash plugin (see https://crbug.com/874515)
105 - A relatively small number of allowlisted Chrome Extensions
106 (see https://crbug.com/846346)
107
108
109## Contents of cross-site frames
110
111Compromised renderers shouldn't be able to read the contents of cross-site
112frames. Examples:
113- Text or pixels of cross-site frames.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34114- Full URL (e.g. URL path or query) of cross-site frames.
115 Note that the origin of other frames
116 needs to be exposed via `window.origin` for legacy reasons.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58117
118Protection techniques:
119- Compositing tab contents (both for display and for printing)
120 outside the renderer processes.
121- Isolating PDF plugins.
122- Being careful what URLs are exposed in console messages.
123
124**Known gaps in protection**:
125- Mixed content console messages may disclose cross-site URLs
126 (see also https://crbug.com/726178).
127
128
129## Cookies
130
131Compromised renderers shouldnt be able to read or write
132any cookies of another site,
133or `httpOnly` cookies even from the same site.
134
135Protection techniques:
136- Renderer processes are only given `network::mojom::RestrictedCookieManager`
137 for origins within their site
138 (see `StoragePartitionImpl::CreateRestrictedCookieManager`).
139- Mojo serialization does not send any cookies from HTTP headers to the renderer
140 process (see
141 `ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write`).
142
143
144## Passwords
145
146Compromised renderers shouldnt be able to read or write passwords of
147other sites.
148
149Protection techniques:
150- Using `CanAccessDataForOrigin` to verify IPCs sent by a renderer process
151 (e.g. `//components/password_manager/content/browser/bad_message.cc`)
152- Using trustworthy, browser-side knowledge
153 to determine which credentials to read or write
154 (e.g. `content::RenderFrameHost::GetLastCommittedURL` in
155 `password_manager::CredentialManagerImpl::GetOrigin`).
156
157
158## Security-sensitive UI/chrome elements (e.g. Omnibox)
159
160Compromised renderers shouldnt be able to influence/spoof
161security-sensitive UI elements.
162
163Examples:
164- Omnibox
165 - URL (e.g. renderer process locked to foo.com shouldnt
166 be able to trick the Omnibox into displaying bar.com)
167 - Secure / not secure chip (e.g. a renderer process locked to a HTTP
168 site shouldnt be able to trick the Omnibox into displaying a
169 HTTPS-associated lock)
170 - Content settings (e.g. a renderer process that has been granted
171 microphone access shouldnt be able to suppress the mic/camera
172 icon in the Omnibox)
173- Dialogs and prompts (for example a permissions dialog asking to allow
174 a site to show notifications)
175 - Origin in dialogs (e.g. a renderer process locked to foo.com
176 shouldnt be able to trick the Omnibox into displaying a bar.com
177 URL in permission dialogs)
178
179Protection techniques:
180- `RenderFrameHostImpl::CanCommitOriginAndUrl` verifies that the renderer
181 process is able to commit what it claims, and kills the process otherwise.
182- Work-in-progress: calculating the origin in the browser process,
183 before a navigation commits (https://crbug.com/888079).
184
185
186## Permissions
187
188Compromised renderers shouldnt be able to gain permissions without user
189consent.
190
191Examples: microphone access permission, geolocation permission, etc.
192
193Protection techniques:
194- Requesting permissions based on browser-side knowledge of frame's origin
195 (e.g. see `GeolocationServiceImplContext::RequestPermission`).
196
197
198## Web storage
199
200Compromised renderers shouldn’t be able to read from or write into
201storage of another site.
202
203Examples of protected storage technologies:
204- localStorage
205- sessionStorage
206- indexedDB
207- blob storage
208- webSQL
209
210Protection techniques:
211- Using CanAccessDataForOrigin to verify IPCs sent by a renderer process
212 (e.g. see `StoragePartitionImpl::OpenLocalStorage`).
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34213- Binding Mojo interfaces to a single origin obtained from browser-side
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58214 information in `RenderFrameHost::GetLastCommittedOrigin()`
215 (e.g. see RenderFrameHostImpl::CreateIDBFactory).
216
217**Known gaps in protection**:
218- https://crbug.com/917457: FileSystem API (deprecated, Chrome-only).
219
220
221## Messaging
222
223Compromised renderers shouldn’t be able to:
224- Spoof the `MessageEvent.origin` seen by a recipient of a `postMessage`.
225- Bypass enforcement of the `targetOrigin` argument of `postMessage`.
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34226- Send or receive `BroadcastChannel` messages for another origin.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58227- Spoof the `MessageSender.origin` seen by a recipient of a
228 `chrome.runtime.sendMessage`
229 (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)).
230
231Protection techniques:
232- Using CanAccessDataForOrigin to verify IPCs sent by a renderer process
233 (e.g. in `RenderFrameProxyHost::OnRouteMessageEvent` or
234 `BroadcastChannelProvider::ConnectToChannel`).
235
236**Known gaps in protection**:
237- Spoofing of `MessageSender.id` object
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34238 (see [the MessageSender documentation](https://developers.chrome.com/extensions/runtime#type-MessageSender)
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58239 and https://crbug.com/982361).
240
241
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34242## JavaScript code cache
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58243
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34244Compromised renderers shouldn't be able to poison the JavaScript code cache
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58245used by scripts executed in cross-site execution contexts.
246
247Protection techniques:
248- Partitioning the code cache by Network Isolation Key (NIK).
249- Using `CanAccessDataForOrigin` in
250 `CodeCacheHostImpl::DidGenerateCacheableMetadataInCacheStorage`.
251
252
253## Cross-Origin-Resource-Policy response header
254
255A compromised renderer shouldnt be able to bypass
256Cross-Origin-Resource-Policy (CORS),
257which prevents or allows responses from being requested cross-origin, more
258explicitly than CORB.
259
260Protection techniques:
261- Enforcing Cross-Origin-Resource-Policy in the NetworkService process
262 (i.e. before the HTTP response is handed out to the renderer process).
263- Preventing spoofing of `network::ResourceRequest::request_initiator`
264 by using `network::GetTrustworthyInitiator` which enforces
265 browser-controlled `request_initiator_site_lock`.
266
267
268## Frame-ancestors CSP and X-Frame-Options response headers
269
270A compromised renderer shouldnt be able to bypass `X-Frame-Options`
271or `frame-ancestors` CSP.
272
273For example, if example.com/page.html sends a `X-Frame-Options: deny` header,
274then it should never commit in a subframe, even if some renderers have
275been compromised.
276
277Protection techniques:
278- `X-Frame-Options: deny` is enforced in the browser process
279 via `content::AncestorThrottle`, an implementation of
280 `content::NavigationThrottle`.
281- `frame-ancestors` is enforced in a renderer process, but
282 this process is considered trustworthy in this scenario
283 (because it hosts the frame that is requesting protection).
284 See also https://crbug.com/759184 which tracks
285 moving this enforcement into the browser process.
286
287
288## HTTP request headers
289
290Compromised renderers shouldnt be able to control security sensitive HTTP
291request headers like `Host` or `Sec-Fetch-Site`.
292
293Protection techniques:
294- Using `AreRequestHeadersSafe` to reject `Host` and other headers that
295 should only be generated internally within the NetworkService.
296- `Sec-Fetch-Site` is robust against spoofing of
297 `network::ResourceRequest::request_initiator` by using
298 `network::GetTrustworthyInitiator` which enforces browser-controlled
299 `request_initiator_site_lock`.
300
301**Known gaps in protection**:
302- `Origin` header. Tracked by
303 https://crbug.com/920634 (making
304 `network::ResourceRequest::request_initiator` unspoofable without
305 having to go through `GetTrustworthyInitiator`) and
306 https://crbug.com/920638 (making
307 `network::ResourceRequest::isolated_world_origin` irrelevant for
308 security decisions).
309
310
311## (WIP) SameSite cookies
312
313Compromised renderers shouldnt be able to send a cross-site HTTP request with
314SameSite cookies.
315
316**Work-in-progress / not protected today**.
317
318TODO(morlovich): Add details. I assume that this requires trustworthy
319|request_initiator| (similar to the `Origin` header), but probably more
320than that.
321
322See also https://crbug.com/927967.
323
324
325## (WIP) User gestures / activations.
326
327Compromised renderers shouldn't be able to spoof user gestures to perform
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34328actions requiring them:
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58329
Lukasz Anforowicz11dbb06d2020-05-12 00:14:34330- A compromised renderer should not be able to forge a gesture that affects
331 the trusted browser UI. For example, a compromised renderer should not be
332 able to interact with the Omnibox or the WebBluetooth chooser.
333
334- A compromised renderer should not be able to forge a gesture that grants
335 extra capabilities to a web origin. For example, a compromised renderer
336 should not be able to open an unlimited number of popup
337 windows by forging user gestures.
338 **Work-in-progress / not protected today** - see https://crbug.com/848778.
Lukasz Anforowiczf4e58ce2020-05-11 18:18:58339
340
341## Web Accessible Resources of Chrome Extensions
342
343Compromised non-extension renderers shouldn’t be able to access
344non-web-accessible-resources of a Chrome Extension.
345
346Protection techniques:
347- Navigations: Enforcement in the browser process
348 via `extensions::ExtensionNavigationThrottle`, an implementation of
349 `content::NavigationThrottle`. This relies on non-spoofability
350 of `content::NavigationHandle::GetInitiatorOrigin`.
351- Subresources: Enforcement in the browser process via
352 `ExtensionURLLoaderFactory::CreateLoaderAndStart`. This relies
353 on process boundaries and therefore doesn't rely on non-spoofability
354 of `network::ResourceRequest::request_initiator`.
355
356
357## Non-Web resources
358
359Compromised *web* renderer processes shouldnt be able to access
360*local* resources (e.g. `file://...` or `chrome://settings`).
361
362Protection techniques:
363- TODO(lukasza, nasko): need to research
364
365
366## Android-specific protection gaps
367
368Due to resource constraints, on Android platforms only some sites get a
369dedicated renderer process, isolated from other sites.
370(Current heuristic is to isolate the sites where the user has entered a password
371in the past.)
372This means that some sites are hosted in a renderer process that is
373*not* locked to any particular site. If an attacker compromises
374an unlocked renderer process, they may try to abuse protection gaps listed
375below.
376
377**Known gaps in protection**:
378- When `CanAccessDataForOrigin` runs on the IO thread, it cannot protect
379 isolated sites against being accessed from an unlocked renderer process.
380 Some web storage protections depend on `CanAccessDataForOrigin` calls
381 on the IO thread.
382 See also https://crbug.com/764958.
383- `request_initiator_site_lock` may be missing in unlocked renderer
384 processes on Android (for example affecting protections of CORB, CORP,
385 Sec-Fetch-Site and in the future SameSite cookies and Origin
386 protections). See also https://crbug.com/891872.