Closed Bug 2024537 Opened 8 months ago Closed 3 months ago

Service Worker `PBackground` actors trust forged `IPCClientInfo` / registration descriptors from content processes

Categories

(Core :: DOM: Service Workers, defect, P3)

defect

Tracking

()

RESOLVED FIXED
155 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr140 --- wontfix
firefox-esr153 154+ fixed
firefox153 --- wontfix
firefox154 + fixed
firefox155 + fixed

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 ServiceWorkerRegistrationDescriptor for an arbitrary origin,
  • open a PServiceWorkerRegistration actor 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

  1. PBackground is ChildProc=anydom and directly manages Service Worker actors.
  • ipc/glue/PBackground.ipdl:83-119
    • PBackground is ChildProc=anydom
    • manages PServiceWorkerContainer;
    • manages PServiceWorkerRegistration;
  • ipc/glue/PBackground.ipdl:278-285
    • child-side constructors exist for PServiceWorkerContainer() and PServiceWorkerRegistration(IPCServiceWorkerRegistrationDescriptor aDescriptor, IPCClientInfo aForClient);
    • the comment notes that aForClient identifies the subscribing global and hints that the actor should ideally be tied to a global more explicitly
  1. The child sends clientInfo.ref().ToIPC() to the parent on each relevant call.
  • dom/serviceworkers/ServiceWorkerContainer.cpp:317-319
    • mActor->SendRegister(clientInfo.ref().ToIPC(), ...)
  • dom/serviceworkers/ServiceWorkerContainer.cpp:393-395
    • SendGetRegistrations(clientInfo.ref().ToIPC(), ...)
  • dom/serviceworkers/ServiceWorkerContainer.cpp:495-497
    • SendGetRegistration(clientInfo.ref().ToIPC(), spec, ...)
  1. The parent wraps the incoming IPCClientInfo as ClientInfo and uses it without validating that it matches the real sender identity.
  • dom/serviceworkers/ServiceWorkerContainerParent.cpp:21-43
    • RecvRegister(const IPCClientInfo& aClientInfo, ...)
    • mProxy->Register(ClientInfo(aClientInfo), ...)
  • dom/serviceworkers/ServiceWorkerContainerParent.cpp:46-64
    • RecvGetRegistration(const IPCClientInfo& aClientInfo, ...)
    • mProxy->GetRegistration(ClientInfo(aClientInfo), ...)
  • dom/serviceworkers/ServiceWorkerContainerParent.cpp:67-89
    • RecvGetRegistrations(const IPCClientInfo& aClientInfo, ...)
    • mProxy->GetRegistrations(ClientInfo(aClientInfo))
  • dom/serviceworkers/ServiceWorkerContainerParent.cpp:92-109
    • RecvGetReady(const IPCClientInfo& aClientInfo, ...)
  1. ClientInfo reconstructs a principal from child-controlled PrincipalInfo without additional validation on the parent side.
  • dom/clients/manager/ClientInfo.cpp:108-110
    • ClientInfo::GetPrincipal() returns PrincipalInfoToPrincipal(PrincipalInfo())
  1. GetRegistration / GetRegistrations use the forged principal as the authorization source.
  • dom/serviceworkers/ServiceWorkerManager.cpp:972-986
    • GetRegistrationsRunnable obtains the principal from mClientInfo.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
  • dom/serviceworkers/ServiceWorkerManager.cpp:1063-1088
    • GetRegistrationRunnable follows the same pattern and may return a registration based on the forged principal
  1. PServiceWorkerRegistration construction also fails to validate descriptor/client binding.
  • dom/serviceworkers/ServiceWorkerRegistrationParent.cpp:145-151
    • Init(aDescriptor, aForClient) creates ServiceWorkerRegistrationProxy(ServiceWorkerRegistrationDescriptor(aDescriptor), ClientInfo(aForClient))
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:86-100
    • InitOnMainThread() checks only that the descriptor's (principal, scope, id) matches an existing registration
    • it does not verify that aForClient is same-origin with the registration principal
  1. Privileged operations are then directly exposed on that actor.
  • dom/serviceworkers/PServiceWorkerRegistration.ipdl:23-31
    • Unregister
    • Update
    • GetNotifications
    • SetNavigationPreloadEnabled
    • SetNavigationPreloadHeader
    • GetNavigationPreloadState
  1. Those operations can produce real cross-origin impact.
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:228-229
    • Unregister() calls swm->Unregister(self->mReg->Principal(), ..., self->mReg->Scope())
    • there is no caller-vs-registration principal comparison
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:414-418
    • SetNavigationPreloadEnabled() mutates the target registration and stores it
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:448-452
    • SetNavigationPreloadHeader() does the same
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:384-386
    • Update() combines forged mListeningClientInfo with the target registration principal/scope
  • dom/serviceworkers/ServiceWorkerRegistrationProxy.cpp:496-509
    • GetNotifications() uses forged mListeningClientInfo.GetPrincipal() and the target scope to call GetStoredNotificationsForScope(principal, scope, tag)
  1. Notification disclosure returns data that is visible to script.
  • dom/notification/NotificationUtils.cpp:213-237
    • GetStoredNotificationsForScope() looks up notifications by (origin, scope, tag)
  • dom/notification/Notification.h:79-97
    • Notification exposes fields such as title, body, and tag
  • dom/notification/Notification.cpp:641-654
    • Notification.data is deserialized from dataSerialized
  • dom/serviceworkers/ServiceWorkerRegistration.cpp:480-520
    • the child converts returned IPCNotification[] into JS-visible Notification objects

Plausible Attack Scenario

A compromised content process could:

  1. create a PServiceWorkerContainer actor through PBackground,
  2. forge an IPCClientInfo whose principal and URL point to a victim origin,
  3. call GetRegistration or GetRegistrations to obtain the victim origin's ServiceWorkerRegistrationDescriptor,
  4. construct PServiceWorkerRegistration(descriptor, forgedClientInfo),
  5. 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/data may become readable
    • this would violate the normal same-origin data model
  • 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:

  1. Register a normal Service Worker under victim.example.
  2. Make that Service Worker create a persistent notification.
  3. Instrument a content-process path so that PServiceWorkerContainer requests send an IPCClientInfo whose PrincipalInfo and URL identify victim.example.
  4. Confirm that GetRegistration() or GetRegistrations() returns the victim origin's ServiceWorkerRegistrationDescriptor.
  5. Create PServiceWorkerRegistration(descriptor, forgedClientInfo).
  6. Call SendGetNotifications(u"") and verify that the returned IPCNotification contains the victim notification's title, body, or data.
  7. Call SendUnregister().
  8. Verify from a normal victim page that navigator.serviceWorker.getRegistration() no longer returns the registration.
  9. Optionally call SendSetNavigationPreloadEnabled(false) or SendSetNavigationPreloadHeader("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 PServiceWorkerContainer and PServiceWorkerRegistration to immutable caller identity at actor construction time.
  • Do not trust child-supplied IPCClientInfo as an authorization source unless it is validated against the real global / window / worker that owns the actor.
  • In the PServiceWorkerRegistration constructor path, require aForClient to be same-origin with aDescriptor.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.
Flags: sec-bounty?
Duplicate of this bug: 2024538
Group: firefox-core-security → dom-core-security
Component: Security → DOM: Service Workers
Product: Firefox → Core

(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.

Flags: needinfo?(kkinho04)
Keywords: sec-want
Duplicate of this bug: 2032362
Duplicate of this bug: 2039580

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.

Flags: needinfo?(kkinho04) → needinfo?(echuang)
Duplicate of this bug: 2043880
Duplicate of this bug: 2052705
Depends on: 2045721
See Also: → 2054724
Duplicate of this bug: 2054637
Duplicate of this bug: 2055420
Duplicate of this bug: 2055826
Flags: needinfo?(echuang)
Assignee: nobody → tschuster
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attached file (secure) (obsolete) —

: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?

Flags: needinfo?(tschuster)
Attachment #9615126 - Attachment is obsolete: true

Oh, seems like Nika had a patch for this in bug 2054674.

Flags: needinfo?(tschuster)
Assignee: tschuster → nobody
Status: ASSIGNED → NEW
Depends on: 2054667
Depends on: 2054674
Duplicate of this bug: 2045533

There is a lot in here, but I think the majority should be fixed now.

Severity: -- → S3
Priority: -- → P3
Duplicate of this bug: 2058864

(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.

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.

Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Group: dom-core-security → core-security-release
Target Milestone: --- → 155 Branch
QA Whiteboard: [sec] [uplift] [qa-triage-done-c155/b154]
Depends on: 2022253, 2059144
See Also: → 2055554
Whiteboard: [client-bounty-form] → [client-bounty-form][adv-main154-]
Whiteboard: [client-bounty-form][adv-main154-] → [client-bounty-form][adv-main154-][adv-esr153.1-]
Flags: sec-bounty? → sec-bounty-
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: