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

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

Issue 2450503002: Tighten IO thread blob/filesystem URL checks for apps with webview permission. (Closed)
Patch Set: 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 "extensions/browser/api/web_request/web_request_api.h" 25 #include "extensions/browser/api/web_request/web_request_api.h"
22 #include "extensions/browser/extension_navigation_ui_data.h" 26 #include "extensions/browser/extension_navigation_ui_data.h"
23 #include "extensions/browser/info_map.h" 27 #include "extensions/browser/info_map.h"
24 #include "extensions/browser/process_manager.h" 28 #include "extensions/browser/process_manager.h"
25 #include "extensions/common/constants.h" 29 #include "extensions/common/constants.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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 origin.scheme() == extensions::kExtensionScheme && 194 origin.scheme() == extensions::kExtensionScheme &&
191 !extension_info_map_->process_map().Contains(info->GetChildID())) { 195 !extension_info_map_->process_map().Contains(info->GetChildID())) {
192 // Relax this restriction for apps that use <webview>. See 196 // Relax this restriction for apps that use <webview>. See
193 // https://crbug.com/652077. 197 // https://crbug.com/652077.
194 const extensions::Extension* extension = 198 const extensions::Extension* extension =
195 extension_info_map_->extensions().GetByID(origin.host()); 199 extension_info_map_->extensions().GetByID(origin.host());
196 bool has_webview_permission = 200 bool has_webview_permission =
197 extension && 201 extension &&
198 extension->permissions_data()->HasAPIPermission( 202 extension->permissions_data()->HasAPIPermission(
199 extensions::APIPermission::kWebView); 203 extensions::APIPermission::kWebView);
200 if (!has_webview_permission) 204 // Check whether the request is coming from a <webview> guest process via
205 // ChildProcessSecurityPolicy. A guest process should have already been
206 // granted permission to request |origin| when its WebContents was created.
207 // See https://crbug.com/656752.
208 auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
209 bool from_guest =
210 policy->HasSpecificPermissionForOrigin(info->GetChildID(), origin);
211 if (!has_webview_permission || !from_guest) {
212 // TODO(alexmos): Temporary instrumentation to find any regressions for
213 // this blocking. Remove after verifying that this is not breaking any
214 // legitimate use cases.
215 char origin_copy[256];
216 base::strlcpy(origin_copy, origin.Serialize().c_str(),
217 arraysize(origin_copy));
218 base::debug::Alias(&origin_copy);
219 base::debug::Alias(&from_guest);
220 base::debug::DumpWithoutCrashing();
201 return net::ERR_ABORTED; 221 return net::ERR_ABORTED;
222 }
202 } 223 }
203 224
204 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( 225 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
205 profile_, extension_info_map_.get(), 226 profile_, extension_info_map_.get(),
206 GetExtensionNavigationUIData(request), request, callback, new_url); 227 GetExtensionNavigationUIData(request), request, callback, new_url);
207 } 228 }
208 229
209 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction( 230 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction(
210 net::URLRequest* request, 231 net::URLRequest* request,
211 const net::CompletionCallback& callback, 232 const net::CompletionCallback& callback,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 416 }
396 417
397 net::NetworkDelegate::AuthRequiredResponse 418 net::NetworkDelegate::AuthRequiredResponse
398 ChromeExtensionsNetworkDelegate::OnAuthRequired( 419 ChromeExtensionsNetworkDelegate::OnAuthRequired(
399 net::URLRequest* request, 420 net::URLRequest* request,
400 const net::AuthChallengeInfo& auth_info, 421 const net::AuthChallengeInfo& auth_info,
401 const AuthCallback& callback, 422 const AuthCallback& callback,
402 net::AuthCredentials* credentials) { 423 net::AuthCredentials* credentials) {
403 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 424 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
404 } 425 }
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