Repository navigation
fix(notifications): keep admin test pushes on the caller's account - #3604
Conversation
The admin test push routes take a profile ID but no account, and profile IDs such as the legacy `default` repeat across accounts. Testing `default` could send another person's phone a real notification and report it as delivered, and naming their server device ID did the same. Select only among the calling account's devices, on any of its profiles, on both the v2 and v1 routes. Another account's profile or device now gets the same 404 as a device that does not exist.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
# Conflicts: # internal/notifications/push_delivery.go
Quick104
left a comment
There was a problem hiding this comment.
🤖 T3 Code running Claude Code (claude-opus-5-5)
One small cleanup, below. I merged main into the branch first (85832db): #3603 added the login-liveness filter to the same EnqueueTestAttempt query, so the resolved query keeps both filters, and the merge passes account 7 in #3603's TestPushStopsWhenTheRegisteringLoginEndsDB. I found no correctness problem.
|
🤖 T3 Code running Claude Code (claude-opus-5-5) Review summaryReviewed head: No defects found. The change scopes the test-push device lookup to the caller's account in the shared repository query, so both API versions get it from one place. Branch update. I merged Verification.
Remaining. One deliberate behaviour change is for the maintainers to settle: an admin can no longer send a test push to another account's device. Nothing calls these routes from the web app, Validated features. None affected. The passed Notifications cases (#1234 C1/C3/C4, #1235 C1/C2, Silo-Server/silo-apple#336 C1, Silo-Server/silo-android#346 C1) cover event fan-out, payload privacy, and opening content. None of them uses an admin test push to another account's device. User manual. Unaffected. The manual doesn't describe these routes. Apple/Android. No client change is needed. Neither app calls these routes. Overlap. #3592 still edits this query, so whichever PR merges second needs a small rebase. Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
|
Problem
Related issue: N/A
Validation tasks: none
An admin testing push on the profile
defaultcould send a real notification to someone else's phone and be told it was delivered. This change keeps admin test pushes on the caller's own account, on both the v2 routes and the v1 bridge routes (/admin/notifications/push/apple/testand/admin/notifications/push/fcm/test).These routes take a
profile_idfrom the request body and never check it against an account. Profile IDs are only unique per account, and older accounts all sharedefault, so the query picked whichever account's device was seen last. Naming the other account'sserver_device_idreached the same phone. The response also returned that account's attempt and device IDs and the relay outcome, plusdelivery_idon v2.Kody flagged the query as critical while reviewing #3592. It is not a privilege escalation: only an acting admin can call these routes, and the push carried the owner's own notification to the owner's own device, so no notification text reached the admin. The harm is the misdirected push and the false "delivered" report.
Approach
EnqueueTestAttemptnow also matchesuser_id, and both API versions pass the account from the caller's token. Any profile on the caller's account can still be tested. Another account's profile or device gets the same 404 as a device that does not exist, and no attempt is recorded. On v1, only this authorization behaviour changes; the change is recorded indocs/architecture/v1-scope.md.Deliberate behaviour change: a server admin can no longer test another account's device, even through a unique profile ID, where that used to work. The request has no account field, and frozen v1 cannot gain one. I found no web, Apple or Android caller of these routes, and the user manual does not mention them. If admins turn out to need this for support, v2 could add an explicit account field later.
This query also changes in #3592, so whichever PR merges second needs a small rebase.
Validation
db-contracts.txt): fails on both platforms without the fix, passes with it. It covers the caller's own and sibling profiles, the other account's device with and without a selector, and matching errors.make lint-changed, build, vet, OpenAPI and web type generation, contract, route inventory and v1 route freeze checks: pass.make test-go: fails only onTestPersonalListPageFollowsAccessDBandTestRatingsPageIndexDB, query-plan tests ininternal/catalog, which depends on no package changed here. The first also fails on cleanmain; the second passed when run alone on cleanmain, so I have not reproduced it there.make test-db-contracts: no test failed, but it exits non-zero because backup tests skip on a machine withoutpg_dump/pg_restore. That run predates a final test-only cleanup; the new test passed again afterwards, directly and inmake test-go.mainfor fix(notifications): stop web push when the registering login session ends #3603, which changed the same query. The merged query keeps both the account filter and fix(notifications): stop web push when the registering login session ends #3603's live-login check, and fix(notifications): stop web push when the registering login session ends #3603'sTestPushStopsWhenTheRegisteringLoginEndsDBpasses the account it registers under. A copy of the new database test that callsmain's signature fails onmainand passes here.verify-actionlint,verify-shellcheck,verify-prometheus-rules.Evidence
No screen changes; this is API behaviour. Tokens below are test fixtures.
Before, with an admin and another account both on
default, the push for the admin's own profile went to the other account's device (b…) instead of the admin's (a…):After, on a real server, where the admin has no device and the other account has one on
default. Each request returned the same 404 as a profile that does not exist, and no attempt rows were written:The FCM routes returned the same responses with
Android push device not foundon v1. A regular user got 403 and an anonymous caller 401.Risks
Anyone relying on these routes to test another account's device will now get a 404, as described under Approach. There is no migration, and the v1 and v2 response shapes do not change.
Checklist
AI Disclosure
Note
Scope admin push-test device selection to the caller's account
Admin push-test routes previously dispatched using only the profile and device selectors, so a shared profile ID could resolve to another account's device. The v1 and v2 handlers now pass the authenticated account ID from request claims into the push-test service, and
PushDeviceRepository.EnqueueTestAttemptmatches account, profile, platform, provider, and push mode when selecting a device.TestSendPushTestStaysOnTheCallersAccountplus handler testsPushDeviceRepository.EnqueueTestAttemptin push_delivery.go now requires an account ID; callers in push_devices_test.go and push_test_send_db_test.go are updated, and the new cross-account contract test is listed in db-contracts.txtMacroscope summarized 85832db.