diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 3234bfaab92f..3c69180a3263 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -22,6 +22,7 @@ #include "mozilla/Telemetry.h" #include "mozilla/unused.h" #include "mozilla/VisualEventTracer.h" +#include "URIUtils.h" #ifdef MOZ_LOGGING // so we can get logging even in release builds (but only for some things) @@ -4559,16 +4560,24 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, // if this is a Strict-Transport-Security host and the cert // is bad, don't allow overrides (STS Spec section 7.3). - nsCOMPtr sss = - do_GetService(NS_SSSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - uint32_t flags = - mInPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0; - + uint32_t type = nsISiteSecurityService::HEADER_HSTS; + uint32_t flags = mInPrivateBrowsing + ? nsISocketProvider::NO_PERMANENT_STORAGE + : 0; bool isStsHost = false; - rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, - aURI, flags, &isStsHost); - NS_ENSURE_SUCCESS(rv, rv); + if (XRE_GetProcessType() == GeckoProcessType_Default) { + nsCOMPtr sss = + do_GetService(NS_SSSERVICE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + rv = sss->IsSecureURI(type, aURI, flags, &isStsHost); + NS_ENSURE_SUCCESS(rv, rv); + } else { + mozilla::dom::ContentChild* cc = + mozilla::dom::ContentChild::GetSingleton(); + mozilla::ipc::URIParams uri; + SerializeURI(aURI, uri); + cc->SendIsSecureURI(type, uri, flags, &isStsHost); + } uint32_t bucketId; if (isStsHost) { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 1a0fd0facdbd..3dfe0bf6d73c 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -98,6 +98,7 @@ #include "nsIPresShell.h" #include "nsIRemoteBlob.h" #include "nsIScriptError.h" +#include "nsISiteSecurityService.h" #include "nsIStyleSheet.h" #include "nsISupportsPrimitives.h" #include "nsIURIFixup.h" @@ -3239,6 +3240,23 @@ ContentParent::RecvGetSystemMemory(const uint64_t& aGetterId) return true; } +bool +ContentParent::RecvIsSecureURI(const uint32_t& type, + const URIParams& uri, + const uint32_t& flags, + bool* isSecureURI) +{ + nsCOMPtr sss(do_GetService(NS_SSSERVICE_CONTRACTID)); + if (!sss) { + return false; + } + nsCOMPtr ourURI = DeserializeURI(uri); + if (!ourURI) { + return false; + } + nsresult rv = sss->IsSecureURI(type, ourURI, flags, isSecureURI); + return NS_SUCCEEDED(rv); +} bool ContentParent::RecvLoadURIExternal(const URIParams& uri) diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index f2546c1b8445..f29895120cf7 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -422,6 +422,9 @@ private: virtual bool RecvGetRandomValues(const uint32_t& length, InfallibleTArray* randomValues) MOZ_OVERRIDE; + virtual bool RecvIsSecureURI(const uint32_t& type, const URIParams& uri, + const uint32_t& flags, bool* isSecureURI); + virtual bool DeallocPHalParent(PHalParent*) MOZ_OVERRIDE; virtual bool DeallocPIndexedDBParent(PIndexedDBParent* aActor) MOZ_OVERRIDE; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 3f6a86529a4e..e3581bec1a34 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -478,6 +478,9 @@ parent: async GetSystemMemory(uint64_t getterId); + sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags) + returns (bool isSecureURI); + PHal(); PIndexedDB(); diff --git a/security/manager/boot/src/nsSiteSecurityService.cpp b/security/manager/boot/src/nsSiteSecurityService.cpp index 3cab048ec8f6..30cc0de889bd 100644 --- a/security/manager/boot/src/nsSiteSecurityService.cpp +++ b/security/manager/boot/src/nsSiteSecurityService.cpp @@ -20,6 +20,7 @@ #include "mozilla/Preferences.h" #include "mozilla/LinkedList.h" #include "nsSecurityHeaderParser.h" +#include "nsXULAppAPI.h" // A note about the preload list: // When a site specifically disables sts by sending a header with @@ -87,6 +88,11 @@ NS_IMPL_ISUPPORTS(nsSiteSecurityService, nsresult nsSiteSecurityService::Init() { + // Child processes are not allowed direct access to this. + if (XRE_GetProcessType() != GeckoProcessType_Default) { + MOZ_CRASH("Child process: no direct access to nsSiteSecurityService"); + } + nsresult rv; mPermMgr = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);