Sandbox escape: PTCPSocket/PTCPServerSocket IPC lacks parent-side authorization — compromised content process can open arbitrary TCP connections from parent
Categories
(Core :: Networking, defect)
Tracking
()
People
(Reporter: s3zer0, Unassigned)
Details
(Keywords: ai-involved, reporter-external, Whiteboard: [client-bounty-form])
Background
The mozTCPSocket API (originally added for Firefox OS / B2G in Bug 797561) is gated at the JavaScript level via [Func="mozilla::dom::TCPSocket::ShouldTCPSocketExist"] in the WebIDL, which checks IsSystemPrincipal(). This prevents normal web content from accessing the API through JavaScript.
However, the underlying IPC protocol (PTCPSocket, managed by PNecko) has no corresponding parent-side authorization. A compromised content process that can send raw IPC messages bypasses the JavaScript gate entirely.
Vulnerability Details
PTCPSocket (outbound connections):
-
PNecko.ipdldeclaresmanages PTCPSocket;with no[ChildProc=...]restriction. PNecko is managed by PContent, so every web content process has a PNecko actor. -
NeckoParent::AllocPTCPSocketParent()(netwerk/ipc/NeckoParent.cpp) performs zero authorization checks:
PTCPSocketParent* NeckoParent::AllocPTCPSocketParent(
const nsAString& /* host */, const uint16_t& /* port */) {
TCPSocketParent* p = new TCPSocketParent();
p->AddIPDLReference();
return p;
}
TCPSocketParent::RecvOpen()(dom/network/TCPSocketParent.cpp) creates a real TCP connection in the parent process with no validation:
mozilla::ipc::IPCResult TCPSocketParent::RecvOpen(
const nsString& aHost, const uint16_t& aPort,
const bool& aUseSSL, const bool& aUseArrayBuffers) {
mSocket = new TCPSocket(nullptr, aHost, aPort, aUseSSL, aUseArrayBuffers);
mSocket->SetSocketBridgeParent(this);
NS_ENSURE_SUCCESS(mSocket->Init(nullptr), IPC_OK());
return IPC_OK();
}
-
TCPSocket::Init()(dom/network/TCPSocket.cpp), when running in the parent process (XRE_IsContentProcess()returns false), callssts->CreateTransport()to open a real TCP socket to the attacker-specified host:port with no security checks. -
The connection is fully bidirectional: data received on the socket is sent back to the content process via
FireArrayBufferDataEvent()/FireStringDataEvent()→PTCPSocketParent::SendCallback().
PTCPServerSocket (listening sockets):
The identical pattern exists for PTCPServerSocket:
NeckoParent::AllocPTCPServerSocketParent()— zero checksNeckoParent::RecvPTCPServerSocketConstructor()— callsInit()directlyTCPServerSocketParent::Init()— opens a listening socket in the parent process
Attack Chain
Compromised content process
→ PContent → PNecko (every content process has one)
→ PTCPSocket("target.internal", 80) // no ChildProc restriction
→ NeckoParent::AllocPTCPSocketParent // no authorization check
→ TCPSocketParent::RecvOpen // no authorization check
→ TCPSocket::Init() // parent process path
→ CreateTransport(host, port) // real TCP connection!
→ bidirectional data via SendCallback
Contrast with Properly Defended NeckoParent Handlers
Other handlers in the same file correctly validate the caller:
RecvGetPageThumbStream: enforcesPRIVILEGEDABOUT_REMOTE_TYPEprocess checkRecvGetExtensionStream: validates moz-extension scheme, host registration, and directory containmentRecvPUDPSocketConstructor: rejects requests from content processes
PTCPSocket and PTCPServerSocket are missing equivalent checks.
Root Cause
The mozTCPSocket API was added for Firefox OS (B2G) where it was gated by app permissions. When Firefox OS was discontinued, the JavaScript-level gate (ShouldTCPSocketExist → IsSystemPrincipal()) was retained, but it only controls WebIDL visibility and does not protect the IPC boundary. The Fission IPC hardening effort (Bug 1484019) does not include PTCPSocket/PTCPServerSocket in its tracked sub-bugs.
Historical context:
- Bug 782542 (2012): Necko IPC security added, but focused on cookie/cache AppID validation, not TCPSocket
- Bug 891954 (2013): Necko IPC security disabled for desktop e10s (only relevant for B2G multi-app model)
- Bug 1322254 (2020):
UsingNeckoIPCSecuritycode entirely removed as dead code
Steps to Reproduce
From a compromised content process (e.g., after exploiting a JIT or memory corruption bug):
-
Send
PTCPSocketconstructor message via the existing PNecko actor:
PNecko::SendPTCPSocketConstructor("192.168.1.1", 22) -
Send
RecvOpenon the constructed actor:
PTCPSocket::SendOpen("192.168.1.1", 22, false, true) -
The parent process opens a TCP connection to
192.168.1.1:22and begins relaying data bidirectionally viaSendCallback. -
For a listening socket:
PNecko::SendPTCPServerSocketConstructor(4444, 5, true)
This opens port 4444 on the victim's machine.
Attack Scenarios
- Internal network SSRF: Access cloud metadata endpoints (169.254.169.254), internal databases, admin panels from the parent process
- Port scanning: Probe internal network topology from the parent process
- Listening sockets: Open arbitrary ports on the victim's machine (reverse shell listener, pivot point)
- Data exfiltration: Bypass content sandbox network restrictions for data theft
- TLS connections:
useSSL=trueenables encrypted connections to internal services
Impact
- Severity: sec-high / sec-critical (sandbox escape — full network access from parent process)
- Affected: All platforms, all Firefox versions with e10s/Fission (the IPC path has been unprotected since Bug 891954 in 2013)
- Prerequisite: Code execution in a content process (standard sandbox escape threat model, cf. CVE-2025-2857, CVE-2024-9680)
Affected Files
netwerk/ipc/PNecko.ipdl— manages PTCPSocket/PTCPServerSocket, no ChildProc restrictionnetwerk/ipc/NeckoParent.cpp— AllocPTCPSocketParent, AllocPTCPServerSocketParent (no checks)dom/network/TCPSocketParent.cpp— RecvOpen (no checks)dom/network/TCPSocket.cpp— ShouldTCPSocketExist (JS-only gate), Init() (no parent-side check)dom/network/PTCPSocket.ipdl— protocol definitiondom/network/TCPServerSocketParent.cpp— same pattern for listening sockets
Updated•8 months ago
|
Updated•8 months ago
|
Comment 1•8 months ago
|
||
Seems like a dupe of bug 2017857
Updated•8 months ago
|
Updated•2 months ago
|
Description
•