Service Worker `PBackground` actors trust forged `IPCClientInfo` / registration descriptors from content processes
Categories
(Core :: DOM: Service Workers, defect, P3)
Tracking
()
People
(Reporter: kkinho04, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: csectype-priv-escalation, reporter-external, sec-want, Whiteboard: [client-bounty-form][adv-main154-][adv-esr153.1-])
Attachments
(1 obsolete file)
- Preconditions:
- This is not directly triggerable from pure web content alone.
- However, in Firefox's sandbox / IPC threat model, a malicious or already-compromised content process sending raw IPDL to the parent process is a normal and relevant attack assumption.
Summary
PServiceWorkerContainer and PServiceWorkerRegistration are both exposed to anydom child processes through PBackground. On the parent side, the implementation appears to trust child-supplied IPCClientInfo and IPCServiceWorkerRegistrationDescriptor values without verifying that they actually match the calling global's real origin.
As a result, a compromised content process may be able to:
- obtain a
ServiceWorkerRegistrationDescriptorfor an arbitrary origin, - open a
PServiceWorkerRegistrationactor for that descriptor, - read stored notifications for that origin,
- unregister that origin's Service Worker,
- modify navigation preload state, or
- trigger update-related behavior against the target registration.
This is a classic IPC trust-boundary violation: the parent process relies on identity objects supplied by the child process.
Supporting Code Paths
PBackgroundisChildProc=anydomand directly manages Service Worker actors.
ipc/glue/PBackground.ipdl:83-119PBackgroundisChildProc=anydommanages PServiceWorkerContainer;manages PServiceWorkerRegistration;
ipc/glue/PBackground.ipdl:278-285- child-side constructors exist for
PServiceWorkerContainer()andPServiceWorkerRegistration(IPCServiceWorkerRegistrationDescriptor aDescriptor, IPCClientInfo aForClient); - the comment notes that
aForClientidentifies the subscribing global and hints that the actor should ideally be tied to a global more explicitly
- child-side constructors exist for
- The child sends
clientInfo.ref().ToIPC()to the parent on each relevant call.
dom/serviceworkers/ServiceWorkerContainer.cpp:317-319mActor->SendRegister(clientInfo.ref().ToIPC(), ...)
dom/serviceworkers/ServiceWorkerContainer.cpp:393-395SendGetRegistrations(clientInfo.ref().ToIPC(), ...)
dom/serviceworkers/ServiceWorkerContainer.cpp:495-497SendGetRegistration(clientInfo.ref().ToIPC(), spec, ...)
- The parent wraps the incoming
IPCClientInfoasClientInfoand uses it without validating that it matches the real sender identity.
dom/serviceworkers/ServiceWorkerContainerParent.cpp:21-43RecvRegister(const IPCClientInfo& aClientInfo, ...)mProxy->Register(ClientInfo(aClientInfo), ...)
dom/serviceworkers/ServiceWorkerContainerParent.cpp:46-64RecvGetRegistration(const IPCClientInfo& aClientInfo, ...)mProxy->GetRegistration(ClientInfo(aClientInfo), ...)
dom/serviceworkers/ServiceWorkerContainerParent.cpp:67-89RecvGetRegistrations(const IPCClientInfo& aClientInfo, ...)mProxy->GetRegistrations(ClientInfo(aClientInfo))
dom/serviceworkers/ServiceWorkerContainerParent.cpp:92-109RecvGetReady(const IPCClientInfo& aClientInfo, ...)
ClientInforeconstructs a principal from child-controlledPrincipalInfowithout additional validation on the parent side.
dom/clients/manager/ClientInfo.cpp:108-110ClientInfo::GetPrincipal()returnsPrincipalInfoToPrincipal(PrincipalInfo())
GetRegistration/GetRegistrationsuse the forged principal as the authorization source.
dom/serviceworkers/ServiceWorkerManager.cpp:972-986GetRegistrationsRunnableobtains the principal frommClientInfo.GetPrincipal()- it then derives the registration namespace via
PrincipalToScopeKey(principal, scopeKey)
dom/serviceworkers/ServiceWorkerManager.cpp:1013-1020- for each scope it calls
principal->CheckMayLoadWithReporting(scopeURI, ...) - this checks whether the child-supplied principal can load the URI, not whether the sender is actually that principal
- for each scope it calls
dom/serviceworkers/ServiceWorkerManager.cpp:1063-1088GetRegistrationRunnablefollows the same pattern and may return a registration based on the forged principal
PServiceWorkerRegistrationconstruction also fails to validate descriptor/client binding.
dom/serviceworkers/ServiceWorkerRegistrationParent.cpp:145-151Init(aDescriptor, aForClient)createsServiceWorkerRegistrationProxy(ServiceWorkerRegistrationDescriptor(aDescriptor), ClientInfo(aForClient))
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:86-100InitOnMainThread()checks only that the descriptor's(principal, scope, id)matches an existing registration- it does not verify that
aForClientis same-origin with the registration principal
- Privileged operations are then directly exposed on that actor.
dom/serviceworkers/PServiceWorkerRegistration.ipdl:23-31UnregisterUpdateGetNotificationsSetNavigationPreloadEnabledSetNavigationPreloadHeaderGetNavigationPreloadState
- Those operations can produce real cross-origin impact.
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:228-229Unregister()callsswm->Unregister(self->mReg->Principal(), ..., self->mReg->Scope())- there is no caller-vs-registration principal comparison
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:414-418SetNavigationPreloadEnabled()mutates the target registration and stores it
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:448-452SetNavigationPreloadHeader()does the same
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:384-386Update()combines forgedmListeningClientInfowith the target registration principal/scope
dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:496-509GetNotifications()uses forgedmListeningClientInfo.GetPrincipal()and the target scope to callGetStoredNotificationsForScope(principal, scope, tag)
- Notification disclosure returns data that is visible to script.
dom/notification/NotificationUtils.cpp:213-237GetStoredNotificationsForScope()looks up notifications by(origin, scope, tag)
dom/notification/Notification.h:79-97Notificationexposes fields such astitle,body, andtag
dom/notification/Notification.cpp:641-654Notification.datais deserialized fromdataSerialized
dom/serviceworkers/ServiceWorkerRegistration.cpp:480-520- the child converts returned
IPCNotification[]into JS-visibleNotificationobjects
- the child converts returned
Plausible Attack Scenario
A compromised content process could:
- create a
PServiceWorkerContaineractor throughPBackground, - forge an
IPCClientInfowhose principal and URL point to a victim origin, - call
GetRegistrationorGetRegistrationsto obtain the victim origin'sServiceWorkerRegistrationDescriptor, - construct
PServiceWorkerRegistration(descriptor, forgedClientInfo), - invoke one of:
GetNotifications("")to read pending notification title/body/data,Unregister()to remove the victim Service Worker,SetNavigationPreloadEnabled/Header()to modify persistent registration state,Update()to force update-related behavior.
Impact Assessment
- Confidentiality:
- cross-origin stored notification title/body/
datamay become readable - this would violate the normal same-origin data model
- cross-origin stored notification title/body/
- Integrity:
- a target origin's Service Worker registration may be removed or mutated
- Availability:
- unregistering a Service Worker can disrupt offline functionality, push flows, or background tasks
False Positive Considerations
- This report does not claim that pure web content alone can directly trigger the issue.
- The security claim is specifically about the sandbox / IPC threat model: whether a compromised content process can abuse parent IPC trust.
- I did not find any parent-side validation analogous to
quota::IsPrincipalInfoValid()in these paths, nor any binding of these actors to an immutable caller global identity. - Parent-side authorization decisions are derived from the principal supplied by the child, which is why the trust-boundary interpretation appears justified.
Validation Procedure
The following is the intended validation approach for reducing false positives, using a debug or instrumentation build:
- Register a normal Service Worker under
victim.example. - Make that Service Worker create a persistent notification.
- Instrument a content-process path so that
PServiceWorkerContainerrequests send anIPCClientInfowhosePrincipalInfoand URL identifyvictim.example. - Confirm that
GetRegistration()orGetRegistrations()returns the victim origin'sServiceWorkerRegistrationDescriptor. - Create
PServiceWorkerRegistration(descriptor, forgedClientInfo). - Call
SendGetNotifications(u"")and verify that the returnedIPCNotificationcontains the victim notification'stitle,body, ordata. - Call
SendUnregister(). - Verify from a normal victim page that
navigator.serviceWorker.getRegistration()no longer returns the registration. - Optionally call
SendSetNavigationPreloadEnabled(false)orSendSetNavigationPreloadHeader("x-test")and verify that the victim registration state changed.
Expected results during validation:
- the parent does not reject the forged
IPCClientInfo, - the victim registration descriptor is returned to the attacker-controlled content process,
- cross-origin notification content becomes visible to script,
- registration state mutation affects the victim origin.
Remediation Direction
- Bind
PServiceWorkerContainerandPServiceWorkerRegistrationto immutable caller identity at actor construction time. - Do not trust child-supplied
IPCClientInfoas an authorization source unless it is validated against the real global / window / worker that owns the actor. - In the
PServiceWorkerRegistrationconstructor path, requireaForClientto be same-origin withaDescriptor.PrincipalInfo(). - Structurally, the design would be safer if these actors were moved under a parent actor that is explicitly tied to a concrete global, as the existing IPDL comment already suggests.
Updated•8 months ago
|
Updated•8 months ago
|
Updated•8 months ago
|
Comment 2•8 months ago
|
||
(In reply to Jinho Seo from comment #0)
in Firefox's sandbox / IPC threat model, a malicious or already-compromised content process sending raw IPDL to the parent process is a normal and relevant attack assumption.
It is a consideration in our threat model, but we know our site-isolation work to harden that boundary is not complete. Since this bug was submitted to our Bug Bounty program you should know, however, that assuming an already-compromised content process is only a valid in the specific case of a sandbox escape bounty. While this is a privilege escalation that involves the parent process, it is not a sandbox "escape" as defined by our bounty program
Plausible Attack Scenario
Validation Procedure
If you're seeking bug bounties we need a POC that demonstrates the bug is real and reachable in an operating Firefox, not plausible scenarios. If you have a testcase that performs your validation procedure please attach it to this bug.
Comment 5•6 months ago
|
||
Redirect a needinfo that is pending on an inactive user to the triage owner.
:edenchuang, since the bug has recent activity, could you have a look please?
For more information, please visit BugBot documentation.
Updated•4 months ago
|
Updated•3 months ago
|
Comment 11•3 months ago
|
||
Comment 12•3 months ago
|
||
:tschuster, please update all release status flags to reflect the affected/unaffected/disabled state correctly. Which branches (beta, release, and/or ESR) are affected by this flaw?
Updated•3 months ago
|
Comment 13•3 months ago
|
||
Oh, seems like Nika had a patch for this in bug 2054674.
Updated•3 months ago
|
Comment 15•3 months ago
|
||
There is a lot in here, but I think the majority should be fixed now.
Updated•3 months ago
|
Comment 17•3 months ago
|
||
(In reply to Tom Schuster from comment #15)
There is a lot in here, but I think the majority should be fixed now.
A couple of the dupes mention bug privateBrowsingId, which is not explicitly mentioned here FWIW. I'm not sure if there are any other fields we care about validating.
Comment 18•3 months ago
|
||
Because there already has been a lot of duping I'm just going to mark this fixed and cite the specific related bugs that are known/believed to have addressed things. Please file a new bug if there are any specific gaps in existing fixes.
- Bug 2045721 added ServiceWorkerContainer validation and other IPCClientInfo validation
- Bug 2054667 added ServiceWorkerRegistration validation. This bug doesn't mention ServiceWorkerConstructor directly but at least 1 duped one does, and Bug 2054674 added validation for that.
- Bug 2022253, Bug 2054667, and Bug 2059144 impact notification validation.
(In reply to Andrew McCreight [:mccr8] from comment #17)
A couple of the dupes mention bug privateBrowsingId, which is not explicitly mentioned here FWIW. I'm not sure if there are any other fields we care about validating.
So at least for bug 2058864 that you duped above, the intended ratcheting process for tightening the constraints enforced by the origin-tracking in Bug 2055554 will cover private browsing. But also as a sort of orthogonal high-level fix, bug 1853706 tracks having all of these APIs just take their principals from an object capability authority trail.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•2 months ago
|
Updated•21 days ago
|
Description
•