Missing principal validation in PServiceWorkerRegistration constructor allows compromised content process to steal cross-origin notification data
Categories
(Core :: DOM: Service Workers, defect)
Tracking
()
People
(Reporter: bugmon, Unassigned)
References
Details
(5 keywords)
Attachments
(7 files)
PServiceWorkerRegistration is a PBackground-managed IPC actor whose constructor carries a fully child-controlled IPCServiceWorkerRegistrationDescriptor (PrincipalInfo, scope, id, version) and IPCClientInfo (including another PrincipalInfo). BackgroundParentImpl::AllocPServiceWorkerRegistrationParent / RecvPServiceWorkerRegistrationConstructor perform no validation whatsoever — no BackgroundParent::ValidatePrincipal call and no scoping of the descriptor to the sending process — in contrast to sibling constructors such as RecvCreateNotificationParent in the same file, which validates both principals.
ServiceWorkerRegistrationParent::Init builds a ServiceWorkerRegistrationProxy directly from the child-supplied data, and ServiceWorkerRegistrationProxy::InitOnMainThread attaches the actor to whatever registration in the global ServiceWorkerManager registry matches the child-supplied (principal origin, scope, id). Registration ids come from a process-global sequential counter (ServiceWorkerRegistrationInfo::GetNextId: static uint64_t sNextId; ++sNextId) and are trivially brute-forceable. A compromised content process can therefore attach a parent-side actor to ANY other origin's service worker registration and invoke its Recv handlers: RecvGetNotifications returns the victim origin's persisted notification content (title, body, tag, structured-clone data) using the forged client principal and scope — demonstrated cross-origin data theft; RecvUnregister destroys the victim origin's registration; RecvSetNavigationPreloadEnabled/Header mutate and persist the victim's navigation preload state, injecting an attacker-controlled Service-Worker-Navigation-Preload header into the victim's future navigations; RecvUpdate forces update jobs on the victim registration.
The attack was reproduced end-to-end with a pristine parent process: the attacker origin http://127.0.0.1:<port> received, in ordinary page JavaScript, the notification title and body persisted by the distinct origin http://localhost:<port> — data it could never obtain through any web API. This is a site-isolation/sandbox-boundary violation reachable by any compromised content process.
Build Info
- Branch: main
- Revision: b5f92c07c92ce1a6870d2905c7594487e53dfeac
- Timestamp: 2026-07-13T01:27:29+00:00
Affected Code
File: ipc/glue/BackgroundParentImpl.cpp, line 1324-1337
already_AddRefed<PServiceWorkerRegistrationParent>
BackgroundParentImpl::AllocPServiceWorkerRegistrationParent(
const IPCServiceWorkerRegistrationDescriptor&, const IPCClientInfo&) {
return MakeAndAddRef<mozilla::dom::ServiceWorkerRegistrationParent>();
}
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPServiceWorkerRegistrationConstructor(
PServiceWorkerRegistrationParent* aActor,
const IPCServiceWorkerRegistrationDescriptor& aDescriptor,
const IPCClientInfo& aForClient) {
// NO BackgroundParent::ValidatePrincipal on aDescriptor.principalInfo()
// or aForClient.principalInfo() -- both are fully child-controlled.
dom::InitServiceWorkerRegistrationParent(aActor, aDescriptor, aForClient);
return IPC_OK();
}
File: dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp, line 78-101
void ServiceWorkerRegistrationProxy::InitOnMainThread() {
AssertIsOnMainThread();
auto scopeExit = MakeScopeExit([&] { MaybeShutdownOnMainThread(); });
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
NS_ENSURE_TRUE_VOID(swm);
// Lookup keyed ONLY by the child-supplied principal origin and scope;
// no check that the sending process is related to that origin.
RefPtr<ServiceWorkerRegistrationInfo> reg =
swm->GetRegistration(mDescriptor.PrincipalInfo(), mDescriptor.Scope());
NS_ENSURE_TRUE_VOID(reg);
if (reg->Id() != mDescriptor.Id()) {
// This registration has already been replaced by another one.
return;
}
scopeExit.release();
mReg = new nsMainThreadPtrHolder<ServiceWorkerRegistrationInfo>(
"ServiceWorkerRegistrationProxy::mInfo", reg);
mReg->AddInstance(this, mDescriptor);
}
File: dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp, line 493-516
RefPtr<NotificationsPromise> ServiceWorkerRegistrationProxy::GetNotifications(
const nsAString& aTag) {
AssertIsOnBackgroundThread();
RefPtr<ServiceWorkerRegistrationProxy> self = this;
return InvokeAsync(
GetMainThreadSerialEventTarget(), __func__,
[self, tag = nsString(aTag)]() {
// mListeningClientInfo comes verbatim from the forged IPCClientInfo.
Result<nsCOMPtr<nsIPrincipal>, nsresult> principalResult =
self->mListeningClientInfo.GetPrincipal();
if (principalResult.isErr()) {
return NotificationsPromise::CreateAndReject(
NS_ERROR_DOM_INVALID_STATE_ERR, __func__);
}
nsCOMPtr<nsIPrincipal> principal = principalResult.unwrap();
nsString origin;
GetOrigin(principal, origin);
// Returns the VICTIM origin's persisted notifications to the sender.
RefPtr<NotificationsPromise> promise = GetStoredNotificationsForScope(
principal, self->mDescriptor.Scope(), tag);
return promise;
});
}
File: dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp, line 904-908
uint64_t ServiceWorkerRegistrationInfo::GetNextId() {
MOZ_ASSERT(NS_IsMainThread());
static uint64_t sNextId = 0; // process-global sequential counter,
return ++sNextId; // trivially brute-forceable
}
File: ipc/glue/BackgroundParentImpl.cpp, line 505-527
// CONTRAST: the notification constructor in the same file DOES validate:
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateNotificationParent(
Endpoint<dom::notification::PNotificationParent>&& aParentEndpoint,
NotNull<nsIPrincipal*> aPrincipal,
NotNull<nsIPrincipal*> aEffectiveStoragePrincipal,
const bool& aIsSecureContext, const nsAString& aScope,
const IPCNotification& aNotification,
CreateNotificationParentResolver&& aResolver) {
...
if (!BackgroundParent::ValidatePrincipal(this, aPrincipal, {})) {
ContentParent::LogAndAssertFailedPrincipalValidationInfo(aPrincipal,
__func__);
return IPC_FAIL(this, "Invalid aPrincipal for CreateNotificationParent");
}
...
The constructor performs no validation of the child-supplied principals (contrast RecvCreateNotificationParent at line 515 of the same file, which calls BackgroundParent::ValidatePrincipal on both principals). The proxy then attaches to any registration in the global registry keyed solely by the child-supplied principal origin, scope, and guessable sequential id, and GetNotifications queries the notification database with the forged client principal.
Exploit Chain
- Attacker achieves arbitrary code execution in a content process (e.g. via a renderer bug) — simulated in the PoC by an XRE_IsContentProcess()-guarded hook; the parent process is unmodified.
- Attacker crafts an IPCServiceWorkerRegistrationDescriptor with the victim origin's PrincipalInfo, the victim's scope (typically <origin>/), and a guessed registration id; ids are a process-global sequential counter, so a small brute-force range suffices. It also forges an IPCClientInfo whose principalInfo is replaced by the victim's principal.
- Attacker sends PBackground::PServiceWorkerRegistrationConstructor(descriptor, clientInfo). BackgroundParentImpl::RecvPServiceWorkerRegistrationConstructor accepts it with no principal validation and no sender scoping.
- ServiceWorkerRegistrationProxy::InitOnMainThread looks up the victim origin's registration in the global ServiceWorkerManager registry by the forged (origin, scope) and, on id match, attaches the attacker's actor to it (AddInstance); the parent immediately sends UpdateState to the forged actor, confirming attachment.
- Attacker sends GetNotifications on the attached actor. ServiceWorkerRegistrationProxy::GetNotifications uses the forged client principal plus the forged scope to query the parent's NotificationDB (GetStoredNotificationsForScope) and returns the victim origin's persisted notification contents (title, body, tag, structured-clone data payload) to the attacker process.
- Optionally, the attacker escalates impact via the same attached actor: RecvUnregister destroys the victim origin's service worker registration; RecvSetNavigationPreloadEnabled/Header persist an attacker-controlled Service-Worker-Navigation-Preload header into the victim's future navigations; RecvUpdate forces update jobs on the victim registration.
IPC Path
- PServiceWorkerRegistration
- Protocol: PServiceWorkerRegistration
- Parent process: Main
- Child process: Content
- Message flow: Content -> Main: PServiceWorkerRegistrationConstructor(forged descriptor + forged IPCClientInfo), then Content -> Main: GetNotifications()
Steps to Reproduce
- Ensure a clean Firefox tree, then build with the ASAN fuzzing mozconfig (build_firefox with /app/mozconfigs/mozconfig.linux.asan.fuzzing).
- Apply the provided child-simulation.patch (git apply child-simulation.patch) — all hooks are XRE_IsContentProcess()-guarded, content-process-only; the parent/privileged side stays pristine — and rebuild.
- Run test.html via browser_evaluator with prefs: notification.prompt.testing=true, notification.prompt.testing.allow=true, permissions.default.desktop-notification=1, dom.serviceWorkers.testing.enabled=true, network.cookie.cookieBehavior=0, dom.webnotifications.enabled=true, alerts.useSystemBackend=false, dom.disable_open_during_load=false; timeout ~90s.
- The victim page (http://localhost:<port>) persists a secret notification under its own origin (parent-validated principal) and keeps service worker registrations in flight via the standard navigator.serviceWorker.register() API; it opens the attacker popup on the distinct origin http://127.0.0.1:<port>.
- The attacker page triggers the simulated compromised-child hook, which sends forged PServiceWorkerRegistration constructors brute-forcing the sequential registration id, then GetNotifications on each actor.
- Observe in stderr/logs: PWN-PERSIST (victim state created), PWN-ATTACHED regId=N scope=http://localhost:<port>/ (pristine parent attached the forged actor), PWN-STOLEN ... PWNPERSIST-SECRET-c0ffee || victim-private-notification-data-1337, and the attacker page's console log confirming it received the victim origin's notification data in page JavaScript.
Security Impact
- Severity: High
- Attacker capability: From a compromised content process, an attacker bypasses site isolation for service-worker-registration-scoped state of ANY origin: (1) theft of persisted notification contents (title, body, tag, structured-clone data payloads — e.g. message previews, sender names, app data) of arbitrary origins, delivered into attacker-controlled JS; (2) cross-origin destruction of state by unregistering the victim origin's service worker; (3) persistent injection of an attacker-controlled Service-Worker-Navigation-Preload header value into the victim origin's future navigations; (4) forcing service worker update jobs on victim registrations.
- Preconditions: Compromised content process (renderer RCE required). The victim origin must have a service worker registration present in the parent's ServiceWorkerManager registry (any site with an active service worker) and, for the theft primitive, persisted notifications; the registration id is a small sequential counter and trivially brute-forceable. On MOZ_DIAGNOSTIC_ASSERT builds the forged descriptor's PrincipalInfo must match exactly (AddInstance asserts equality); release builds compile that check out, so origin + scope + id suffice.
ASAN Report
No sanitizer crash — this is a logic vulnerability (privilege violation / cross-origin data theft), verified by observable effect with a pristine parent process. Evidence captured by browser_evaluator on the verification run (ASAN fuzzing build, parent unmodified, child-side XRE_IsContentProcess()-guarded simulation only):
[Child 35415: Main Thread]: I/console log: "PWNLOG victim start origin=http://localhost:34259"
[Child 35415: Main Thread]: I/console log: "PWNLOG victim notif permission=granted"
PWN-PERSIST scope=http://localhost:34259/
[Child 35415: Main Thread]: I/console log: "PWNLOG victim notification shown"
[Child 35461: Main Thread]: I/console log: "PWNLOG attacker start origin=http://127.0.0.1:34259"
[Child 35415: Main Thread]: I/console log: "PWNLOG victim register attempt 1 rejected: SecurityError"
PWN-ATTACHED regId=30 version=30 scope=http://localhost:34259/
PWN-STOLEN regId=30 data=PWNPERSIST-SECRET-c0ffee || victim-private-notification-data-1337 ;;
[Child 35461: Main Thread]: I/console log: "PWNLOG !!! ATTACKER (http://127.0.0.1:34259) RECEIVED CROSS-ORIGIN NOTIFICATION DATA OF http://localhost:34259: PWNPERSIST-SECRET-c0ffee || victim-private-notification-data-1337 ;; "
Interpretation: the pristine parent accepted a forged PServiceWorkerRegistration constructor (victim principalInfo/scope + brute-forced sequential id + forged IPCClientInfo) from the attacker-origin content process (PID 35461), attached it to the victim origin's registration (PWN-ATTACHED = parent sent UpdateState to the forged actor), and RecvGetNotifications returned the victim origin's persisted notification content to the attacker process and its page JS. This matches the researcher's evidence (same sequence and secret; regId 6 vs 30 differs only due to race-dependent counter timing).
Related diagnostic-build artifact noted by the researcher: with a mismatched forged principal spec, the same forged constructor instead hits "Assertion failure: aDescriptor.PrincipalInfo() == mDescriptor.PrincipalInfo(), at dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp:100" (MOZ_DIAGNOSTIC_ASSERT, compiled out in release).
| Reporter | ||
Comment 1•4 months ago
|
||
| Reporter | ||
Comment 2•4 months ago
|
||
| Reporter | ||
Comment 3•4 months ago
|
||
| Reporter | ||
Comment 4•4 months ago
|
||
| Reporter | ||
Comment 5•4 months ago
|
||
| Reporter | ||
Comment 6•4 months ago
|
||
| Reporter | ||
Comment 7•4 months ago
|
||
Updated•4 months ago
|
Comment 9•4 months ago
|
||
Duplicate of bug 2024537? That bug should probably have a higher priority? It's in the process of being fixed via bug 2045721.
Updated•3 months ago
|
Comment 11•3 months ago
|
||
This is more like a site isolation bypass, AFAICT, though as always I do worry about system stuff.
Updated•3 months ago
|
Updated•11 days ago
|
Description
•