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

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

Issue 2869423002: PlzNavigate: Do not disclose urls between cross-origin renderers. (Closed)
Patch Set: Add [ Failure ] for virtual/off-main-thread-fetch/[...]/onload-detach-during-csp-frame-src-none.html Created 3 years, 7 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 #include "mojo/public/cpp/bindings/strong_binding.h" 113 #include "mojo/public/cpp/bindings/strong_binding.h"
114 #include "mojo/public/cpp/system/data_pipe.h" 114 #include "mojo/public/cpp/system/data_pipe.h"
115 #include "services/service_manager/public/cpp/connector.h" 115 #include "services/service_manager/public/cpp/connector.h"
116 #include "services/service_manager/public/cpp/interface_provider.h" 116 #include "services/service_manager/public/cpp/interface_provider.h"
117 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h" 117 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
118 #include "ui/accessibility/ax_tree.h" 118 #include "ui/accessibility/ax_tree.h"
119 #include "ui/accessibility/ax_tree_id_registry.h" 119 #include "ui/accessibility/ax_tree_id_registry.h"
120 #include "ui/accessibility/ax_tree_update.h" 120 #include "ui/accessibility/ax_tree_update.h"
121 #include "ui/gfx/geometry/quad_f.h" 121 #include "ui/gfx/geometry/quad_f.h"
122 #include "url/gurl.h" 122 #include "url/gurl.h"
123 #include "url/origin.h"
123 124
124 #if defined(OS_ANDROID) 125 #if defined(OS_ANDROID)
125 #include "content/browser/android/java_interfaces_impl.h" 126 #include "content/browser/android/java_interfaces_impl.h"
126 #include "content/browser/frame_host/render_frame_host_android.h" 127 #include "content/browser/frame_host/render_frame_host_android.h"
127 #include "content/browser/media/android/media_player_renderer.h" 128 #include "content/browser/media/android/media_player_renderer.h"
128 #include "content/public/browser/android/java_interfaces.h" 129 #include "content/public/browser/android/java_interfaces.h"
129 #include "media/base/audio_renderer_sink.h" 130 #include "media/base/audio_renderer_sink.h"
130 #include "media/base/video_renderer_sink.h" 131 #include "media/base/video_renderer_sink.h"
131 #include "media/mojo/services/mojo_renderer_service.h" // nogncheck 132 #include "media/mojo/services/mojo_renderer_service.h" // nogncheck
132 #endif 133 #endif
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 // process should be ignored until the next commit. 968 // process should be ignored until the next commit.
968 set_nav_entry_id(0); 969 set_nav_entry_id(0);
969 } 970 }
970 971
971 void RenderFrameHostImpl::ReportContentSecurityPolicyViolation( 972 void RenderFrameHostImpl::ReportContentSecurityPolicyViolation(
972 const CSPViolationParams& violation_params) { 973 const CSPViolationParams& violation_params) {
973 Send(new FrameMsg_ReportContentSecurityPolicyViolation(routing_id_, 974 Send(new FrameMsg_ReportContentSecurityPolicyViolation(routing_id_,
974 violation_params)); 975 violation_params));
975 } 976 }
976 977
978 void RenderFrameHostImpl::SanitizeDataForUseInCspViolation(
979 bool is_redirect,
980 CSPDirective::Name directive,
981 GURL* blocked_url,
982 SourceLocation* source_location) const {
983 DCHECK(blocked_url);
984 DCHECK(source_location);
985 GURL source_location_url(source_location->url);
986
987 // The main goal of this is to avoid leaking information between potentially
988 // separate renderers, in the event of one of them being compromised.
989 // See https://crbug.com/633306.
990 bool sanitize_blocked_url = true;
991 bool sanitize_source_location = true;
992
993 // There is no need to sanitize data when it is same-origin with the current
994 // url of the renderer.
995 if (url::Origin(*blocked_url).IsSameOriginWith(last_committed_origin_))
996 sanitize_blocked_url = false;
997 if (url::Origin(source_location_url).IsSameOriginWith(last_committed_origin_))
998 sanitize_source_location = false;
999
1000 // When a renderer tries to do a form submission, it already knows the url of
1001 // the blocked url, except when it is redirected.
1002 if (!is_redirect && directive == CSPDirective::FormAction)
1003 sanitize_blocked_url = false;
1004
1005 if (sanitize_blocked_url)
1006 *blocked_url = blocked_url->GetOrigin();
1007 if (sanitize_source_location) {
1008 *source_location =
1009 SourceLocation(source_location_url.GetOrigin().spec(), 0u, 0u);
1010 }
1011 }
1012
977 bool RenderFrameHostImpl::SchemeShouldBypassCSP( 1013 bool RenderFrameHostImpl::SchemeShouldBypassCSP(
978 const base::StringPiece& scheme) { 1014 const base::StringPiece& scheme) {
979 // Blink uses its SchemeRegistry to check if a scheme should be bypassed. 1015 // Blink uses its SchemeRegistry to check if a scheme should be bypassed.
980 // It can't be used on the browser process. It is used for two things: 1016 // It can't be used on the browser process. It is used for two things:
981 // 1) Bypassing the "chrome-extension" scheme when chrome is built with the 1017 // 1) Bypassing the "chrome-extension" scheme when chrome is built with the
982 // extensions support. 1018 // extensions support.
983 // 2) Bypassing arbitrary scheme for testing purpose only in blink and in V8. 1019 // 2) Bypassing arbitrary scheme for testing purpose only in blink and in V8.
984 // TODO(arthursonzogni): url::GetBypassingCSPScheme() is used instead of the 1020 // TODO(arthursonzogni): url::GetBypassingCSPScheme() is used instead of the
985 // blink::SchemeRegistry. It contains 1) but not 2). 1021 // blink::SchemeRegistry. It contains 1) but not 2).
986 const auto& bypassing_schemes = url::GetCSPBypassingSchemes(); 1022 const auto& bypassing_schemes = url::GetCSPBypassingSchemes();
(...skipping 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 } 3970 }
3935 3971
3936 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( 3972 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame(
3937 const std::string& interface_name, 3973 const std::string& interface_name,
3938 mojo::ScopedMessagePipeHandle pipe) { 3974 mojo::ScopedMessagePipeHandle pipe) {
3939 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); 3975 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe));
3940 } 3976 }
3941 #endif 3977 #endif
3942 3978
3943 } // namespace content 3979 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/content_security_policy/content_security_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698