Sandbox escape: content process can navigate chrome windows with SystemPrincipal via [@ ClientManagerService::Navigate]
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: bugmon, Unassigned)
References
Details
(6 keywords)
Attachments
(3 files)
|
353 bytes,
text/html
|
Details | |
|
8.31 KB,
patch
|
Details | Diff | Splinter Review | |
|
7.24 KB,
text/plain
|
Details |
Summary
A compromised content process can navigate the parent process's chrome browser window (chrome://browser/content/browser.xhtml) to an attacker-chosen URL with SystemPrincipal as the triggering principal. The root cause is that ClientManagerService::Navigate in /firefox/dom/clients/manager/ClientManagerService.cpp receives aOriginContent (identifying the requesting content process) but never validates it. Combined with missing authorization in ClientSourceParent::StartOp (which lets any process set a chrome window's controller) and ClientMatchPrincipalInfo (which unconditionally matches SystemPrincipal), a content process can cause ClientNavigateOpChild::DoNavigate to run in the parent process and call docShell->LoadURI() using browser.xhtml's SystemPrincipal.
Affected Code
File: dom/clients/manager/ClientManagerService.cpp, lines 405-452
RefPtr<ClientOpPromise> ClientManagerService::Navigate(
ThreadsafeContentParentHandle* aOriginContent, // <-- NEVER USED
const ClientNavigateArgs& aArgs) {
ClientSourceParent* source =
FindExistingSource(aArgs.target().id(), aArgs.target().principalInfo());
...
// Only checks that controller matches attacker-supplied SW descriptor.
// The attacker set this controller via Control() — both sides are attacker-controlled.
const Maybe<ServiceWorkerDescriptor>& controller = source->GetController();
if (controller.isNothing() ||
controller.ref().Scope() != serviceWorker.scope() ||
controller.ref().Id() != serviceWorker.id()) {
...reject...
}
PClientManagerParent* manager = source->Manager(); // <-- chrome window's in-process manager
...
// Sends PClientNavigateOpConstructor to ClientManagerChild running IN THE PARENT PROCESS
PClientNavigateOpParent* result =
manager->SendPClientNavigateOpConstructor(op, args);
File: dom/clients/manager/ClientSourceParent.cpp, lines 213-235
RefPtr<ClientOpPromise> ClientSourceParent::StartOp(
ClientOpConstructorArgs&& aArgs) {
...
// NO authorization check — any process with a ClientHandle can set controller
if (aArgs.type() == ClientOpConstructorArgs::TClientControlledArgs) {
mController.reset();
mController.emplace(aArgs.get_ClientControlledArgs().serviceWorker());
}
File: dom/clients/manager/ClientNavigateOpChild.cpp, lines 238-262
// Runs IN THE PARENT PROCESS when target is a chrome window
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal(); // <-- SystemPrincipal for browser.xhtml
...
loadState->SetTriggeringPrincipal(principal); // <-- SystemPrincipal!
...
rv = docShell->LoadURI(loadState, false); // Navigate chrome window with SystemPrincipal
File: dom/clients/manager/ClientPrincipalUtils.cpp, lines 29-32
case PrincipalInfo::TSystemPrincipalInfo: {
// system principal always matches
return true; // <-- Content process can forge SystemPrincipalInfo to match chrome windows
}
Exploit Chain
- Content process crafts an
IPCServiceWorkerDescriptorwithSystemPrincipalInfo(no validation exists). - Content sends
PClientManagerOp(ClientMatchAllArgs)with the fake descriptor andincludeUncontrolled=true.ClientManagerService::MatchAlliteratesmSourceTableand callsClientMatchPrincipalInfo(source, SystemPrincipal)which returnstruefor all chrome windows. Parent returns the list includingbrowser.xhtml's client ID. - Content sends
PClientHandleConstructorwithbrowser.xhtml'sIPCClientInfo.ClientHandleParent::InitcallsFindSource(id, SystemPrincipal)— matches. - Content sends
PClientHandleOp(ClientControlledArgs)with the fake SW descriptor.ClientHandleOpParent::Init→ClientSourceParent::StartOpsetsmControlleron the chrome source with no authorization check. - Content sends
PClientManagerOp(ClientNavigateArgs)withbrowser.xhtml'sIPCClientInfo, attacker URL, and the fake SW descriptor.ClientManagerService::Navigate:FindExistingSource(id, SystemPrincipal)finds chrome window ✓- Controller check:
mControllermatches the fake descriptor (we just set it) ✓ source->Manager()returns the in-processPClientManagerParent(chrome windows use same-process PBackground)SendPClientNavigateOpConstructordispatches toClientManagerChildon the parent process main thread
ClientNavigateOpChild::DoNavigateruns in the parent process: getsbrowser.xhtml's document, usesdoc->NodePrincipal()(SystemPrincipal) asTriggeringPrincipal, callsdocShell->LoadURI()with attacker URL.- With
about:crashparent:nsAboutRedirector::NewChannelchecksTriggeringPrincipal()->IsSystemPrincipal()— passes — createsCrashChannel→MOZ_CRASH.
IPC Path
- Protocol:
PClientManager/PClientHandle/PClientNavigateOp(overPBackground) - Parent side:
ClientManagerOpParent,ClientHandleOpParent,ClientSourceParent,ClientManagerService(PBackground thread) - Child side (attacker): Content process sends
PClientManagerOpConstructor(ClientMatchAllArgs),PClientHandleConstructor,PClientHandleOpConstructor(ClientControlledArgs),PClientManagerOpConstructor(ClientNavigateArgs) - Pivot:
ClientManagerService::Navigatecallssource->Manager()->SendPClientNavigateOpConstructor()— for chrome windows this dispatches to the parent's own in-processClientManagerChild, causingClientNavigateOpChild::DoNavigateto execute on the parent main thread with the chrome document's SystemPrincipal
Steps to Reproduce
- Apply the provided patch to
/firefox/dom/clients/manager/ClientSource.cppand/firefox/dom/clients/manager/ClientNavigateOpChild.cpp(simulates a compromised content process sending crafted IPC). - Rebuild Firefox.
- Load any
http://page — the exploit triggers fromClientSource::WindowExecutionReadywhen the first content window becomes ready.
Security Impact
Severity: Critical (sandbox escape).
Attacker capability: A compromised content process (e.g., via a renderer RCE) can navigate the parent's chrome browser window to an arbitrary URL with SystemPrincipal as the triggering principal. This grants:
- Access to any SystemPrincipal-gated navigation target (
about:,chrome://,resource://) - Ability to replace
browser.xhtmlentirely, controlling all UI the user sees - Potential chrome-privileged script execution via
javascript:URLs or principal-inheriting loads in the chrome docshell
Preconditions: Attacker must first achieve code execution in a content process. No user interaction required beyond loading a web page.
Note on demonstration: The MOZ_CRASH via about:crashparent is not a defensive mitigation — it is the attacker's chosen proof-of-concept. The SystemPrincipal gate at nsAboutRedirector.cpp:267 explicitly rejects non-SystemPrincipal callers; passing it demonstrates the content process achieved SystemPrincipal-level navigation.
Suggested Fix
Validate the origin content process in all ClientManagerService operations that accept attacker-controlled principal data:
// In ClientManagerService.cpp, add a helper:
static bool ValidateContentPrincipal(ThreadsafeContentParentHandle* aOriginContent,
const PrincipalInfo& aPrincipal) {
// Content processes must never claim SystemPrincipal or ExpandedPrincipal
if (aOriginContent &&
aPrincipal.type() != PrincipalInfo::TContentPrincipalInfo &&
aPrincipal.type() != PrincipalInfo::TNullPrincipalInfo) {
return false;
}
return true;
}
// In Navigate, MatchAll, Claim, GetInfoAndState — add at the top:
if (!ValidateContentPrincipal(aOriginContent, aArgs.target().principalInfo()) ||
!ValidateContentPrincipal(aOriginContent, aArgs.serviceWorker().principalInfo())) {
return ClientOpPromise::CreateAndReject(
CopyableErrorResult(NS_ERROR_DOM_SECURITY_ERR), __func__);
}
Additionally, ClientManagerService::Navigate should verify that source->Manager() belongs to the same process as aOriginContent, or that the requesting process legitimately hosts the controlling service worker (cross-check with ServiceWorkerManager rather than trusting the IPC-supplied descriptor). ClientSourceParent::StartOp should similarly validate that the handle's owning process is authorized to control the source.
| Reporter | ||
Comment 1•7 months ago
|
||
| Reporter | ||
Comment 2•7 months ago
|
||
| Reporter | ||
Comment 3•7 months ago
|
||
Updated•7 months ago
|
Updated•7 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Comment 8•3 months ago
|
||
Related bugs (NOT duplicates): the parent trusts content-initiated Clients-API IPC in distinct ops -- ClientHandleOpParent op-type not validated / controller-state forge (2061777), ClientManagerService::Navigate SystemPrincipal chrome nav (2028006), ClientOpenWindow child principal (2018164). Same family, separate defects.
Updated•11 days ago
|
Description
•