Notification parent cross-origin scope confusion — attacker-dispatched `notificationclick` / `notificationclose` event injection into victim origin's active service worker with attacker-controlled payload
Categories
(Core :: DOM: Notifications, defect, P3)
Tracking
()
People
(Reporter: bugzilla.backwater968, Assigned: saschanaz)
References
Details
(4 keywords, Whiteboard: [adv-main155-][adv-esr153.2-])
Attachments
(1 file, 5 external files, 1 obsolete file)
|
23.55 KB,
text/x-python
|
Details |
Steps to reproduce:
Overview
PBackground::CreateNotificationParent carries an nsIPrincipal and a free-form nsString mScope from the child. Bug 2039990 hardened the principal: BackgroundParent::ValidatePrincipal is now called in RecvCreateNotificationParent (BackgroundParentImpl.cpp:505), so a compromised content process can no longer forge a principal it cannot load. However, the mScope string is never validated against the validated principal. The scope is later used verbatim by ServiceWorkerManager::SendNotificationClickEvent / SendNotificationCloseEvent to select which service worker receives the notificationclick / notificationclose event, and GetActiveWorkerInfoForScope derives the SW-lookup principal from the scope URI (via ScopeToPrincipal(scopeURI, attrs)), not from the caller principal.
The result: a compromised content process for https://attacker.example can dispatch a notificationclick event — carrying a fully attacker-controlled Notification payload (title, body, tag, dataSerialized, actions) — to any origin's active service worker, by supplying the victim's SW scope as mArgs.mScope while keeping the validated principal as the attacker's own. The victim's service worker runs with the victim's origin principal (Cache API, IndexedDB, cookie-scope fetch, etc.) and processes the attacker-controlled event.notification.data via structured clone.
Root cause
The implementation has four layers that combine into the vulnerability:
dom/notification/NotificationParent.cpp:408—NotificationParent::RecvShowconstructs theNotificationObserverwithmArgs.mScope(child-supplied) andprincipal(validated, but only for remote-type compatibility). No check that the scope's origin matches the principal's origin.dom/notification/NotificationParent.cpp:90,105-106— onAlertTopic::Click/AlertTopic::Closed, callsRespondOnClick(mPrincipal, mScope, mNotification, actionName)/SendNotificationCloseEventwith the child-controlledmScope.dom/notification/NotificationHandler.cpp:20-36—notification::RespondOnClickforwards toServiceWorkerManager::SendNotificationClickEvent(originSuffix, aScope, ...).originSuffixis derived frommPrincipal, butaScopeis the child-controlled string.dom/serviceworkers/ServiceWorkerManager.cpp:1212-1228—SendNotificationClickEventparsesOriginAttributesfromaOriginSuffix, then callsGetActiveWorkerInfoForScope(attrs, aScope).dom/serviceworkers/ServiceWorkerManager.cpp:1343-1366—GetActiveWorkerInfoForScopedoesNS_NewURI(getter_AddRefs(scopeURI), aScope), thenScopeToPrincipal(scopeURI, aOriginAttributes). The principal used for SW lookup is derived from the scope URI, not frommPrincipal. TheOriginAttributescome from the attacker's principal, so for default (non-PB, default userContext) attributes they match any normal browsing registration.- The close path (
dom/serviceworkers/ServiceWorkerManager.cpp:1232-1248) is analogous.
The display path (NotificationParent::Show, dom/notification/NotificationParent.cpp:347-404) uses mArgs.mPrincipal for the nsIAlertNotification principal, so the visible OS-notification origin label is the attacker's origin — not the victim's. The persistence path (PersistNotification, dom/notification/NotificationUtils.cpp:240-265) keys storage by the principal's origin, with mScope stored only as the serviceWorkerRegistrationScope metadata field. Neither display nor persistence is the primary impact; the SW dispatch is.
MOZ_ASSERT(!mScope.IsEmpty()) at NotificationParent.cpp:70 only checks that a scope exists when a SW path is taken — it does not validate the scope's origin.
Build
Tested revision:
9a8a80db6ce10ffc2fc91a1e25685eed59ce3501
2026-07-19T04:22:49Z
Bug 2055720 - Provide localization comments to Content Classifier strings
Browser:
Mozilla Firefox 154.0a1
Linux x86-64 ASan + gczeal, non-optimized, fresh temporary profile
Build ID 20260720042830
Steps to reproduce
-
Build Firefox with AddressSanitizer and tests enabled.
-
Save the attached
run_marionette.pyin a working directory. -
From the Firefox source directory, launch a fresh profile:
ASAN_OPTIONS='abort_on_error=1:detect_leaks=0:allocator_may_return_null=1' \ MOZ_MARIONETTE=1 MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1 \ ./mach run --temp-profile --no-remote -- --marionette --headless -remote-allow-system-access -
In another terminal, run:
./mach python /absolute/path/to/run_marionette.py
The harness starts two local HTTP servers (http://localhost:8766 and https://localhost:8767), adds the self-signed localhost cert as a trusted CA + per-host override so HTTPS SW registration succeeds, grants desktop-notification permission to the test origins, registers victim service workers at two scopes (http://localhost:8766/victim/ and https://localhost:8767/victim/), and simulates a compromised content process from chrome-privileged JS.
The harness runs two test cases in the same session:
-
CONTROL (same-origin). Attacker principal =
https://localhost:8767, forgedserviceWorkerRegistrationScope=https://localhost:8767/victim/. Principal and scope belong to the same origin. Expected: victim SW receivesnotificationclick. This verifies the harness end-to-end. -
BUG (cross-origin). Attacker principal =
https://attacker.test, forgedserviceWorkerRegistrationScope=http://localhost:8766/victim/. Principal and scope belong to DIFFERENT origins (and even different schemes / hosts). Expected if the bug exists: victim SW athttp://localhost:8766/victim/STILL receivesnotificationclickcarrying the attacker-controlled title and body, becauseGetActiveWorkerInfoForScopeuses the principal derived from the scope, not the caller principal.
The harness exercises the parent-side code path of the finding: NotificationHandler::RespondOnClick (XPCOM) → notification::RespondOnClick(principal=attacker, scope=victimScope, notification, action) (NotificationHandler.cpp:20-40) → ServiceWorkerManager::SendNotificationClickEvent(originSuffix=attacker, aScope=victimScope, aNotification, aAction) → GetActiveWorkerInfoForScope(attrs, victimScope) (ServiceWorkerManager.cpp:1343-1367), which derives the principal from ScopeToPrincipal(scopeURI, attrs) (i.e. from the SCOPE URI, not from the caller principal), then looks up the victim's active SW registration and dispatches notificationclick.
This is functionally equivalent to the live NotificationParent::Observe(AlertTopic::Click) path (which calls notification::RespondOnClick directly, without the XPCOM https:// check at NotificationHandler.cpp:85) that a real compromised content process would hit via PBackground::CreateNotificationParent + PNotification::Show.
Suggested fix direction
In NotificationParent::RecvShow (or in CreateOnMainThread), if mArgs.mScope is non-empty, parse it as a URI and verify that ScopeToPrincipal(scopeURI, mArgs.mPrincipal->OriginAttributesRef()) equals mArgs.mPrincipal (or at minimum that the scope's origin equals the principal's origin). Reject the Show (or fail the actor) if not. The same check should cover the SendNotificationCloseEvent path. Alternatively, perform the scope/principal binding check inside ServiceWorkerManager::SendNotificationClickEvent / SendNotificationCloseEvent by accepting the caller principal explicitly and asserting the scope's principal equals it.
A regression test should send CreateNotificationParent from a content process with a validated attacker principal and a forged mScope pointing at a victim origin's SW registration, then issue Show and simulate a notification click, and assert that (a) the Show is rejected (or the actor is failed) and (b) no notificationclick event is dispatched to the victim's service worker.
Actual results:
RESULT=VULNERABLE: both control (same-origin) and cross-origin
forged-scope dispatched notificationclick to victim SW
Cross-origin forged-scope dispatch (BUG_CROSS_ORIGIN test case):
FORGED_DISPATCH[BUG_CROSS_ORIGIN]={
"attackerOrigin": "https://attacker.test",
"dispatchInvoked": true,
"handlerPresent": true,
"label": "BUG_CROSS_ORIGIN",
"notifId": "forged-BUG_CROSS_ORIGIN-1784607564474",
"putOk": true,
"respondOnClickResolved": true,
"storedEntry": {
"body": "ATTACKER BODY [BUG_CROSS_ORIGIN] - forged scope -> victim SW",
"id": "forged-BUG_CROSS_ORIGIN-1784607564474",
"serviceWorkerRegistrationScope": "http://localhost:8766/victim/",
"tag": "forged-tag-BUG_CROSS_ORIGIN",
"title": "ATTACKER TITLE [BUG_CROSS_ORIGIN]"
},
"victimScope": "http://localhost:8766/victim/"
}
SW_EVENTS_VIA_SERVER[BUG_CROSS_ORIGIN]=[{
"body": "ATTACKER BODY [BUG_CROSS_ORIGIN] - forged scope -> victim SW",
"clientList": [{"id": "e1a6bf14-cd66-463a-96c9-cdea261df897",
"url": "http://localhost:8766/victim/victim.html"}],
"data": null,
"scope": "http://localhost:8766/victim/",
"tag": "forged-tag-BUG_CROSS_ORIGIN",
"timestamp": 1784607564478,
"title": "ATTACKER TITLE [BUG_CROSS_ORIGIN]",
"type": "notificationclick"
}]
The victim SW at http://localhost:8766/victim/ received a notificationclick event carrying the attacker-controlled title (ATTACKER TITLE [BUG_CROSS_ORIGIN]), body, and tag, dispatched by a principal (https://attacker.test) that has no relationship to the victim's SW registration scope (http://localhost:8766/victim/). The victim SW ran with the victim origin principal (http://localhost:8766) and processed the attacker-controlled notification payload.
The CONTROL (same-origin) test case also fired notificationclick, proving the harness exercises the real code path (not silently failing).
Expected results:
NotificationParent::RecvShow (or CreateOnMainThread) must validate, when mArgs.mScope is non-empty, that the scope's origin equals mArgs.mPrincipal's origin. Concretely: parse mArgs.mScope as a URI, compute ScopeToPrincipal(scopeURI, mArgs.mPrincipal->OriginAttributesRef()), and reject the Show (or fail the actor) if that principal does not equal mArgs.mPrincipal. The same check must cover the SendNotificationCloseEvent path. Alternatively, perform the scope/principal binding check inside ServiceWorkerManager::SendNotificationClickEvent / SendNotificationCloseEvent by accepting the caller principal explicitly and asserting the scope's principal equals it.
Under the correct behavior, a CreateNotificationParent call with mPrincipal = https://attacker.example and mScope = https://victim.example/sw.js would be rejected at the IPC boundary, and no notificationclick event would be dispatched to the victim's service worker.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 1•3 months ago
|
||
Do we have any good way to guard for different scopes?
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 2•3 months ago
|
||
(The suggestion to use ScopeToPrincipal sounds reasonable to me)
Comment 3•3 months ago
|
||
Yes, I think using ScopeToPrincipal, additionally validating the resulting scope principal in mozilla::ipc::BackgroundParentImpl::RecvCreateNotificationParent and then additionally checking that the scope principal is the same as the effective storage principal would be appropriate/correct.
| Assignee | ||
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 4•3 months ago
|
||
Comment 5•3 months ago
|
||
:saschanaz, 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?
| Assignee | ||
Comment 6•3 months ago
|
||
scope has been there forever.
Comment 7•3 months ago
|
||
The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.
| Assignee | ||
Comment 9•3 months ago
|
||
Comment 10•3 months ago
|
||
Comment 11•3 months ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e7a22dc262b7
https://hg.mozilla.org/mozilla-central/rev/ee4b8d32b3a1
Comment 12•3 months ago
|
||
The patch landed in nightly and beta is affected, along with ESR.
:saschanaz, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta and ESR approvals.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox155and the ESR status flag(s) towontfix.
For more information, please visit BugBot documentation.
Comment 13•3 months ago
|
||
To add to comment 12, we could uplift to esr153?
| Assignee | ||
Comment 14•3 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D314657
Updated•3 months ago
|
Comment 15•3 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Compromised content process may trigger notifications on third party origin and run service worker script there if the user clicks it.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Adding extra validations with test coverage
- String changes made/needed?: None
- Is Android affected?: yes
| Assignee | ||
Comment 16•3 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D318753
| Assignee | ||
Comment 17•3 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D314657
Updated•3 months ago
|
Comment 18•3 months ago
|
||
firefox-release Uplift Approval Request
- User impact if declined/Reason for urgency: Compromised content process may trigger notifications on third party origin and run service worker script there if the user clicks it.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Adding extra validations with test coverage
- String changes made/needed?: None
- Is Android affected?: yes
Comment 19•3 months ago
|
||
firefox-esr153 Uplift Approval Request
- User impact if declined/Reason for urgency: Compromised content process may trigger notifications on third party origin and run service worker script there if the user clicks it.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Adding extra validations with test coverage
- String changes made/needed?: None
- Is Android affected?: yes
| Assignee | ||
Comment 20•3 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D314657
Updated•3 months ago
|
Comment 21•3 months ago
|
||
Since esr153 is affected, this cannot ship with an Fx154 dot release. I'll abandon the release uplift requests.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Comment 22•3 months ago
|
||
| uplift | ||
Updated•3 months ago
|
Comment 23•3 months ago
|
||
Was Part 2 left off the ESR153 uplift request intentionally?
| Assignee | ||
Comment 24•3 months ago
|
||
That's more of cleanup on top of other refactoring that is not uplifted, so yes.
Updated•3 months ago
|
Comment 25•3 months ago
|
||
| uplift | ||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•3 days ago
|
Description
•