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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 1608573002: RDH: Block a compromised renderer from reusing request ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // If sync_result is non-null, then a SyncLoad reply will be generated, else 1180 // If sync_result is non-null, then a SyncLoad reply will be generated, else
1181 // a normal asynchronous set of response messages will be generated. 1181 // a normal asynchronous set of response messages will be generated.
1182 void ResourceDispatcherHostImpl::OnSyncLoad( 1182 void ResourceDispatcherHostImpl::OnSyncLoad(
1183 int request_id, 1183 int request_id,
1184 const ResourceHostMsg_Request& request_data, 1184 const ResourceHostMsg_Request& request_data,
1185 IPC::Message* sync_result) { 1185 IPC::Message* sync_result) {
1186 BeginRequest(request_id, request_data, sync_result, 1186 BeginRequest(request_id, request_data, sync_result,
1187 sync_result->routing_id()); 1187 sync_result->routing_id());
1188 } 1188 }
1189 1189
1190 bool ResourceDispatcherHostImpl::IsRequestIDInUse(
1191 const GlobalRequestID& id) const {
1192 if (pending_loaders_.find(id) != pending_loaders_.end())
1193 return true;
1194 for (const auto& blocked_loaders : blocked_loaders_map_) {
1195 for (const auto& loader : *blocked_loaders.second.get()) {
1196 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
1197 if (info->GetGlobalRequestID() == id)
1198 return true;
1199 }
1200 }
1201 return false;
1202 }
1203
1190 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( 1204 void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
1191 int child_id, 1205 int child_id,
1192 int route_id, 1206 int route_id,
1193 int request_id, 1207 int request_id,
1194 const ResourceHostMsg_Request& request_data, 1208 const ResourceHostMsg_Request& request_data,
1195 LoaderMap::iterator iter) { 1209 LoaderMap::iterator iter) {
1196 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); 1210 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo();
1197 GlobalRoutingID old_routing_id( 1211 GlobalRoutingID old_routing_id(
1198 request_data.transferred_request_child_id, info->GetRouteID()); 1212 request_data.transferred_request_child_id, info->GetRouteID());
1199 GlobalRequestID old_request_id(request_data.transferred_request_child_id, 1213 GlobalRequestID old_request_id(request_data.transferred_request_child_id,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 } 1288 }
1275 1289
1276 void ResourceDispatcherHostImpl::BeginRequest( 1290 void ResourceDispatcherHostImpl::BeginRequest(
1277 int request_id, 1291 int request_id,
1278 const ResourceHostMsg_Request& request_data, 1292 const ResourceHostMsg_Request& request_data,
1279 IPC::Message* sync_result, // only valid for sync 1293 IPC::Message* sync_result, // only valid for sync
1280 int route_id) { 1294 int route_id) {
1281 int process_type = filter_->process_type(); 1295 int process_type = filter_->process_type();
1282 int child_id = filter_->child_id(); 1296 int child_id = filter_->child_id();
1283 1297
1298 // Reject request id that's currently in use.
1299 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1300 bad_message::ReceivedBadMessage(filter_,
1301 bad_message::RDH_INVALID_REQUEST_ID);
1302 return;
1303 }
1304
1284 // PlzNavigate: reject invalid renderer main resource request. 1305 // PlzNavigate: reject invalid renderer main resource request.
1285 if (IsBrowserSideNavigationEnabled() && 1306 if (IsBrowserSideNavigationEnabled() &&
1286 IsResourceTypeFrame(request_data.resource_type) && 1307 IsResourceTypeFrame(request_data.resource_type) &&
1287 !request_data.url.SchemeIs(url::kBlobScheme)) { 1308 !request_data.url.SchemeIs(url::kBlobScheme)) {
1288 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_URL); 1309 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_URL);
1289 return; 1310 return;
1290 } 1311 }
1291 1312
1292 // Reject invalid priority. 1313 // Reject invalid priority.
1293 if (request_data.priority < net::MINIMUM_PRIORITY || 1314 if (request_data.priority < net::MINIMUM_PRIORITY ||
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 load_flags |= net::LOAD_PREFETCH; 2561 load_flags |= net::LOAD_PREFETCH;
2541 } 2562 }
2542 2563
2543 if (is_sync_load) 2564 if (is_sync_load)
2544 load_flags |= net::LOAD_IGNORE_LIMITS; 2565 load_flags |= net::LOAD_IGNORE_LIMITS;
2545 2566
2546 return load_flags; 2567 return load_flags;
2547 } 2568 }
2548 2569
2549 } // namespace content 2570 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/security_exploit_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698