Repository navigation
fix(relay): enforce channel owner precedence - #9592
Conversation
Only channel owners may grant ownership, change another owner's role, or remove an owner. Enforce the same boundary during relay validation and inside the serialized database membership write, including owned agents and concurrent target promotions. Keep ordinary admin management and the existing last-owner protections. Add role-matrix and persistence/concurrency regressions, and document the hierarchy in the protocol guide. Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Drop repeated ownership delegation and co-owner demotion checks from the admin precedence journey. The existing owner management journey already verifies both writes and their persisted roles. Keep the new denied escalation, owned-agent removal, ordinary admin management, last-owner removal, and concurrent target promotion cases. Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
🔐 Codex Security Review
Review SummaryOverall Risk: NONE
FindingsNo concrete security, correctness, or reliability findings were identified. Notes
Generated by Codex Security Review | |
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord: changes recommended at 6d4622d for one removal-receipt race. Source review only; two first-pass review lanes timed out.
jmecom
left a comment
There was a problem hiding this comment.
🤖 jm-astra, AI reviewer: Independently reviewed 6d4622d3e0b1a3d93806e9677e4bfe4950f11152, including source integration with main f315c7f31f0e8ac73763ce253c03e509a0631f2c.
I confirm the existing P2 removal-receipt finding: when an admin's removal validates before the target becomes an owner, the locked database check correctly rejects removal, but ingest retains/broadcasts the command and returns success. Owner membership remains protected; the receipt does not reflect the result. No additional actionable findings in the reviewed ownership and concurrency paths, so I have not duplicated that inline comment.
Validation at the reviewed head: 550 core/database library and integration tests passed; 769 database infrastructure tests were ignored. The full relay library run stalled in configuration/audio tests with mutex waits and was terminated, so there is no complete relay-suite pass. The clean merge was inspected from source. The promotion/removal race was traced through validation, persistence and dispatch, not reproduced through a live relay.
Persist kind 9001 and its membership removal in one admitted transaction. Return locked refusals through ingest without storing or broadcasting the command, and keep post-commit notices best-effort. Replace the database-only target-promotion race with an ingest journey covering rejection, atomic event absence, publication, legitimate removal and replay after rejoin. Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
…ransparency * origin/main: (85 commits) docs(mobile): add REVIEWING.md with mobile review principles (#9298) buzz-db: check workflow references in app code before FK retirement (#9399) fix(relay): enforce channel owner precedence (#9592) feat(relay): grow DMs in place, identified by their people (#9125) feat(workflow): implement send_dm action (#9402) perf(mobile): stop following presence for people no longer shown (#9480) [buzz] Classify HTTP event request metrics by event type (#9561) update feedback community invite link (#9588) fix(mobile): name the failing step in sign-in errors (#9263) fix(mobile): order same-second messages by millisecond offsets (#9541) fix(acp): saturate observer frame size estimates (#9494) feat(mobile): accept mentions with Tab and send with Enter on hardware keyboards (#8733) Fix remote Huddle ending cleanup (#9376) fix(mobile): host Duo long-press menus in native sheets (#9536) fix(mobile): keep the relay session across auth reloads (#9543) feat(deletion): clean up media for users and owned agents (#9365) Refuse opening a private channel that has other members (#9307) feat(auth): tolerate client clocks up to 120 s off (#9485) docs: name the required stop as a relay build, not a release (#9577) buzz-db: drop the created_at floor, community write-fence and migration-only NIP-RS triggers (contract) (#8326) ... Signed-off-by: John Tennant <jtennant@squareup.com>
…e-recovery * origin/main: (60 commits) Clean up account records and refresh member lists (#9364) perf(mobile): save own thread interest once per unread catch-up (#9614) buzz-db: fix main (renumber the function drop to 0094, update_channel test call) (#9616) feat(relay): name the agent whose add policy refuses a DM (#9601) buzz-db: drop the community_deletion_lock_key and profile_name_fields functions (contract) (#9598) fix(deps): clear chrono, humantime and zip advisories from the dependency policy (#9609) docs: define mobile diagnostic reporting (#9600) build(mobile): link iOS plugins through Swift Package Manager (#9597) feat(push-gateway): enroll Android installations and send FCM wakes (#9560) perf(mobile): cache and animate custom emoji in the iOS picker (#9479) fix(ios): end each bold or strikethrough run at its first closing marker (#9559) Apply the private-to-open rule in update_channel too (#9581) Add real content cleanup for users and agents (#9363) Keep transparency in mobile avatar photo crops (#9319) fix(mobile): read presence for a person shown again while still covered (#9595) buzz-db: check membership, agent-owner and channel references in app code (#9404) buzz-db: enforce five single-table guards in app writers (phase 1) (#8320) docs(mobile): add REVIEWING.md with mobile review principles (#9298) buzz-db: check workflow references in app code before FK retirement (#9399) fix(relay): enforce channel owner precedence (#9592) ... Signed-off-by: Will Pfleger <wpfleger@block.xyz> # Conflicts: # mobile/lib/features/channels/channel_actions_sheet.dart # mobile/lib/shared/read_state/read_state_manager.dart
**Category:** improvement **User Impact:** Solo chat owners can lower the access of any current non-owner, including people and agents. **Problem:** Using invitations to change Solo chat access can restore a removed member, reject a downgrade because of the target’s invitation policy, or show a join notice for a role change. **Solution:** Add signed role updates that require an active member at the expected role when the relay commits the change. A Solo owner can downgrade any current non-owner. Moving a viewer to Participating requires a verified agent, and granting Admin requires ownership of that agent. The relay refreshes signed group state without emitting a join notice. Companion to [block/buzz-app#3704](block/buzz-app#3704). The [app review](block/buzz-app#3704 (review)) identified the need for conditional writes, verified agent identity and live relay validation. [#9592](#9592) introduced the atomic removal that uses the same membership lock. <details> <summary>File changes</summary> **crates/buzz-core/src/kind.rs** Register signed Solo role updates as kind 9050. **crates/buzz-db/src/store/channel_members.rs** Authorize the transition under the channel membership lock and commit the active row update and signed event together. **crates/buzz-relay/src/handlers/event.rs** Give the new command a bounded metrics label. **crates/buzz-relay/src/handlers/ingest.rs** Use the shared signed ingest path and require the channel administration scope. **crates/buzz-relay/src/handlers/mod.rs** Register the command handler and its PostgreSQL test. **crates/buzz-relay/src/handlers/solo_member_role.rs** Parse the command, route it to the conditional write, and refresh signed group state after commit. **crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs** Exercise human and agent changes, restrictive invitation policy, promotion authorization, stale and removed membership, duplicate receipt, and signed roster updates through the relay’s production ingest path. **docs/solo-mobile-contract.md** Describe the wire format, permitted transitions, and handling when an older relay rejects the command. </details> ### Try it 1. Run the updated relay and the companion app against a disposable Solo chat with a current human and agent. Open **Chat access** as the owner. 2. Lower the human to **Viewing only**. Reopen **Chat access** and confirm the saved role. A role change should produce no join notice. 3. Downgrade an agent with a restrictive invitation policy. Confirm its role changes. Check that **Admin** can be granted only to your own verified agent. 4. Run `solo_owner_edits_active_members_and_publishes_the_new_roster` with PostgreSQL to check that a pending change for a removed member is refused and the signed roster stays clear of that member. ### Validation - The PostgreSQL regression passes at relay commit `405f7d1da`. It covers role and invite-policy enforcement, signed roster refresh, duplicate receipts, and rejection after removal. - The companion app at `a470947dc6` passes 138 administration tests. Its production command builder, validator, and signed roster reader also passed over WebSocket against a local relay backed by PostgreSQL and Redis. A human moved from Admin to Participating to Viewing only, then was removed. The app preflight and relay both refused a further role edit, and the signed roster still excluded the member. - The live check exercised the app’s relay code headlessly. The UI walkthrough is pending. --------- Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Co-authored-by: Tom Brow <tomb@block.xyz>
Category: fix
User Impact: Channel admins can manage the conversation while owners retain control of ownership and owner membership.
Problem: Channel admins can currently grant themselves ownership, change another owner's role, or remove an owner when another owner remains. A racing promotion can stop a removal after admission while its command is still stored and reported successful.
Solution: Reserve ownership grants, owner role changes, and owner removal for channel owners, enforced during validation and under the database membership lock. Persist each removal and its signed command together so a locked refusal rejects the receipt without storing or broadcasting the refused command; this applies equally to people and agents, with no new role, migration or protocol field.
File changes
crates/buzz-core/src/channel.rs
Constrain the shared role policy and member admission decision. Keep same-role additions idempotent and preserve ordinary guest-promotion rules; extend the existing role matrix and cover ownership grants through admission.
crates/buzz-db/src/store/channel_members.rs
Reject non-owner removal of an owner under the existing membership lock, including removal of an agent the actor owns. Reuse those locked checks when storing a removal command and its membership change atomically. Retain database coverage for escalation denials, ordinary owner/admin powers and concurrency; move the target-promotion race to the ingest journey below.
crates/buzz-relay/src/handlers/channel_authz.rs
Make removal authorization aware of the target's role and expose an ownership-specific role-change refusal. Extend the existing authorization tables.
crates/buzz-relay/src/handlers/side_effects.rs
Pass the removal target into admission authorization. Persist removals atomically, then run cache invalidation, eviction and best-effort notices only after commit; duplicates run no second removal or notices.
crates/buzz-relay/src/handlers/ingest.rs
Route kind 9001 through atomic persistence and return locked membership refusals as client rejection before dispatch.
crates/buzz-relay/src/handlers/remove_user_postgres_tests.rs
Exercise the real ingest race with a membership-lock barrier: target promotion causes rejection, leaves the Owner intact and stores/publishes no command. Then verify legitimate removal and duplicate replay after rejoin. This replaces the DB-only target-promotion test rather than duplicating it.
crates/buzz-relay/src/handlers/mod.rs
Register the new PostgreSQL ingest journey for automatic discovery.
NOSTR.md
Document owner precedence, including the agent-owner exception's boundary.
Try it
removal_receipt_tracks_the_locked_membership_write. The controlled race must return rejection with the target still Owner and no stored/published removal; the same command must succeed once authorized, and its later replay must preserve a rejoined member.Validation and remaining checks
e7a8fe405, all 2,048 infrastructure-free tests across the completebuzz-db/buzz-relaypackage inventory pass with nextest process isolation, plus all five package doctests. The monolithic Cargo run stalled in shared-process configuration tests; the same package inventory passes with the repository's preferred isolated runner, without exclusions or assertion changes.accepted:trueafter the locked refusal, and passes with atomic removal. Its positive controls verify actual publication for a legitimate removal and no repeated removal/publication after rejoin. The existing demoted-actor lock test retains direct-call concurrency coverage.Ok(Owner); restoring the guard returned all 298 core tests to green.6d4622d3e, all 769 PostgreSQL tests in thebuzz-dbpackage profile passed using the repository's per-test database isolation wrapper (PostgreSQL 17.12, UTC; 245 cases outside the selected profile skipped). This includes both new regressions and the existing owner-management journey retained after removing two repeated positive checks.6d4622d3e. Maintainer approval and human acceptance remain pending.This relay permission change does not require a client update.
Related history: #3017 established bidirectional elevated-role checks and last-owner protection; #8143 introduced the current shared role predicate. This PR adds the Owner-over-Admin distinction to those rules.