[tor-commits] [tor-browser] 62/64: Bug 40432: Prevent probing installed applications

gitolite role git at cupani.torproject.org
Thu Apr 21 16:22:04 UTC 2022


This is an automated email from the git hooks/post-receive script.

aguestuser pushed a commit to branch geckoview-99.0b3-11.5-2
in repository tor-browser.

commit eae79a407e815fa495c29766532f1790f000974e
Author: Matthew Finkel <sysrqb at torproject.org>
AuthorDate: 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 88fbb333590c3..61d597ca6b205 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1139,8 +1139,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));
@@ -1183,11 +1208,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);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list