Firefox · DOM
CVE-2026-6761
Logic Error in DOM
Overview
Medium
Severity
—
CVSS
No
Exploited ITW
Fixed
Fix Status
Files Changed
dom/network/TCPSocket.cppdom/network/TCPSocketParent.cppdom/network/tests/chrome.tomlipc/glue/BackgroundParentImpl.cppmodules/libpref/init/StaticPrefList.yamlnetwerk/ipc/NeckoParent.cpp
Patch
diff --git a/dom/network/TCPSocket.cpp b/dom/network/TCPSocket.cpp
index f222bcffe43..84c2d9cf890 100644
--- a/dom/network/TCPSocket.cpp
+++ b/dom/network/TCPSocket.cpp
@@ -9,6 +9,7 @@
#include "TCPSocketParent.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/ErrorResult.h"
+#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/ScriptSettings.h"
@@ -1162,6 +1163,10 @@ TCPSocket::Observe(nsISupports* aSubject, const char* aTopic,
/* static */
bool TCPSocket::ShouldTCPSocketExist(JSContext* aCx, JSObject* aGlobal) {
+ if (XRE_IsContentProcess() &&
+ !StaticPrefs::dom_tcpsocket_in_child_enabled()) {
+ return false;
+ }
JS::Rooted<JSObject*> global(aCx, aGlobal);
return nsContentUtils::ObjectPrincipal(global)->IsSystemPrincipal();
}
diff --git a/dom/network/TCPSocketParent.cpp b/dom/network/TCPSocketParent.cpp
index c8507d26bd1..5335c995a62 100644
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -8,6 +8,7 @@
#include "jsapi.h"
#include "jsfriendapi.h"
#include "mozilla/HoldDropJSObjects.h"
+#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/net/NeckoCommon.h"
@@ -76,6 +77,9 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketParent::Release(void) {
mozilla::ipc::IPCResult TCPSocketParent::RecvOpen(
const nsString& aHost, const uint16_t& aPort, const bool& aUseSSL,
const bool& aUseArrayBuffers) {
+ if (!StaticPrefs::dom_tcpsocket_in_child_enabled()) {
+ return IPC_FAIL(this, "tcp socket not enabled");
+ }
mSocket = new TCPSocket(nullptr, aHost, aPort, aUseSSL, aUseArrayBuffers);
mSocket->SetSocketBridgeParent(this);
NS_ENSURE_SUCCESS(mSocket->Init(nullptr), IPC_OK());
diff --git a/dom/network/tests/chrome.toml b/dom/network/tests/chrome.toml
index c22fe385722..7a769cff8d3 100644
--- a/dom/network/tests/chrome.toml
+++ b/dom/network/tests/chrome.toml
@@ -1,4 +1,5 @@
[DEFAULT]
+prefs = ["dom.tcpsocket_in_child.enabled=true"]
support-files = [
"tcpsocket_test.sys.mjs",
"test_tcpsocket_client_and_server_basics.js",
diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp
index 41cd94bebc0..5dcb289ca8a 100644
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -677,6 +677,10 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPUDPSocketConstructor(
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
+ if (!StaticPrefs::dom_udpsocket_enabled()) {
+ return IPC_FAIL(this, "udp socket not enabled");
+ }
+
if (aOptionalPrincipal.isSome()) {
// Support for checking principals (for non-mtransport use) will be handled
// in bug 1167039
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
index fa44179af45..c397e21ec10 100644
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -5282,6 +5282,12 @@
value: 30000
mirror: always
+# TCPSocket API
+- name: dom.tcpsocket_in_child.enabled
+ type: RelaxedAtomicBool
+ value: false
+ mirror: always
+
# UDPSocket API
- name: dom.udpsocket.enabled
type: bool
diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp
index c54751a8b5c..32e67c61752 100644
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -505,6 +505,9 @@ PTCPServerSocketParent* NeckoParent::AllocPTCPServerSocketParent(
mozilla::ipc::IPCResult NeckoParent::RecvPTCPServerSocketConstructor(
PTCPServerSocketParent* aActor, const uint16_t& aLocalPort,
const uint16_t& aBacklog, const bool& aUseArrayBuffers) {
+ if (!StaticPrefs::dom_tcpsocket_in_child_enabled()) {
+ return IPC_FAIL(this, "tcp socket not enabled");
+ }
static_cast<TCPServerSocketParent*>(aActor)->Init();
return IPC_OK();
}
@@ -525,6 +528,9 @@ PUDPSocketParent* NeckoParent::AllocPUDPSocketParent(
mozilla::ipc::IPCResult NeckoParent::RecvPUDPSocketConstructor(
PUDPSocketParent* aActor, nsIPrincipal* aPrincipal,
const nsACString& aFilter) {
+ if (!StaticPrefs::dom_udpsocket_enabled()) {
+ return IPC_FAIL(this, "udp socket not enabled");
+ }
if (!static_cast<UDPSocketParent*>(aActor)->Init(aPrincipal, aFilter)) {
return IPC_FAIL_NO_REASON(this);
}
Loading diff…
Regression Test / PoC
shipped with the fix
diff --git a/dom/network/tests/chrome.toml b/dom/network/tests/chrome.toml index c22fe385722..7a769cff8d3 100644 --- a/dom/network/tests/chrome.toml +++ b/dom/network/tests/chrome.toml @@ -1,4 +1,5 @@ [DEFAULT] +prefs = ["dom.tcpsocket_in_child.enabled=true"] support-files = [ "tcpsocket_test.sys.mjs", "test_tcpsocket_client_and_server_basics.js",
Loading diff…
References
On This Page