Repository navigation
fix(notifications): guard legacy mobile push account ownership - #2762
Conversation
Co-authored-by: Codex <[email protected]>
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:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The Notifications validation tasks listed by the parent currently record every case as
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Quick104
left a comment
There was a problem hiding this comment.
Review of af2710cc0. The guard is correct: both legacy writers check account ownership after taking the installation lock and before any delete, a refusal rolls back the installation row it inserted, and same-account profile switching still retires the previous profile's destination and its attempts in one transaction. The rule matches the one ordered v2 bootstrap already applies. I found one product trade-off that needs your call and two smaller items, which I'm fixing on this branch.
AI-generated review: Claude Code (claude-opus-5-5), cross-checked with Codex (gpt-6.1-sol).
| if generation > 0 { | ||
| return nil, ErrPushLegacyWriter | ||
| } | ||
| if err := checkLegacyPushOwner(ctx, tx, registration.DeviceID, PushPlatformApple, registration.UserID); err != nil { |
There was a problem hiding this comment.
Medium, needs your call (disclosed in Risks): account switching on older builds now leaves both accounts worse off.
Trigger: a shared phone runs an Apple build from before v2 push registration or an Android build from before ordered registration. Account A signs out and account B signs in on the same install. Neither of those builds unregisters on sign-out: the old Apple coordinator has no unregister call, and the old Android unregisterDevice() has no caller.
Impact: before this PR, B's registration replaced A's row. Now B gets 409 conflict on every launch and has no push destination. A's row stays enabled with its queued attempts, so A's notifications keep waking that phone; the client fetches their content with B's credentials and can only show generic text. No content leaks, but the phone shows the wrong account's alerts and none of B's. Signing out or revoking A's sessions doesn't clear it. Only A unregistering (which those builds can't do), deleting A's profile, or deleting A's account does. Upgrading the app while B is selected doesn't help either, because v2 bootstrap refuses the same retained row.
Options:
- Accept it for the bridge window. Current Apple and Android builds use ordered v2, the old builds handle the 409 quietly (they log it and try again on the next foreground or token callback, with no retry loop), and the original issue is low severity. The doc already states the limitation; I'm adding what clears it (separate comment).
- Let a legacy registration replace foreign rows only when every foreign row carries the same provider token hash as the request. The PR body rejects a same-token exception because the token is caller-supplied, but it differs from the device ID in the way that matters here: the server never returns it, so another account can present it only if it already holds that app install's APNs or FCM token. That keeps household account switching on old builds working and still refuses a caller who knows only the device ID. It would change the doc's statement that a matching token doesn't bypass ownership.
I haven't changed this; it's your decision.
Ordered Apple and Android bootstrap now use the same account-ownership check as the legacy writers, so the bridge and ordered paths cannot drift on who owns an installation. The push API doc also names what clears a legacy ownership conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
Review summaryReviewed head: Fit: 8/10 · Readiness: 8/10 — conditional Fit. This closes a real cross-account write. Before this PR, any signed-in account that sent another account's device ID to the legacy registration routes deleted that account's push destination and its queued attempts. The fix enforces ownership at the account level, matching the rule ordered v2 bootstrap already applies. It's a reasonable use of the critical-fix exception on the frozen Readiness. The guard is correct on both platforms. It runs after the installation lock and before any delete, a refusal leaves destinations, attempts, and the installation row untouched, and same-account profile switching still retires the previous profile's destination in one transaction. What holds the score down is one open product decision. Needs your call
Addressed
Verification
Validated featuresNo passed case is affected. #1234 C2 reaches the changed legacy routes but is recorded as Not run. The Apple and Android tasks (Silo-Server/silo-apple#336, Silo-Server/silo-android#346) cover current builds, which register through ordered v2 and see no change. I changed the body's line to Other checks
AI-generated review: Claude Code ( |
Problem
Closes #2760
Related issue: N/A
Validation tasks: none. The legacy registration behavior behind #1234 C2 changes, and that case is recorded as Not run; the Apple and Android tasks use ordered v2 registration, which this change leaves alone.
Legacy Apple and Android push registration can retire another account's destination and queued attempts when the caller supplies the same device identifier. This change refuses that collision with the existing v1
409 conflictresponse and preserves the foreign account's stored state. The confirmed impact is notification suppression.Approach
Check account ownership at the repository boundary under the existing installation lock, before any destination cleanup or update. Same-account profile switches remain atomic. Ordered v2 installation proof and generation rules stay intact.
Current Apple and Android callers use ordered v2 and already handle registration refusal; neither needs a code change. Jellycompat has no mobile push-registration operation. The API reference documents the bridge rule. User manual: unaffected after checking notification guides, the release card and feature mappings. Browser push ownership is outside this change.
Validation
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2760/
Risks
An older bridge client switching accounts can receive a conflict while the previous account's destination remains registered. Repeating registration does not resolve ownership. Ordered bootstrap must use the existing account before later transfers can use installation-key proof and a newer generation. Matching provider tokens and disabled rows do not grant reassignment authority. No automatic recovery policy is added.
Checklist
AI Disclosure
functions.exec,mcp__t3_code__delegate_task,gh, Go tools, isolated PostgreSQL,silo-evidence.gpt-6.1-sol(implementation, xhigh);claude-opus-5-5(independent review, high).claude-opus-5-5) reviewedaf2710cc0with a read-only Codex (gpt-6.1-sol) cross-check and committedbbb28bb4d, which moves the ordered v2 bootstrap ownership checks onto the same helper and documents what clears a legacy ownership conflict. The account-switch trade-off for older builds is open for a maintainer decision in the review.claude-opus-5-5completed againstaf2710cc05fa4d875a8cdc11386de1e7a095121a: it checked all seven files, surrounding transactions and pinned native callers, with zero verified findings; nothing was posted.Note
Guard legacy mobile push registration against cross-account takeover
checkPushInstallationOwnerhelper in push_devices.go. It runs under the installation lock and returnsErrPushGenerationConflictwhen another account already owns a destination for the same device and platform.UpsertAppleandUpsertFCMwriters now use this guard for generation-zero registration. Profile-switch cleanup is restricted to same-account destinations, so a legacy registration can no longer delete another account's push destination.ErrPushGenerationConflictto HTTP 409 with error codeconflicton both the Apple and generic Android routes.Macroscope summarized bbb28bb.