[tbb-commits] [tor-browser/geckoview-95.0b12-11.5-1] Bug 40432: Prevent probing installed applications

sysrqb at torproject.org sysrqb at torproject.org
Fri Dec 17 16:47:53 UTC 2021


commit d4d8f562f9f44a0135672f80bffcc648a0b53162
Author: Matthew Finkel <sysrqb at torproject.org>
Date:   Mon May 17 18:09:09 2021 +0000

    Bug 40432: Prevent probing installed applications
---
 .../exthandler/nsExternalHelperAppService.cpp      | 30 ++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index 9961ecf30977..019f453cb0ef 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1057,8 +1057,33 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath(
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 // begin external protocol service default implementation...
 //////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static const char kExternalProtocolPrefPrefix[] =
+    "network.protocol-handler.external.";
+static const char kExternalProtocolDefaultPref[] =
+    "network.protocol-handler.external-default";
+
 NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(
     const char* aProtocolScheme, bool* aHandlerExists) {
+
+  // Replicate the same check performed in LoadURI.
+  // Deny load if the prefs say to do so
+  nsAutoCString externalPref(kExternalProtocolPrefPrefix);
+  externalPref += aProtocolScheme;
+  bool allowLoad = false;
+  *aHandlerExists = false;
+  if (NS_FAILED(Preferences::GetBool(externalPref.get(), &allowLoad))) {
+    // no scheme-specific value, check the default
+    if (NS_FAILED(
+            Preferences::GetBool(kExternalProtocolDefaultPref, &allowLoad))) {
+      return NS_OK;  // missing default pref
+    }
+  }
+
+  if (!allowLoad) {
+    return NS_OK;  // explicitly denied
+  }
+
   nsCOMPtr<nsIHandlerInfo> handlerInfo;
   nsresult rv = GetProtocolHandlerInfo(nsDependentCString(aProtocolScheme),
                                        getter_AddRefs(handlerInfo));
@@ -1101,11 +1126,6 @@ NS_IMETHODIMP nsExternalHelperAppService::IsExposedProtocol(
   return NS_OK;
 }
 
-static const char kExternalProtocolPrefPrefix[] =
-    "network.protocol-handler.external.";
-static const char kExternalProtocolDefaultPref[] =
-    "network.protocol-handler.external-default";
-
 // static
 nsresult nsExternalHelperAppService::EscapeURI(nsIURI* aURI, nsIURI** aResult) {
   MOZ_ASSERT(aURI);



More information about the tbb-commits mailing list