Medium firefox Logic Error 🔧 Commit mapped

Overview

Medium
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
Impactmoderate
DescriptionLeaking of file descriptors from the fork server to web content processes could allow for privilege escalation attacks.
ComponentSecurity/NSS
Bug ClassLogic Error
Tracker1949987
Fix commit77a968c0cd35 (firefox) +14/-3
CISA KEVNot listed
CreditedThinker Li
Disclosed2025-04-01

Files Changed

  • ipc/glue/ForkServer.cpp
  • ipc/glue/ForkServer.h
  • ipc/glue/GeckoChildProcessHost.cpp
  • security/sandbox/linux/launch/SandboxLaunch.cpp
diff --git a/ipc/glue/ForkServer.cpp b/ipc/glue/ForkServer.cpp
index 7b846b5d807..ba368de1575 100644
--- a/ipc/glue/ForkServer.cpp
+++ b/ipc/glue/ForkServer.cpp
@@ -47,7 +47,9 @@ ForkServer::ForkServer(int* aArgc, char*** aArgv) : mArgc(aArgc), mArgv(aArgv) {
     MOZ_CRASH("forkserver missing ipcHandle argument");
   }
 
-  mTcver = MakeUnique<MiniTransceiver>(ipcHandle->release(),
+  // Hold our IPC FD while our MiniTransceiver is alive.
+  mIpcFd = ipcHandle.extract();
+  mTcver = MakeUnique<MiniTransceiver>(mIpcFd.get(),
                                        DataBufferClear::AfterReceiving);
 }
 
diff --git a/ipc/glue/ForkServer.h b/ipc/glue/ForkServer.h
index eb04a2089d5..51fb473e922 100644
--- a/ipc/glue/ForkServer.h
+++ b/ipc/glue/ForkServer.h
@@ -27,6 +27,7 @@ class ForkServer {
   static bool RunForkServer(int* aArgc, char*** aArgv);
 
  private:
+  UniqueFileHandle mIpcFd;
   UniquePtr<MiniTransceiver> mTcver;
 
   int* mArgc;
diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp
index b0c74483ac4..755f90a4594 100644
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -1120,7 +1120,8 @@ Result<Ok, LaunchError> BaseProcessLauncher::DoSetup() {
   geckoargs::sParentPid.Put(static_cast<uint64_t>(base::GetCurrentProcId()),
                             mChildArgs);
 
-  if (!CrashReporter::IsDummy() && CrashReporter::GetEnabled()) {
+  if (!CrashReporter::IsDummy() && CrashReporter::GetEnabled() &&
+      mProcessType != GeckoProcessType_ForkServer) {
 #if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
     geckoargs::sCrashReporter.Put(CrashReporter::GetChildNotificationPipe(),
                                   mChildArgs);
@@ -1310,6 +1311,12 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
 
   mChildArgs.mArgs.push_back(ChildProcessType());
 
+#  ifdef MOZ_ENABLE_FORKSERVER
+  MOZ_ASSERT(mProcessType != GeckoProcessType_ForkServer ||
+                 mChildArgs.mFiles.size() == 1,
+             "The ForkServer only expects a single FD argument");
+#  endif
+
 #  if !defined(MOZ_WIDGET_ANDROID)
   // Add any files which need to be transferred to fds_to_remap.
   // NOTE: This doesn't transfer ownership of the files out of `mChildArgs`.
diff --git a/security/sandbox/linux/launch/SandboxLaunch.cpp b/security/sandbox/linux/launch/SandboxLaunch.cpp
index 0c916941158..0c2f62b5d59 100644
--- a/security/sandbox/linux/launch/SandboxLaunch.cpp
+++ b/security/sandbox/linux/launch/SandboxLaunch.cpp
@@ -306,7 +306,8 @@ bool SandboxLaunch::Configure(GeckoProcessType aType, SandboxingKind aKind,
   // At this point, we know we'll be using sandboxing; generic
   // sandboxing support goes here.
   PreloadSandboxLib(&aOptions->env_map);
-  if (!AttachSandboxReporter(aExtraOpts)) {
+  if (aType != GeckoProcessType_ForkServer &&
+      !AttachSandboxReporter(aExtraOpts)) {
     return false;
   }
 
Loading diff…