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

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2022083002: Move 'frame-src' CSP checks into FrameFetchContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yoav Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index 2b94715d0ecbb29575518815d8c9543d0edae911..049b83c77e82d474863f808581dcb64d8dc32885 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -201,7 +201,7 @@ void FrameLoader::init()
initialRequest.setRequestContext(WebURLRequest::RequestContextInternal);
initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initialRequest, SubstituteData());
- m_provisionalDocumentLoader->startLoadingMainResource();
+ m_provisionalDocumentLoader->startLoadingMainResource(CheckContentSecurityPolicy);
m_frame->document()->cancelParsing();
m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
takeObjectSnapshot();
@@ -1359,30 +1359,14 @@ bool FrameLoader::shouldClose(bool isReload)
}
bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& request, const SubstituteData& substituteData,
- DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy,
- NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryItem, bool isClientRedirect)
+ DocumentLoader* loader, NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryItem, bool isClientRedirect)
{
// Don't ask if we are loading an empty URL.
if (request.url().isEmpty() || substituteData.isValid())
return true;
- // If we're loading content into a subframe, check against the parent's Content Security Policy
- // and kill the load if that check fails, unless we should bypass the main world's CSP.
- if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) {
- Frame* parentFrame = m_frame->tree().parent();
- if (parentFrame) {
- ContentSecurityPolicy* parentPolicy = parentFrame->securityContext()->contentSecurityPolicy();
- if (!parentPolicy->allowChildFrameFromSource(request.url(), request.redirectStatus())) {
- // Fire a load event, as timing attacks would otherwise reveal that the
- // frame was blocked. This way, it looks like every other cross-origin
- // page load.
- m_frame->document()->enforceSandboxFlags(SandboxOrigin);
- m_frame->owner()->dispatchLoad();
- return false;
- }
- }
- }
-
+ // TODO(mkwst): Look into moving this to 'FrameFetchContext::canRequestInternal' alongside the
+ // 'frame-src' checks.
bool isFormSubmission = type == NavigationTypeFormSubmitted || type == NavigationTypeFormResubmitted;
if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allowFormAction(request.url()))
return false;
@@ -1413,7 +1397,7 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
frameLoadRequest.resourceRequest().setRequestContext(determineRequestContextFromNavigationType(navigationType));
frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
ResourceRequest& request = frameLoadRequest.resourceRequest();
- if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteData(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLoadRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect))
+ if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteData(), nullptr, navigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLoadRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect))
return;
m_frame->document()->cancelParsing();
@@ -1449,7 +1433,7 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
double triggeringEventTime = frameLoadRequest.triggeringEvent() ? frameLoadRequest.triggeringEvent()->platformTimeStamp() : 0;
client()->dispatchDidStartProvisionalLoad(triggeringEventTime);
ASSERT(m_provisionalDocumentLoader);
- m_provisionalDocumentLoader->startLoadingMainResource();
+ m_provisionalDocumentLoader->startLoadingMainResource(frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy());
takeObjectSnapshot();
}

Powered by Google App Engine
This is Rietveld 408576698