Medium firefox Sandbox Escape 🔧 Commit mapped

Overview

Medium
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
Impactmoderate
DescriptionFirefox for Android allowed a sandboxed iframe without the <code>allow-downloads</code> attribute to start downloads.
ComponentDOM
Bug ClassSandbox Escape
Tracker1791322
Fix commit3350c1e440f6 (firefox) +15/-6
CISA KEVNot listed
CreditedAxel Chong (@Haxatron)
Disclosed2025-07-22

Changed Functions

FunctionChangeNotes
if
mobile/android/components/geckoview/GeckoViewStreamListener.cpp
modified
if
uriloader/exthandler/nsExternalHelperAppService.cpp
modified

Files Changed

  • dom/security/nsContentSecurityUtils.cpp
  • dom/security/nsContentSecurityUtils.h
  • mobile/android/components/geckoview/GeckoViewStreamListener.cpp
  • uriloader/exthandler/nsExternalHelperAppService.cpp
diff --git a/dom/security/nsContentSecurityUtils.cpp b/dom/security/nsContentSecurityUtils.cpp
index 528beff667f..6e04c8b21f1 100644
--- a/dom/security/nsContentSecurityUtils.cpp
+++ b/dom/security/nsContentSecurityUtils.cpp
@@ -2204,8 +2204,7 @@ void nsContentSecurityUtils::LogMessageToConsole(nsIHttpChannel* aChannel,
 }
 
 /* static */
-long nsContentSecurityUtils::ClassifyDownload(
-    nsIChannel* aChannel, const nsAutoCString& aMimeTypeGuess) {
+long nsContentSecurityUtils::ClassifyDownload(nsIChannel* aChannel) {
   MOZ_ASSERT(aChannel, "IsDownloadAllowed without channel?");
 
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
diff --git a/dom/security/nsContentSecurityUtils.h b/dom/security/nsContentSecurityUtils.h
index 73102441f58..324ec302c7d 100644
--- a/dom/security/nsContentSecurityUtils.h
+++ b/dom/security/nsContentSecurityUtils.h
@@ -74,8 +74,7 @@ class nsContentSecurityUtils {
       const mozilla::dom::Element& aElement);
 
   // Helper function to Check if a Download is allowed;
-  static long ClassifyDownload(nsIChannel* aChannel,
-                               const nsAutoCString& aMimeTypeGuess);
+  static long ClassifyDownload(nsIChannel* aChannel);
 
   // Public only for testing
   static FilenameTypeAndDetails FilenameToFilenameType(
diff --git a/mobile/android/components/geckoview/GeckoViewStreamListener.cpp b/mobile/android/components/geckoview/GeckoViewStreamListener.cpp
index 71b9fadeb50..387e5ce2eb2 100644
--- a/mobile/android/components/geckoview/GeckoViewStreamListener.cpp
+++ b/mobile/android/components/geckoview/GeckoViewStreamListener.cpp
@@ -16,6 +16,8 @@
 #include "nsIWebProgressListener.h"
 #include "nsIX509Cert.h"
 #include "nsPrintfCString.h"
+#include "nsContentSecurityUtils.h"
+#include "nsITransfer.h"
 
 #include "nsNetUtil.h"
 
@@ -85,6 +87,16 @@ GeckoViewStreamListener::OnStartRequest(nsIRequest* aRequest) {
     return NS_OK;
   }
 
+  nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
+  if (channel) {
+    int32_t classification = nsContentSecurityUtils::ClassifyDownload(channel);
+    if (classification == nsITransfer::DOWNLOAD_FORBIDDEN) {
+      channel->Cancel(NS_ERROR_ABORT);
+      CompleteWithError(NS_ERROR_ABORT, channel);
+      return NS_OK;
+    }
+  }
+
   // We're expecting data later via OnDataAvailable, so create the stream now.
   InitializeStreamSupport(aRequest);
 
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index cd4d745890a..5bd60b585b5 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1621,8 +1621,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
     return NS_OK;
   }
 
-  mDownloadClassification =
-      nsContentSecurityUtils::ClassifyDownload(aChannel, MIMEType);
+  mDownloadClassification = nsContentSecurityUtils::ClassifyDownload(aChannel);
 
   if (mDownloadClassification == nsITransfer::DOWNLOAD_FORBIDDEN) {
     // If the download is rated as forbidden,
Loading diff…