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

Side by Side Diff: chrome/browser/net/chrome_extensions_network_delegate.cc

Issue 2437753003: Tighten IO thread blob/filesystem URL checks for apps with webview permission. (Closed)
Patch Set: arraysize Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/net/chrome_extensions_network_delegate.h" 5 #include "chrome/browser/net/chrome_extensions_network_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 11
12 #if defined(ENABLE_EXTENSIONS) 12 #if defined(ENABLE_EXTENSIONS)
13 #include "base/debug/alias.h"
14 #include "base/debug/dump_without_crashing.h"
15 #include "base/strings/string_util.h"
13 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/api/proxy/proxy_api.h" 17 #include "chrome/browser/extensions/api/proxy/proxy_api.h"
15 #include "chrome/browser/extensions/event_router_forwarder.h" 18 #include "chrome/browser/extensions/event_router_forwarder.h"
16 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" 20 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h"
18 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/child_process_security_policy.h"
19 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/resource_request_info.h" 24 #include "content/public/browser/resource_request_info.h"
21 #include "content/public/common/browser_side_navigation_policy.h" 25 #include "content/public/common/browser_side_navigation_policy.h"
22 #include "extensions/browser/api/web_request/web_request_api.h" 26 #include "extensions/browser/api/web_request/web_request_api.h"
23 #include "extensions/browser/extension_navigation_ui_data.h" 27 #include "extensions/browser/extension_navigation_ui_data.h"
24 #include "extensions/browser/info_map.h" 28 #include "extensions/browser/info_map.h"
25 #include "extensions/browser/process_manager.h" 29 #include "extensions/browser/process_manager.h"
26 #include "extensions/common/permissions/api_permission.h" 30 #include "extensions/common/permissions/api_permission.h"
27 #include "net/url_request/url_request.h" 31 #include "net/url_request/url_request.h"
28 32
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 !extension_info_map_->process_map().Contains(info->GetChildID()) && 206 !extension_info_map_->process_map().Contains(info->GetChildID()) &&
203 !content::IsBrowserSideNavigationEnabled()) { 207 !content::IsBrowserSideNavigationEnabled()) {
204 // Relax this restriction for apps that use <webview>. See 208 // Relax this restriction for apps that use <webview>. See
205 // https://crbug.com/652077. 209 // https://crbug.com/652077.
206 const extensions::Extension* extension = 210 const extensions::Extension* extension =
207 extension_info_map_->extensions().GetByID(origin.host()); 211 extension_info_map_->extensions().GetByID(origin.host());
208 bool has_webview_permission = 212 bool has_webview_permission =
209 extension && 213 extension &&
210 extension->permissions_data()->HasAPIPermission( 214 extension->permissions_data()->HasAPIPermission(
211 extensions::APIPermission::kWebView); 215 extensions::APIPermission::kWebView);
212 if (!has_webview_permission) 216 // Check whether the request is coming from a <webview> guest process via
217 // ChildProcessSecurityPolicy. A guest process should have already been
218 // granted permission to request |origin| when its WebContents was created.
219 // See https://crbug.com/656752.
220 auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
221 bool from_guest =
222 policy->HasSpecificPermissionForOrigin(info->GetChildID(), origin);
223 if (!has_webview_permission || !from_guest) {
224 // TODO(alexmos): Temporary instrumentation to find any regressions for
225 // this blocking. Remove after verifying that this is not breaking any
226 // legitimate use cases.
227 char origin_copy[256];
228 base::strlcpy(origin_copy, origin.Serialize().c_str(),
229 arraysize(origin_copy));
230 base::debug::Alias(&origin_copy);
231 base::debug::Alias(&from_guest);
232 base::debug::DumpWithoutCrashing();
213 return net::ERR_ABORTED; 233 return net::ERR_ABORTED;
234 }
214 } 235 }
215 236
216 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( 237 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
217 profile_, extension_info_map_.get(), 238 profile_, extension_info_map_.get(),
218 GetExtensionNavigationUIData(request), request, callback, new_url); 239 GetExtensionNavigationUIData(request), request, callback, new_url);
219 } 240 }
220 241
221 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction( 242 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction(
222 net::URLRequest* request, 243 net::URLRequest* request,
223 const net::CompletionCallback& callback, 244 const net::CompletionCallback& callback,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 422 }
402 423
403 net::NetworkDelegate::AuthRequiredResponse 424 net::NetworkDelegate::AuthRequiredResponse
404 ChromeExtensionsNetworkDelegate::OnAuthRequired( 425 ChromeExtensionsNetworkDelegate::OnAuthRequired(
405 net::URLRequest* request, 426 net::URLRequest* request,
406 const net::AuthChallengeInfo& auth_info, 427 const net::AuthChallengeInfo& auth_info,
407 const AuthCallback& callback, 428 const AuthCallback& callback,
408 net::AuthCredentials* credentials) { 429 net::AuthCredentials* credentials) {
409 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 430 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
410 } 431 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/process_manager_browsertest.cc ('k') | content/browser/child_process_security_policy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698