Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: content/browser/child_process_security_policy_impl.h

Issue 2891443002: Keep subdomains of an isolated origin in the isolated origin's SiteInstance. (Closed)
Patch Set: Addressing Nick's comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 6 #define CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 int policy); 202 int policy);
203 203
204 // Returns true if sending system exclusive messages is allowed. 204 // Returns true if sending system exclusive messages is allowed.
205 bool CanSendMidiSysExMessage(int child_id); 205 bool CanSendMidiSysExMessage(int child_id);
206 206
207 // Add an origin to the list of origins that require process isolation. 207 // Add an origin to the list of origins that require process isolation.
208 // When making process model decisions for such origins, the full 208 // When making process model decisions for such origins, the full
209 // scheme+host+port tuple rather than scheme and eTLD+1 will be used. 209 // scheme+host+port tuple rather than scheme and eTLD+1 will be used.
210 // SiteInstances for these origins will also use the full origin as site URL. 210 // SiteInstances for these origins will also use the full origin as site URL.
211 // 211 //
212 // Subdomains of an isolated origin are considered to be part of that
213 // origin's site. For example, if https://isolated.foo.com is added as an
214 // isolated origin, then https://bar.isolated.foo.com will be considered part
215 // of the site for https://isolated.foo.com.
216 //
212 // Note that |origin| must not be unique. URLs that render with 217 // Note that |origin| must not be unique. URLs that render with
213 // unique origins, such as data: URLs, are not supported. Suborigins (see 218 // unique origins, such as data: URLs, are not supported. Suborigins (see
214 // https://w3c.github.io/webappsec-suborigins/ -- not to be confused with 219 // https://w3c.github.io/webappsec-suborigins/ -- not to be confused with
215 // subdomains) and non-standard schemes are also not supported. Sandboxed 220 // subdomains) and non-standard schemes are also not supported. Sandboxed
216 // frames (e.g., <iframe sandbox>) 221 // frames (e.g., <iframe sandbox>) *are* supported, since process placement
217 // *are* supported, since process placement decisions will be based on the 222 // decisions will be based on the URLs such frames navigate to, and not the
218 // URLs such frames navigate to, and not the origin of committed documents 223 // origin of committed documents (which might be unique). If an isolated
219 // (which might be unique). If an isolated origin opens an about:blank 224 // origin opens an about:blank popup, it will stay in the isolated origin's
220 // popup, it will stay in the isolated origin's process. Nested URLs 225 // process. Nested URLs (filesystem: and blob:) retain process isolation
221 // (filesystem: and blob:) retain process isolation behavior of their inner 226 // behavior of their inner origin.
222 // origin.
223 void AddIsolatedOrigin(const url::Origin& origin); 227 void AddIsolatedOrigin(const url::Origin& origin);
224 228
225 // Register a set of isolated origins as specified on the command line with 229 // Register a set of isolated origins as specified on the command line with
226 // the --isolate-origins flag. |origin_list| is the flag's value, which 230 // the --isolate-origins flag. |origin_list| is the flag's value, which
227 // contains the list of comma-separated scheme-host-port origins. See 231 // contains the list of comma-separated scheme-host-port origins. See
228 // AddIsolatedOrigin for definition of an isolated origin. 232 // AddIsolatedOrigin for definition of an isolated origin.
229 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); 233 void AddIsolatedOriginsFromCommandLine(const std::string& origin_list);
230 234
231 // Helper to check whether an origin requires origin-wide process isolation. 235 // Check whether |origin| requires origin-wide process isolation.
236 //
237 // Subdomains of an isolated origin are considered part of that isolated
238 // origin. Thus, if https://isolated.foo.com/ had been added as an isolated
239 // origin, this will return true for https://isolated.foo.com/,
240 // https://bar.isolated.foo.com/, or https://baz.bar.isolated.foo.com/; and
241 // it will return false for https://foo.com/ or https://unisolated.foo.com/.
242 //
243 // Note that unlike site URLs for regular web sites, isolated origins care
244 // about port.
232 bool IsIsolatedOrigin(const url::Origin& origin); 245 bool IsIsolatedOrigin(const url::Origin& origin);
233 246
247 // This function will check whether |origin| requires process isolation, and
248 // if so, it will return true and put the most specific matching isolated
249 // origin into |result|.
250 //
251 // If |origin| does not require process isolation, this function will return
252 // false, and |result| will be a unique origin. This means that neither
253 // |origin|, nor any origins for which |origin| is a subdomain, have been
254 // registered as isolated origins.
255 //
256 // For example, if both https://isolated.com/ and
257 // https://bar.foo.isolated.com/ are registered as isolated origins, then the
258 // values returned in |result| are:
259 // https://isolated.com/ --> https://isolated.com/
260 // https://foo.isolated.com/ --> https://isolated.com/
261 // https://bar.foo.isolated.com/ --> https://bar.foo.isolated.com/
262 // https://baz.bar.foo.isolated.com/ --> https://bar.foo.isolated.com/
263 // https://unisolated.com/ --> (unique origin)
264 bool GetMatchingIsolatedOrigin(const url::Origin& origin,
265 url::Origin* result);
266
267 // Removes a previously added isolated origin, currently only used in tests.
268 //
269 // TODO(alexmos): Exposing this more generally will require extra care, such
270 // as ensuring that there are no active SiteInstances in that origin.
271 void RemoveIsolatedOriginForTesting(const url::Origin& origin);
272
234 private: 273 private:
235 friend class ChildProcessSecurityPolicyInProcessBrowserTest; 274 friend class ChildProcessSecurityPolicyInProcessBrowserTest;
236 friend class ChildProcessSecurityPolicyTest; 275 friend class ChildProcessSecurityPolicyTest;
237 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest, 276 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyInProcessBrowserTest,
238 NoLeak); 277 NoLeak);
239 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions); 278 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, FilePermissions);
240 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest, 279 FRIEND_TEST_ALL_PREFIXES(ChildProcessSecurityPolicyTest,
241 IsolateOriginsFromCommandLine); 280 IsolateOriginsFromCommandLine);
242 281
243 class SecurityState; 282 class SecurityState;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // eTLD+1. Each of these origins requires a dedicated process. This set is 367 // eTLD+1. Each of these origins requires a dedicated process. This set is
329 // protected by |lock_|. 368 // protected by |lock_|.
330 std::set<url::Origin> isolated_origins_; 369 std::set<url::Origin> isolated_origins_;
331 370
332 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl); 371 DISALLOW_COPY_AND_ASSIGN(ChildProcessSecurityPolicyImpl);
333 }; 372 };
334 373
335 } // namespace content 374 } // namespace content
336 375
337 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_ 376 #endif // CONTENT_BROWSER_CHILD_PROCESS_SECURITY_POLICY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698