Bug 1554805 - Never set firstPartyDomain on origin attributes for moz-extension. r=rpl,Ehsan,tjr a=RyanVM
authorJohann Hofmann <jhofmann@mozilla.com>
Sun, 06 Oct 2019 15:43:39 +0000
changeset 523874 084856145376476fbdeb90e2fe457007c9e1824a
parent 523873 632ebba5e525ae40a45a697b4730a43ec2343030
child 523875 d54afc3153e3760c7bc2795d2a81d8a40cd81e24
push id489
push userryanvm@gmail.com
push dateMon, 21 Oct 2019 19:21:55 +0000
treeherdermozilla-esr68@d54afc3153e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl, Ehsan, tjr, RyanVM
bugs1554805
milestone68.3.0
Bug 1554805 - Never set firstPartyDomain on origin attributes for moz-extension. r=rpl,Ehsan,tjr a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D47425
caps/OriginAttributes.cpp
--- a/caps/OriginAttributes.cpp
+++ b/caps/OriginAttributes.cpp
@@ -87,16 +87,23 @@ void OriginAttributes::SetFirstPartyDoma
   nsAutoCString scheme;
   rv = aURI->GetScheme(scheme);
   NS_ENSURE_SUCCESS_VOID(rv);
   if (scheme.EqualsLiteral("about")) {
     mFirstPartyDomain.AssignLiteral(ABOUT_URI_FIRST_PARTY_DOMAIN);
     return;
   }
 
+  // Add-on principals should never get any first-party domain
+  // attributes in order to guarantee their storage integrity when switching
+  // FPI on and off.
+  if (scheme.EqualsLiteral("moz-extension")) {
+    return;
+  }
+
   nsCOMPtr<nsIPrincipal> blobPrincipal;
   if (dom::BlobURLProtocolHandler::GetBlobURLPrincipal(
           aURI, getter_AddRefs(blobPrincipal))) {
     MOZ_ASSERT(blobPrincipal);
     mFirstPartyDomain = blobPrincipal->OriginAttributesRef().mFirstPartyDomain;
     return;
   }