Bug 1346774: do not check frame-ancestors for non-CSP eligible URLs r?ckerschb draft
authorFrederik Braun <fbraun+gh@mozilla.com>
Mon, 27 Mar 2017 14:34:44 +0200
changeset 559678 95028f8c9942b9a3f5523715c19160a7a33bfb04
parent 559677 ccc6986cd646524d766286978b1b218f829ad57d
child 559679 e05b11d82b14c1390aff3844a07e7c4cce2a23c5
push id53163
push userbmo:fbraun@mozilla.com
push dateMon, 10 Apr 2017 11:09:42 +0000
reviewersckerschb
bugs1346774
milestone55.0a1
Bug 1346774: do not check frame-ancestors for non-CSP eligible URLs r?ckerschb MozReview-Commit-ID: C1602j5j3My
dom/security/nsCSPContext.cpp
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCOMPtr.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsCSPContext.h"
 #include "nsCSPParser.h"
 #include "nsCSPService.h"
+#include "nsCSPUtils.h"
 #include "nsError.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMNode.h"
@@ -1267,16 +1268,22 @@ nsCSPContext::PermitsAncestry(nsIDocShel
 
     nsIDocument* doc = parentTreeItem->GetDocument();
     NS_ASSERTION(doc, "Could not get nsIDocument from nsIDocShellTreeItem in nsCSPContext::PermitsAncestry");
     NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
 
     currentURI = doc->GetDocumentURI();
 
     if (currentURI) {
+
+      // skip items in ancestor tree if the URI is not CSP eligible
+      if (!CSP_IsRequestSubjectToCSP(currentURI, nsIContentPolicy::TYPE_SUBDOCUMENT)) {
+        continue;
+      }
+
       // delete the userpass from the URI.
       rv = currentURI->CloneIgnoringRef(getter_AddRefs(uriClone));
       NS_ENSURE_SUCCESS(rv, rv);
 
       // We don't care if this succeeds, just want to delete a userpass if
       // there was one.
       uriClone->SetUserPass(EmptyCString());