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

Side by Side Diff: content/browser/web_contents/render_view_host_manager.cc

Issue 12210048: Prevent bindings escalation on an existing NavigationEntry (attempt 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.h ('k') | 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 (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 #include "content/browser/web_contents/render_view_host_manager.h" 5 #include "content/browser/web_contents/render_view_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "content/browser/devtools/render_view_devtools_agent_host.h" 11 #include "content/browser/devtools/render_view_devtools_agent_host.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_factory.h" 13 #include "content/browser/renderer_host/render_view_host_factory.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
16 #include "content/browser/web_contents/interstitial_page_impl.h" 16 #include "content/browser/web_contents/interstitial_page_impl.h"
17 #include "content/browser/web_contents/navigation_controller_impl.h" 17 #include "content/browser/web_contents/navigation_controller_impl.h"
18 #include "content/browser/web_contents/navigation_entry_impl.h" 18 #include "content/browser/web_contents/navigation_entry_impl.h"
19 #include "content/browser/webui/web_ui_impl.h" 19 #include "content/browser/webui/web_ui_impl.h"
20 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
21 #include "content/port/browser/render_widget_host_view_port.h" 21 #include "content/port/browser/render_widget_host_view_port.h"
22 #include "content/public/browser/content_browser_client.h" 22 #include "content/public/browser/content_browser_client.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/user_metrics.h"
25 #include "content/public/browser/web_contents_view.h" 26 #include "content/public/browser/web_contents_view.h"
26 #include "content/public/browser/web_ui_controller.h" 27 #include "content/public/browser/web_ui_controller.h"
27 #include "content/public/browser/web_ui_controller_factory.h" 28 #include "content/public/browser/web_ui_controller_factory.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/common/url_constants.h" 30 #include "content/public/common/url_constants.h"
30 31
31 namespace content { 32 namespace content {
32 33
33 RenderViewHostManager::RenderViewHostManager( 34 RenderViewHostManager::RenderViewHostManager(
34 RenderViewHostDelegate* render_view_delegate, 35 RenderViewHostDelegate* render_view_delegate,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 91 }
91 92
92 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { 93 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const {
93 if (interstitial_page_) 94 if (interstitial_page_)
94 return interstitial_page_->GetView(); 95 return interstitial_page_->GetView();
95 if (!render_view_host_) 96 if (!render_view_host_)
96 return NULL; 97 return NULL;
97 return render_view_host_->GetView(); 98 return render_view_host_->GetView();
98 } 99 }
99 100
101 void RenderViewHostManager::SetPendingWebUI(const NavigationEntryImpl& entry) {
102 pending_web_ui_.reset(
103 delegate_->CreateWebUIForRenderManager(entry.GetURL()));
104 pending_and_current_web_ui_.reset();
105
106 // If this is an existing NavigationEntry, make sure we're not granting it
107 // different bindings than it had before. If so, note it and don't give it
108 // any bindings, to avoid a potential privilege escalation.
109 if (pending_web_ui_.get() &&
110 !entry.GetContentState().empty() &&
nasko 2013/02/13 23:44:02 This seems redundant, since we already check the b
Charlie Reis 2013/02/13 23:56:18 Good point! Updated.
111 entry.bindings() != NavigationEntryImpl::kInvalidBindings &&
112 pending_web_ui_->GetBindings() != entry.bindings()) {
113 RecordAction(UserMetricsAction("ProcessSwapBindingsMismatch_RVHM"));
114 pending_web_ui_.reset();
115 }
116 }
117
100 RenderViewHostImpl* RenderViewHostManager::Navigate( 118 RenderViewHostImpl* RenderViewHostManager::Navigate(
101 const NavigationEntryImpl& entry) { 119 const NavigationEntryImpl& entry) {
102 // Create a pending RenderViewHost. It will give us the one we should use 120 // Create a pending RenderViewHost. It will give us the one we should use
103 RenderViewHostImpl* dest_render_view_host = 121 RenderViewHostImpl* dest_render_view_host =
104 static_cast<RenderViewHostImpl*>(UpdateRendererStateForNavigate(entry)); 122 static_cast<RenderViewHostImpl*>(UpdateRendererStateForNavigate(entry));
105 if (!dest_render_view_host) 123 if (!dest_render_view_host)
106 return NULL; // We weren't able to create a pending render view host. 124 return NULL; // We weren't able to create a pending render view host.
107 125
108 // If the current render_view_host_ isn't live, we should create it so 126 // If the current render_view_host_ isn't live, we should create it so
109 // that we don't show a sad tab while the dest_render_view_host fetches 127 // that we don't show a sad tab while the dest_render_view_host fetches
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { 825 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) {
808 // New SiteInstance. 826 // New SiteInstance.
809 DCHECK(!cross_navigation_pending_); 827 DCHECK(!cross_navigation_pending_);
810 828
811 // This will possibly create (set to NULL) a Web UI object for the pending 829 // This will possibly create (set to NULL) a Web UI object for the pending
812 // page. We'll use this later to give the page special access. This must 830 // page. We'll use this later to give the page special access. This must
813 // happen before the new renderer is created below so it will get bindings. 831 // happen before the new renderer is created below so it will get bindings.
814 // It must also happen after the above conditional call to CancelPending(), 832 // It must also happen after the above conditional call to CancelPending(),
815 // otherwise CancelPending may clear the pending_web_ui_ and the page will 833 // otherwise CancelPending may clear the pending_web_ui_ and the page will
816 // not have its bindings set appropriately. 834 // not have its bindings set appropriately.
817 pending_web_ui_.reset( 835 SetPendingWebUI(entry);
818 delegate_->CreateWebUIForRenderManager(entry.GetURL()));
819 pending_and_current_web_ui_.reset();
820 836
821 // Ensure that we have created RVHs for the new RVH's opener chain if 837 // Ensure that we have created RVHs for the new RVH's opener chain if
822 // we are staying in the same BrowsingInstance. This allows the pending RVH 838 // we are staying in the same BrowsingInstance. This allows the pending RVH
823 // to send cross-process script calls to its opener(s). 839 // to send cross-process script calls to its opener(s).
824 int opener_route_id = MSG_ROUTING_NONE; 840 int opener_route_id = MSG_ROUTING_NONE;
825 if (new_instance->IsRelatedSiteInstance(curr_instance)) { 841 if (new_instance->IsRelatedSiteInstance(curr_instance)) {
826 opener_route_id = 842 opener_route_id =
827 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); 843 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance);
828 } 844 }
829 845
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 // doesn't otherwise know that the cross-site request is happening. This 890 // doesn't otherwise know that the cross-site request is happening. This
875 // will trigger a call to ShouldClosePage with the reply. 891 // will trigger a call to ShouldClosePage with the reply.
876 render_view_host_->FirePageBeforeUnload(true); 892 render_view_host_->FirePageBeforeUnload(true);
877 893
878 return pending_render_view_host_; 894 return pending_render_view_host_;
879 } else { 895 } else {
880 if (ShouldReuseWebUI(curr_entry, &entry)) { 896 if (ShouldReuseWebUI(curr_entry, &entry)) {
881 pending_web_ui_.reset(); 897 pending_web_ui_.reset();
882 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); 898 pending_and_current_web_ui_ = web_ui_->AsWeakPtr();
883 } else { 899 } else {
884 pending_and_current_web_ui_.reset(); 900 SetPendingWebUI(entry);
885 pending_web_ui_.reset(
886 delegate_->CreateWebUIForRenderManager(entry.GetURL()));
887 } 901 }
888 902
889 if (pending_web_ui() && render_view_host_->IsRenderViewLive()) 903 if (pending_web_ui() && render_view_host_->IsRenderViewLive())
890 pending_web_ui()->GetController()->RenderViewReused(render_view_host_); 904 pending_web_ui()->GetController()->RenderViewReused(render_view_host_);
891 905
892 // The renderer can exit view source mode when any error or cancellation 906 // The renderer can exit view source mode when any error or cancellation
893 // happen. We must overwrite to recover the mode. 907 // happen. We must overwrite to recover the mode.
894 if (entry.IsViewSourceMode()) { 908 if (entry.IsViewSourceMode()) {
895 render_view_host_->Send( 909 render_view_host_->Send(
896 new ViewMsg_EnableViewSourceMode(render_view_host_->GetRoutingID())); 910 new ViewMsg_EnableViewSourceMode(render_view_host_->GetRoutingID()));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 987 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
974 SiteInstance* instance) { 988 SiteInstance* instance) {
975 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 989 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
976 if (iter != swapped_out_hosts_.end()) 990 if (iter != swapped_out_hosts_.end())
977 return iter->second; 991 return iter->second;
978 992
979 return NULL; 993 return NULL;
980 } 994 }
981 995
982 } // namespace content 996 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698