Bug 1297156: Check favicon loads from the system principal against the content policy. draft
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 11 Apr 2018 12:56:00 -0700
changeset 780714 1c5532d3395792985df7e057a4ca8ca45479cf22
parent 780713 490748389a401067742e9d307432004dd8334edf
child 780715 81bfd5cadb33ac9544a37de22c0980d22eb91ce7
push id106099
push userdtownsend@mozilla.com
push dateWed, 11 Apr 2018 20:47:47 +0000
bugs1297156
milestone61.0a1
Bug 1297156: Check favicon loads from the system principal against the content policy. When a system principled xul:image element attempts to load anything we currently bypass content policy checks. This change makes us continue to respect the content policy when loading favicons. MozReview-Commit-ID: B3CUXqtvsqG
dom/base/nsContentPolicyUtils.h
--- a/dom/base/nsContentPolicyUtils.h
+++ b/dom/base/nsContentPolicyUtils.h
@@ -170,17 +170,18 @@ NS_CP_ContentTypeName(uint32_t contentTy
   nsCOMPtr<nsIURI> requestOrigin;                                             \
   PR_BEGIN_MACRO                                                              \
   if (loadingPrincipal) {                                                     \
       /* We exempt most loads into any document with the system principal     \
        * from content policy checks, mostly as an optimization. Which means   \
        * that we need to apply this check to the loading principal, not the   \
        * principal that triggered the load. */                                \
       bool isSystem = loadingPrincipal->GetIsSystemPrincipal();               \
-      if (isSystem && contentType != nsIContentPolicy::TYPE_DOCUMENT) {       \
+      if (isSystem && contentType != nsIContentPolicy::TYPE_DOCUMENT &&       \
+          contentType != nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {     \
           *decision = nsIContentPolicy::ACCEPT;                               \
           nsCOMPtr<nsINode> n = do_QueryInterface(context);                   \
           if (!n) {                                                           \
               nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(context);  \
               n = win ? win->GetExtantDoc() : nullptr;                        \
           }                                                                   \
           if (n) {                                                            \
               nsIDocument* d = n->OwnerDoc();                                 \