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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2655463006: PlzNavigate: Enforce 'frame-src' CSP on the browser. (Closed)
Patch Set: Add TODO in the FrameLoader. Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 bool FrameLoader::shouldContinueForNavigationPolicy( 1621 bool FrameLoader::shouldContinueForNavigationPolicy(
1622 const ResourceRequest& request, 1622 const ResourceRequest& request,
1623 const SubstituteData& substituteData, 1623 const SubstituteData& substituteData,
1624 DocumentLoader* loader, 1624 DocumentLoader* loader,
1625 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy, 1625 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy,
1626 NavigationType type, 1626 NavigationType type,
1627 NavigationPolicy policy, 1627 NavigationPolicy policy,
1628 FrameLoadType frameLoadType, 1628 FrameLoadType frameLoadType,
1629 bool isClientRedirect, 1629 bool isClientRedirect,
1630 HTMLFormElement* form) { 1630 HTMLFormElement* form) {
1631 Settings* settings = m_frame->settings();
1632 bool browserSideNavigationEnabled =
1633 settings && settings->getBrowserSideNavigationEnabled();
1634
1631 // Don't ask if we are loading an empty URL. 1635 // Don't ask if we are loading an empty URL.
1632 if (request.url().isEmpty() || substituteData.isValid()) 1636 if (request.url().isEmpty() || substituteData.isValid())
1633 return true; 1637 return true;
1634 1638
1635 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check 1639 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check
1636 // against the parent's Content Security Policy and kill the load if that 1640 // against the parent's Content Security Policy and kill the load if that
1637 // check fails, unless we should bypass the main world's CSP. 1641 // check fails, unless we should bypass the main world's CSP.
1638 if (policy == NavigationPolicyCurrentTab && 1642 if (policy == NavigationPolicyCurrentTab &&
1639 shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) { 1643 shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy &&
1644 // TODO(arthursonzogni): 'frame-src' check is disabled on the
1645 // renderer-side with browser-side-navigation, but is enforced on the
1646 // browser-side. See http://crbug.com/692595 for understanding why it
1647 // can't be enforced on both side instead.
1648 !browserSideNavigationEnabled) {
1640 Frame* parentFrame = m_frame->tree().parent(); 1649 Frame* parentFrame = m_frame->tree().parent();
1641 if (parentFrame) { 1650 if (parentFrame) {
1642 ContentSecurityPolicy* parentPolicy = 1651 ContentSecurityPolicy* parentPolicy =
1643 parentFrame->securityContext()->contentSecurityPolicy(); 1652 parentFrame->securityContext()->contentSecurityPolicy();
1644 if (!parentPolicy->allowFrameFromSource(request.url(), 1653 if (!parentPolicy->allowFrameFromSource(request.url(),
1645 request.redirectStatus())) { 1654 request.redirectStatus())) {
1646 // Fire a load event, as timing attacks would otherwise reveal that the 1655 // Fire a load event, as timing attacks would otherwise reveal that the
1647 // frame was blocked. This way, it looks like every other cross-origin 1656 // frame was blocked. This way, it looks like every other cross-origin
1648 // page load. 1657 // page load.
1649 m_frame->document()->enforceSandboxFlags(SandboxOrigin); 1658 m_frame->document()->enforceSandboxFlags(SandboxOrigin);
1650 m_frame->owner()->dispatchLoad(); 1659 m_frame->owner()->dispatchLoad();
1651 return false; 1660 return false;
1652 } 1661 }
1653 } 1662 }
1654 } 1663 }
1655 1664
1656 bool isFormSubmission = type == NavigationTypeFormSubmitted || 1665 bool isFormSubmission = type == NavigationTypeFormSubmitted ||
1657 type == NavigationTypeFormResubmitted; 1666 type == NavigationTypeFormResubmitted;
1658 if (isFormSubmission && 1667 if (isFormSubmission &&
1659 !m_frame->document()->contentSecurityPolicy()->allowFormAction( 1668 !m_frame->document()->contentSecurityPolicy()->allowFormAction(
1660 request.url())) 1669 request.url()))
1661 return false; 1670 return false;
1662 1671
1663 bool replacesCurrentHistoryItem = 1672 bool replacesCurrentHistoryItem =
1664 frameLoadType == FrameLoadTypeReplaceCurrentItem; 1673 frameLoadType == FrameLoadTypeReplaceCurrentItem;
1665 policy = client()->decidePolicyForNavigation(request, loader, type, policy, 1674 policy = client()->decidePolicyForNavigation(
1666 replacesCurrentHistoryItem, 1675 request, loader, type, policy, replacesCurrentHistoryItem,
1667 isClientRedirect, form); 1676 isClientRedirect, form, shouldCheckMainWorldContentSecurityPolicy);
1668 if (policy == NavigationPolicyCurrentTab) 1677 if (policy == NavigationPolicyCurrentTab)
1669 return true; 1678 return true;
1670 if (policy == NavigationPolicyIgnore) 1679 if (policy == NavigationPolicyIgnore)
1671 return false; 1680 return false;
1672 if (policy == NavigationPolicyHandledByClient) { 1681 if (policy == NavigationPolicyHandledByClient) {
1673 m_isNavigationHandledByClient = true; 1682 m_isNavigationHandledByClient = true;
1674 // Mark the frame as loading since the embedder is handling the navigation. 1683 // Mark the frame as loading since the embedder is handling the navigation.
1675 m_progressTracker->progressStarted(frameLoadType); 1684 m_progressTracker->progressStarted(frameLoadType);
1676 1685
1677 m_frame->navigationScheduler().cancel(); 1686 m_frame->navigationScheduler().cancel();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 frameLoadRequest.clientRedirect()); 2019 frameLoadRequest.clientRedirect());
2011 2020
2012 loader->setLoadType(loadType); 2021 loader->setLoadType(loadType);
2013 loader->setNavigationType(navigationType); 2022 loader->setNavigationType(navigationType);
2014 loader->setReplacesCurrentHistoryItem(loadType == 2023 loader->setReplacesCurrentHistoryItem(loadType ==
2015 FrameLoadTypeReplaceCurrentItem); 2024 FrameLoadTypeReplaceCurrentItem);
2016 return loader; 2025 return loader;
2017 } 2026 }
2018 2027
2019 } // namespace blink 2028 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698