Closed Bug 2028006 Opened 7 months ago Closed 7 months ago

Sandbox escape: content process can navigate chrome windows with SystemPrincipal via [@ ClientManagerService::Navigate]

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2018164

People

(Reporter: bugmon, Unassigned)

References

Details

(6 keywords)

Attachments

(3 files)

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

  1. Content process crafts an IPCServiceWorkerDescriptor with SystemPrincipalInfo (no validation exists).
  2. Content sends PClientManagerOp(ClientMatchAllArgs) with the fake descriptor and includeUncontrolled=true. ClientManagerService::MatchAll iterates mSourceTable and calls ClientMatchPrincipalInfo(source, SystemPrincipal) which returns true for all chrome windows. Parent returns the list including browser.xhtml's client ID.
  3. Content sends PClientHandleConstructor with browser.xhtml's IPCClientInfo. ClientHandleParent::Init calls FindSource(id, SystemPrincipal) — matches.
  4. Content sends PClientHandleOp(ClientControlledArgs) with the fake SW descriptor. ClientHandleOpParent::Init → ClientSourceParent::StartOp sets mController on the chrome source with no authorization check.
  5. Content sends PClientManagerOp(ClientNavigateArgs) with browser.xhtml's IPCClientInfo, attacker URL, and the fake SW descriptor. ClientManagerService::Navigate:
    • FindExistingSource(id, SystemPrincipal) finds chrome window ✓
    • Controller check: mController matches the fake descriptor (we just set it) ✓
    • source->Manager() returns the in-process PClientManagerParent (chrome windows use same-process PBackground)
    • SendPClientNavigateOpConstructor dispatches to ClientManagerChild on the parent process main thread
  6. ClientNavigateOpChild::DoNavigate runs in the parent process: gets browser.xhtml's document, uses doc->NodePrincipal() (SystemPrincipal) as TriggeringPrincipal, calls docShell->LoadURI() with attacker URL.
  7. With about:crashparent: nsAboutRedirector::NewChannel checks TriggeringPrincipal()->IsSystemPrincipal() — passes — creates CrashChannel → MOZ_CRASH.

IPC Path

  • Protocol: PClientManager / PClientHandle / PClientNavigateOp (over PBackground)
  • Parent side: ClientManagerOpParent, ClientHandleOpParent, ClientSourceParent, ClientManagerService (PBackground thread)
  • Child side (attacker): Content process sends PClientManagerOpConstructor(ClientMatchAllArgs), PClientHandleConstructor, PClientHandleOpConstructor(ClientControlledArgs), PClientManagerOpConstructor(ClientNavigateArgs)
  • Pivot: ClientManagerService::Navigate calls source->Manager()->SendPClientNavigateOpConstructor() — for chrome windows this dispatches to the parent's own in-process ClientManagerChild, causing ClientNavigateOpChild::DoNavigate to execute on the parent main thread with the chrome document's SystemPrincipal

Steps to Reproduce

  1. Apply the provided patch to /firefox/dom/clients/manager/ClientSource.cpp and /firefox/dom/clients/manager/ClientNavigateOpChild.cpp (simulates a compromised content process sending crafted IPC).
  2. Rebuild Firefox.
  3. Load any http:// page — the exploit triggers from ClientSource::WindowExecutionReady when 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.xhtml entirely, 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.

Attached file testcase.html —
Attached patch exploit.patch — — Splinter Review
Attached file crash_stack.txt —
Group: core-security → dom-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 7 months ago
Duplicate of bug: 2027994
Resolution: --- → DUPLICATE
Duplicate of bug: 2022259
No longer duplicate of bug: 2027994
Duplicate of bug: 2018164
No longer duplicate of bug: 2022259

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.

See Also: → 2018164
Group: dom-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: