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

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

Issue 2435593007: Temporarily reintroduce blob/filesystem URL security checks on the IO thread. (Closed)
Patch Set: Comment nit Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/api/proxy/proxy_api.h" 14 #include "chrome/browser/extensions/api/proxy/proxy_api.h"
15 #include "chrome/browser/extensions/event_router_forwarder.h" 15 #include "chrome/browser/extensions/event_router_forwarder.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" 17 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/resource_request_info.h" 20 #include "content/public/browser/resource_request_info.h"
21 #include "content/public/common/browser_side_navigation_policy.h"
21 #include "extensions/browser/api/web_request/web_request_api.h" 22 #include "extensions/browser/api/web_request/web_request_api.h"
22 #include "extensions/browser/extension_navigation_ui_data.h" 23 #include "extensions/browser/extension_navigation_ui_data.h"
23 #include "extensions/browser/info_map.h" 24 #include "extensions/browser/info_map.h"
24 #include "extensions/browser/process_manager.h" 25 #include "extensions/browser/process_manager.h"
26 #include "extensions/common/permissions/api_permission.h"
25 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
26 28
27 using content::BrowserThread; 29 using content::BrowserThread;
28 using content::ResourceRequestInfo; 30 using content::ResourceRequestInfo;
29 using extensions::ExtensionWebRequestEventRouter; 31 using extensions::ExtensionWebRequestEventRouter;
30 32
31 namespace { 33 namespace {
32 34
33 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; 35 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE };
34 36
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 172
171 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus( 173 void ChromeExtensionsNetworkDelegateImpl::ForwardDoneRequestStatus(
172 net::URLRequest* request) { 174 net::URLRequest* request) {
173 ForwardRequestStatus(REQUEST_DONE, request, profile_); 175 ForwardRequestStatus(REQUEST_DONE, request, profile_);
174 } 176 }
175 177
176 int ChromeExtensionsNetworkDelegateImpl::OnBeforeURLRequest( 178 int ChromeExtensionsNetworkDelegateImpl::OnBeforeURLRequest(
177 net::URLRequest* request, 179 net::URLRequest* request,
178 const net::CompletionCallback& callback, 180 const net::CompletionCallback& callback,
179 GURL* new_url) { 181 GURL* new_url) {
182 const content::ResourceRequestInfo* info =
183 content::ResourceRequestInfo::ForRequest(request);
184 GURL url(request->url());
185
186 // Block top-level navigations to blob: or filesystem: URLs with extension
187 // origin from non-extension processes. See https://crbug.com/645028.
188 //
189 // TODO(alexmos): This check is redundant with the one in
190 // ExtensionNavigationThrottle::WillStartRequest, which was introduced in
191 // M56. This check is reintroduced temporarily to tighten this blocking for
192 // apps with a "webview" permission on M55/54 (see https://crbug.com/656752).
193 // It will be removed after it's merged. Unlike the check in
194 // ExtensionNavigationThrottle, this check is incompatible with PlzNavigate
195 // and is disabled for that mode.
196 bool is_nested_url = url.SchemeIsFileSystem() || url.SchemeIsBlob();
197 bool is_navigation =
198 info && content::IsResourceTypeFrame(info->GetResourceType());
199 url::Origin origin(url);
200 if (is_nested_url && is_navigation && info->IsMainFrame() &&
201 origin.scheme() == extensions::kExtensionScheme &&
202 !extension_info_map_->process_map().Contains(info->GetChildID()) &&
203 !content::IsBrowserSideNavigationEnabled()) {
204 // Relax this restriction for apps that use <webview>. See
205 // https://crbug.com/652077.
206 const extensions::Extension* extension =
207 extension_info_map_->extensions().GetByID(origin.host());
208 bool has_webview_permission =
209 extension &&
210 extension->permissions_data()->HasAPIPermission(
211 extensions::APIPermission::kWebView);
212 if (!has_webview_permission)
213 return net::ERR_ABORTED;
214 }
215
180 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( 216 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
181 profile_, extension_info_map_.get(), 217 profile_, extension_info_map_.get(),
182 GetExtensionNavigationUIData(request), request, callback, new_url); 218 GetExtensionNavigationUIData(request), request, callback, new_url);
183 } 219 }
184 220
185 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction( 221 int ChromeExtensionsNetworkDelegateImpl::OnBeforeStartTransaction(
186 net::URLRequest* request, 222 net::URLRequest* request,
187 const net::CompletionCallback& callback, 223 const net::CompletionCallback& callback,
188 net::HttpRequestHeaders* headers) { 224 net::HttpRequestHeaders* headers) {
189 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeSendHeaders( 225 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeSendHeaders(
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 401 }
366 402
367 net::NetworkDelegate::AuthRequiredResponse 403 net::NetworkDelegate::AuthRequiredResponse
368 ChromeExtensionsNetworkDelegate::OnAuthRequired( 404 ChromeExtensionsNetworkDelegate::OnAuthRequired(
369 net::URLRequest* request, 405 net::URLRequest* request,
370 const net::AuthChallengeInfo& auth_info, 406 const net::AuthChallengeInfo& auth_info,
371 const AuthCallback& callback, 407 const AuthCallback& callback,
372 net::AuthCredentials* credentials) { 408 net::AuthCredentials* credentials) {
373 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 409 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
374 } 410 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698