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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1009583004: Add UMA histograms and logging for bad IPC message handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/user_metrics_action.h"
13 #include "base/process/kill.h" 12 #include "base/process/kill.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "content/browser/accessibility/accessibility_mode_helper.h" 14 #include "content/browser/accessibility/accessibility_mode_helper.h"
16 #include "content/browser/accessibility/browser_accessibility_manager.h" 15 #include "content/browser/accessibility/browser_accessibility_manager.h"
17 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 16 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
18 #include "content/browser/child_process_security_policy_impl.h" 17 #include "content/browser/child_process_security_policy_impl.h"
19 #include "content/browser/frame_host/cross_process_frame_connector.h" 18 #include "content/browser/frame_host/cross_process_frame_connector.h"
20 #include "content/browser/frame_host/cross_site_transferring_request.h" 19 #include "content/browser/frame_host/cross_site_transferring_request.h"
21 #include "content/browser/frame_host/frame_accessibility.h" 20 #include "content/browser/frame_host/frame_accessibility.h"
22 #include "content/browser/frame_host/frame_tree.h" 21 #include "content/browser/frame_host/frame_tree.h"
(...skipping 18 matching lines...) Expand all
41 #include "content/browser/renderer_host/render_widget_host_view_base.h" 40 #include "content/browser/renderer_host/render_widget_host_view_base.h"
42 #include "content/browser/transition_request_manager.h" 41 #include "content/browser/transition_request_manager.h"
43 #include "content/common/accessibility_messages.h" 42 #include "content/common/accessibility_messages.h"
44 #include "content/common/frame_messages.h" 43 #include "content/common/frame_messages.h"
45 #include "content/common/input_messages.h" 44 #include "content/common/input_messages.h"
46 #include "content/common/inter_process_time_ticks_converter.h" 45 #include "content/common/inter_process_time_ticks_converter.h"
47 #include "content/common/navigation_params.h" 46 #include "content/common/navigation_params.h"
48 #include "content/common/render_frame_setup.mojom.h" 47 #include "content/common/render_frame_setup.mojom.h"
49 #include "content/common/swapped_out_messages.h" 48 #include "content/common/swapped_out_messages.h"
50 #include "content/public/browser/ax_event_notification_details.h" 49 #include "content/public/browser/ax_event_notification_details.h"
50 #include "content/public/browser/bad_message.h"
51 #include "content/public/browser/browser_accessibility_state.h" 51 #include "content/public/browser/browser_accessibility_state.h"
52 #include "content/public/browser/browser_context.h" 52 #include "content/public/browser/browser_context.h"
53 #include "content/public/browser/browser_plugin_guest_manager.h" 53 #include "content/public/browser/browser_plugin_guest_manager.h"
54 #include "content/public/browser/browser_thread.h" 54 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/content_browser_client.h" 55 #include "content/public/browser/content_browser_client.h"
56 #include "content/public/browser/render_process_host.h" 56 #include "content/public/browser/render_process_host.h"
57 #include "content/public/browser/render_widget_host_view.h" 57 #include "content/public/browser/render_widget_host_view.h"
58 #include "content/public/browser/stream_handle.h" 58 #include "content/public/browser/stream_handle.h"
59 #include "content/public/browser/user_metrics.h" 59 #include "content/public/browser/user_metrics.h"
60 #include "content/public/common/content_constants.h" 60 #include "content/public/common/content_constants.h"
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } 805 }
806 806
807 RenderProcessHost* process = GetProcess(); 807 RenderProcessHost* process = GetProcess();
808 808
809 // Attempts to commit certain off-limits URL should be caught more strictly 809 // Attempts to commit certain off-limits URL should be caught more strictly
810 // than our FilterURL checks below. If a renderer violates this policy, it 810 // than our FilterURL checks below. If a renderer violates this policy, it
811 // should be killed. 811 // should be killed.
812 if (!CanCommitURL(validated_params.url)) { 812 if (!CanCommitURL(validated_params.url)) {
813 VLOG(1) << "Blocked URL " << validated_params.url.spec(); 813 VLOG(1) << "Blocked URL " << validated_params.url.spec();
814 validated_params.url = GURL(url::kAboutBlankURL); 814 validated_params.url = GURL(url::kAboutBlankURL);
815 RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled"));
816 // Kills the process. 815 // Kills the process.
817 process->ReceivedBadMessage(); 816 process->ReceivedBadMessage(BadMessage::RFH_CAN_COMMIT_URL_BLOCKED);
818 } 817 }
819 818
820 // Without this check, an evil renderer can trick the browser into creating 819 // Without this check, an evil renderer can trick the browser into creating
821 // a navigation entry for a banned URL. If the user clicks the back button 820 // a navigation entry for a banned URL. If the user clicks the back button
822 // followed by the forward button (or clicks reload, or round-trips through 821 // followed by the forward button (or clicks reload, or round-trips through
823 // session restore, etc), we'll think that the browser commanded the 822 // session restore, etc), we'll think that the browser commanded the
824 // renderer to load the URL and grant the renderer the privileges to request 823 // renderer to load the URL and grant the renderer the privileges to request
825 // the URL. To prevent this attack, we block the renderer from inserting 824 // the URL. To prevent this attack, we block the renderer from inserting
826 // banned URLs into the navigation controller in the first place. 825 // banned URLs into the navigation controller in the first place.
827 process->FilterURL(false, &validated_params.url); 826 process->FilterURL(false, &validated_params.url);
828 process->FilterURL(true, &validated_params.referrer.url); 827 process->FilterURL(true, &validated_params.referrer.url);
829 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); 828 for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
830 it != validated_params.redirects.end(); ++it) { 829 it != validated_params.redirects.end(); ++it) {
831 process->FilterURL(false, &(*it)); 830 process->FilterURL(false, &(*it));
832 } 831 }
833 process->FilterURL(true, &validated_params.searchable_form_url); 832 process->FilterURL(true, &validated_params.searchable_form_url);
834 833
835 // Without this check, the renderer can trick the browser into using 834 // Without this check, the renderer can trick the browser into using
836 // filenames it can't access in a future session restore. 835 // filenames it can't access in a future session restore.
837 if (!render_view_host_->CanAccessFilesOfPageState( 836 if (!render_view_host_->CanAccessFilesOfPageState(
838 validated_params.page_state)) { 837 validated_params.page_state)) {
839 GetProcess()->ReceivedBadMessage(); 838 GetProcess()->ReceivedBadMessage(
839 BadMessage::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE);
840 return; 840 return;
841 } 841 }
842 842
843 accessibility_reset_count_ = 0; 843 accessibility_reset_count_ = 0;
844 frame_tree_node()->navigator()->DidNavigate(this, validated_params); 844 frame_tree_node()->navigator()->DidNavigate(this, validated_params);
845 } 845 }
846 846
847 void RenderFrameHostImpl::OnDidDropNavigation() { 847 void RenderFrameHostImpl::OnDidDropNavigation() {
848 // At the end of Navigate(), the delegate's DidStartLoading is called to force 848 // At the end of Navigate(), the delegate's DidStartLoading is called to force
849 // the spinner to start, even if the renderer didn't yet begin the load. If it 849 // the spinner to start, even if the renderer didn't yet begin the load. If it
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 FrameTree* frame_tree = frame_tree_node()->frame_tree(); 1210 FrameTree* frame_tree = frame_tree_node()->frame_tree();
1211 FrameTreeNode* child = 1211 FrameTreeNode* child =
1212 frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id); 1212 frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id);
1213 if (!child) 1213 if (!child)
1214 return; 1214 return;
1215 1215
1216 // Ensure that a frame can only update sandbox flags for its immediate 1216 // Ensure that a frame can only update sandbox flags for its immediate
1217 // children. If this is not the case, the renderer is considered malicious 1217 // children. If this is not the case, the renderer is considered malicious
1218 // and is killed. 1218 // and is killed.
1219 if (child->parent() != frame_tree_node()) { 1219 if (child->parent() != frame_tree_node()) {
1220 RecordAction(base::UserMetricsAction("BadMessageTerminate_RFH")); 1220 GetProcess()->ReceivedBadMessage(BadMessage::RFH_SANDBOX_FLAGS);
1221 GetProcess()->ReceivedBadMessage();
1222 return; 1221 return;
1223 } 1222 }
1224 1223
1225 child->set_sandbox_flags(flags); 1224 child->set_sandbox_flags(flags);
1226 1225
1227 // Notify the RenderFrame if it lives in a different process from its 1226 // Notify the RenderFrame if it lives in a different process from its
1228 // parent. The frame's proxies in other processes also need to learn about 1227 // parent. The frame's proxies in other processes also need to learn about
1229 // the updated sandbox flags, but these notifications are sent later in 1228 // the updated sandbox flags, but these notifications are sent later in
1230 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame 1229 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame
1231 // navigates and the new sandbox flags take effect. 1230 // navigates and the new sandbox flags take effect.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1267 }
1269 1268
1270 void RenderFrameHostImpl::OnDispatchLoad() { 1269 void RenderFrameHostImpl::OnDispatchLoad() {
1271 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1270 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1272 switches::kSitePerProcess)); 1271 switches::kSitePerProcess));
1273 // Only frames with an out-of-process parent frame should be sending this 1272 // Only frames with an out-of-process parent frame should be sending this
1274 // message. 1273 // message.
1275 RenderFrameProxyHost* proxy = 1274 RenderFrameProxyHost* proxy =
1276 frame_tree_node()->render_manager()->GetProxyToParent(); 1275 frame_tree_node()->render_manager()->GetProxyToParent();
1277 if (!proxy) { 1276 if (!proxy) {
1278 GetProcess()->ReceivedBadMessage(); 1277 GetProcess()->ReceivedBadMessage(BadMessage::RFH_NO_PROXY_TO_PARENT);
1279 return; 1278 return;
1280 } 1279 }
1281 1280
1282 proxy->Send(new FrameMsg_DispatchLoad(proxy->GetRoutingID())); 1281 proxy->Send(new FrameMsg_DispatchLoad(proxy->GetRoutingID()));
1283 } 1282 }
1284 1283
1285 void RenderFrameHostImpl::OnAccessibilityEvents( 1284 void RenderFrameHostImpl::OnAccessibilityEvents(
1286 const std::vector<AccessibilityHostMsg_EventParams>& params, 1285 const std::vector<AccessibilityHostMsg_EventParams>& params,
1287 int reset_token) { 1286 int reset_token) {
1288 // Don't process this IPC if either we're waiting on a reset and this 1287 // Don't process this IPC if either we're waiting on a reset and this
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1958 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1960 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1959 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1961 GetContentClient()->browser()->RegisterPermissionUsage( 1960 GetContentClient()->browser()->RegisterPermissionUsage(
1962 PERMISSION_GEOLOCATION, 1961 PERMISSION_GEOLOCATION,
1963 delegate_->GetAsWebContents(), 1962 delegate_->GetAsWebContents(),
1964 GetLastCommittedURL().GetOrigin(), 1963 GetLastCommittedURL().GetOrigin(),
1965 top_frame->GetLastCommittedURL().GetOrigin()); 1964 top_frame->GetLastCommittedURL().GetOrigin());
1966 } 1965 }
1967 1966
1968 } // namespace content 1967 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698