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

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

Issue 1816563002: PlzNavigate: fix SecurityExploitBrowserTest.MismatchedOriginOnCommit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | content/browser/security_exploit_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 RenderProcessHost* process = GetProcess(); 915 RenderProcessHost* process = GetProcess();
916 916
917 // Read the parameters out of the IPC message directly to avoid making another 917 // Read the parameters out of the IPC message directly to avoid making another
918 // copy when we filter the URLs. 918 // copy when we filter the URLs.
919 base::PickleIterator iter(msg); 919 base::PickleIterator iter(msg);
920 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; 920 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
921 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: 921 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
922 Read(&msg, &iter, &validated_params)) { 922 Read(&msg, &iter, &validated_params)) {
923 bad_message::ReceivedBadMessage( 923 bad_message::ReceivedBadMessage(
924 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); 924 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED);
925 // PlzNavigate: release the stream now that the renderer is going away.
926 stream_handle_.reset();
925 return; 927 return;
926 } 928 }
927 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", 929 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad",
928 "url", validated_params.url.possibly_invalid_spec()); 930 "url", validated_params.url.possibly_invalid_spec());
929 931
930 // Sanity-check the page transition for frame type. 932 // Sanity-check the page transition for frame type.
931 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition), 933 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition),
932 !GetParent()); 934 !GetParent());
933 935
934 // If we're waiting for a cross-site beforeunload ack from this renderer and 936 // If we're waiting for a cross-site beforeunload ack from this renderer and
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 971
970 // Attempts to commit certain off-limits URL should be caught more strictly 972 // Attempts to commit certain off-limits URL should be caught more strictly
971 // than our FilterURL checks below. If a renderer violates this policy, it 973 // than our FilterURL checks below. If a renderer violates this policy, it
972 // should be killed. 974 // should be killed.
973 if (!CanCommitURL(validated_params.url)) { 975 if (!CanCommitURL(validated_params.url)) {
974 VLOG(1) << "Blocked URL " << validated_params.url.spec(); 976 VLOG(1) << "Blocked URL " << validated_params.url.spec();
975 validated_params.url = GURL(url::kAboutBlankURL); 977 validated_params.url = GURL(url::kAboutBlankURL);
976 // Kills the process. 978 // Kills the process.
977 bad_message::ReceivedBadMessage(process, 979 bad_message::ReceivedBadMessage(process,
978 bad_message::RFH_CAN_COMMIT_URL_BLOCKED); 980 bad_message::RFH_CAN_COMMIT_URL_BLOCKED);
981 // PlzNavigate: release the stream now that the renderer is going away.
982 stream_handle_.reset();
979 return; 983 return;
980 } 984 }
981 985
982 // Verify that the origin passed from the renderer process is valid and can 986 // Verify that the origin passed from the renderer process is valid and can
983 // be allowed to commit in this RenderFrameHost. 987 // be allowed to commit in this RenderFrameHost.
984 if (!CanCommitOrigin(validated_params.origin, validated_params.url)) { 988 if (!CanCommitOrigin(validated_params.origin, validated_params.url)) {
985 bad_message::ReceivedBadMessage(GetProcess(), 989 bad_message::ReceivedBadMessage(GetProcess(),
986 bad_message::RFH_INVALID_ORIGIN_ON_COMMIT); 990 bad_message::RFH_INVALID_ORIGIN_ON_COMMIT);
991 // PlzNavigate: release the stream now that the renderer is going away.
992 stream_handle_.reset();
987 return; 993 return;
988 } 994 }
989 995
990 // Without this check, an evil renderer can trick the browser into creating 996 // Without this check, an evil renderer can trick the browser into creating
991 // a navigation entry for a banned URL. If the user clicks the back button 997 // a navigation entry for a banned URL. If the user clicks the back button
992 // followed by the forward button (or clicks reload, or round-trips through 998 // followed by the forward button (or clicks reload, or round-trips through
993 // session restore, etc), we'll think that the browser commanded the 999 // session restore, etc), we'll think that the browser commanded the
994 // renderer to load the URL and grant the renderer the privileges to request 1000 // renderer to load the URL and grant the renderer the privileges to request
995 // the URL. To prevent this attack, we block the renderer from inserting 1001 // the URL. To prevent this attack, we block the renderer from inserting
996 // banned URLs into the navigation controller in the first place. 1002 // banned URLs into the navigation controller in the first place.
997 process->FilterURL(false, &validated_params.url); 1003 process->FilterURL(false, &validated_params.url);
998 process->FilterURL(true, &validated_params.referrer.url); 1004 process->FilterURL(true, &validated_params.referrer.url);
999 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); 1005 for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
1000 it != validated_params.redirects.end(); ++it) { 1006 it != validated_params.redirects.end(); ++it) {
1001 process->FilterURL(false, &(*it)); 1007 process->FilterURL(false, &(*it));
1002 } 1008 }
1003 process->FilterURL(true, &validated_params.searchable_form_url); 1009 process->FilterURL(true, &validated_params.searchable_form_url);
1004 1010
1005 // Without this check, the renderer can trick the browser into using 1011 // Without this check, the renderer can trick the browser into using
1006 // filenames it can't access in a future session restore. 1012 // filenames it can't access in a future session restore.
1007 if (!render_view_host_->CanAccessFilesOfPageState( 1013 if (!render_view_host_->CanAccessFilesOfPageState(
1008 validated_params.page_state)) { 1014 validated_params.page_state)) {
1009 bad_message::ReceivedBadMessage( 1015 bad_message::ReceivedBadMessage(
1010 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); 1016 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE);
1017 // PlzNavigate: release the stream now that the renderer is going away.
1018 stream_handle_.reset();
nasko 2016/03/18 20:41:14 Instead of putting these in all cases where we kil
clamy 2016/03/22 16:46:55 Actually we already do (in the SiteInstance versio
1011 return; 1019 return;
1012 } 1020 }
1013 1021
1014 // If the URL does not match what the NavigationHandle expects, treat the 1022 // If the URL does not match what the NavigationHandle expects, treat the
1015 // commit as a new navigation. This can happen if an ongoing slow 1023 // commit as a new navigation. This can happen if an ongoing slow
1016 // same-process navigation is interrupted by a synchronous renderer-initiated 1024 // same-process navigation is interrupted by a synchronous renderer-initiated
1017 // navigation. 1025 // navigation.
1018 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get 1026 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get
1019 // reset here, because the NavigationHandle tracks the URL but the 1027 // reset here, because the NavigationHandle tracks the URL but the
1020 // validated_params.url tracks the data. The trick of saving the old entry ids 1028 // validated_params.url tracks the data. The trick of saving the old entry ids
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame(); 2705 FrameTreeNode* focused_frame_tree_node = frame_tree_->GetFocusedFrame();
2698 if (!focused_frame_tree_node) 2706 if (!focused_frame_tree_node)
2699 return; 2707 return;
2700 RenderFrameHostImpl* focused_frame = 2708 RenderFrameHostImpl* focused_frame =
2701 focused_frame_tree_node->current_frame_host(); 2709 focused_frame_tree_node->current_frame_host();
2702 DCHECK(focused_frame); 2710 DCHECK(focused_frame);
2703 dst->focused_tree_id = focused_frame->GetAXTreeID(); 2711 dst->focused_tree_id = focused_frame->GetAXTreeID();
2704 } 2712 }
2705 2713
2706 } // namespace content 2714 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/security_exploit_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698