Skip to content

Apply the private-to-open rule in update_channel too - #9581

Merged
loganj merged 2 commits into
mainfrom
loganj/update-channel-private-open
Nov 17, 2026
Merged

loganj merged 2 commits into
mainfrom
loganj/update-channel-private-open

Conversation

@loganj

@loganj loganj commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to Refuse opening a private channel that has other members #9307, which made the relay refuse to open a private channel that has, or once had, any member other than the sender and the sender's own agents. That rule lived only in the channel metadata edit path (kind:9002). The store's other channel-settings function, update_channel, could still open such a channel.
  • Now both paths apply the same rule, because it runs in the one function that writes channel settings for both. update_channel takes the authenticated sender so it can decide the rule. Today only tests call update_channel, so nothing user-visible changes; the gap is closed before any real caller arrives.
  • The user-deletion executor doc now says what the rule needs from a purge: if a purge keeps any of a user's messages in a channel, it must also keep that user's membership row there, marked removed. The relay finds former members only through those rows, so dropping the row would let the channel be opened and its history, those messages included, be made public.

Details

  • The check moved out of apply_channel_metadata_event into update_channel_on, which both paths call. It still runs under the membership lock that a visibility change takes, so members cannot be added between the check and the commit.
  • One ordering change: a single kind:9002 that opens a private channel with other members, archives it and sets auto_join to true now gets the auto_join refusal instead of the private-to-open one, because the auto_join check now runs first. Both refuse, and nothing is stored either way.
  • This PR also carries doc-comment wording that was reviewed on Refuse opening a private channel that has other members #9307 but not merged with it: the comments now give the reason, that opening publishes the existing history, so removed members count.
  • Every call site of update_channel is a test, and each now passes the channel owner as sender.

Related issue

Follow-up to #9307 (review notes on its store gap and on purge).

Testing

  • New Postgres test update_channel_refuses_opening_a_private_channel_with_other_members: opening fails for both the owner and the other member as sender, while the other member is current and after they are removed, and the channel stays private. A channel that holds only the owner opens.
  • The existing kind:9002 test private_to_open_needs_no_other_members still passes. Both tests fail when the check is removed.

buzz-review-completed

🤖 Generated with Claude Code

loganj and others added 2 commits November 16, 2026 12:40
The check comment now leads with the reason the helper and NOSTR.md
use: opening publishes the existing history, so removed members count.
The update_channel doc says it applies every ChannelUpdate field,
visibility included.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
The kind:9002 path refused opening a private channel that has, or had,
another member, but the store helper update_channel applied visibility
with no check. Only tests call it today, so nothing could reach the
hole, but a future production caller would have skipped the rule.

The check now lives in update_channel_on, the one write both paths use.
update_channel takes the sender that the rule needs; every caller is a
test and now passes one. A new Postgres test covers update_channel with
a current member, a removed member, and a channel holding only the
sender.

The user-deletion executor doc now says the real purge must keep the
membership row of a user whose messages it keeps: the check finds
former members only through those rows.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@loganj
loganj marked this pull request as ready for review November 17, 2026 01:23
@loganj
loganj requested a review from a team as a code owner November 17, 2026 01:23
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 17, 2026
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 3d97535120cd4e18ecd01542e4f7fbcadbf9301c...c52412ab4a32e9804bbaa838b94018e3d07418e0
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete findings in the authorized PR range. The centralized guard preserves tenant scoping, membership locking, replay handling, and transactional rollback.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Read-only inspection only; builds and tests were not executed, as requested.

Generated by Codex Security Review |
Requested by: @loganj |
Workflow run

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent — recommend approval (agent comment under repository policy).

Reviewed: 63f1d6918c61e179733ff4d22e70033e74bc3482..c52412ab4a32e9804bbaa838b94018e3d07418e0, clean checkout; critical privacy boundary (private history becomes readable on opening).

Integrated finding: no introduced correctness or security defect identified; author action: none. The shared settings writer enforces the private→open guard for both direct update_channel and kind:9002 edits (crates/buzz-db/src/store/channel.rs:1121-1129,1320-1325,1774-1777). Visibility edits take the membership lock before reading former members (channel.rs:1094-1098,1241-1294); has_member_besides_sender_and_agents includes removed rows and fails conservatively on missing ownership (channel.rs:1662-1682). Signed kind:9002 still passes the event actor after relay authority checks (crates/buzz-relay/src/handlers/side_effects.rs:888-904). A refused edit rolls back the event and settings together. The new public-store Postgres test exercises current/removed other members and sender-only opening (channel.rs:2681-2765); existing relay tests cover other agent/owner and refusal behavior (crates/buzz-relay/src/handlers/edit_metadata_postgres_tests.rs:867-1064). Both independent review lenses agree with the source tracing.

Validation: git diff --check <base>..HEAD passed at the exact clean head. One independent reviewer ran scripts/test-postgres-test-discovery.sh successfully; another ran cargo test -p buzz-db --quiet (216 passed, 764 Postgres-ignored) and cargo test -p buzz-relay --no-run --quiet (passed). A local full buzz-relay suite was stopped after unrelated long-running tests; it is not a passing local run. The ignored Postgres regression and a live relay were not exercised locally because local Postgres/Docker was unavailable. Matching-head CI run 43924497097 completed successfully, including PostgreSQL tests, Rust unit/lint, and relay E2E; that is CI execution evidence, not a local reproduction.

Residual contracts / verification owners: docs/operator-user-deletion-executor.md:125-131 specifies a future purge must retain removed membership rows when retaining messages; the real purge is not implemented here. Its implementer must enforce and test that invariant when it ships. The public direct-store API relies on a caller-supplied authenticated sender (channel.rs:1101-1114); the first production adopter/reviewer must bind it to authenticated identity. Neither is a new blocker for this guard move. CI owns executed Postgres proof; no author rework is requested.

@loganj
loganj merged commit 50cfc54 into main Nov 17, 2026
97 checks passed
@loganj
loganj deleted the loganj/update-channel-private-open branch November 17, 2026 16:52
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
#9581 added a `sender` argument to `update_channel`. #8320's
cross-community test landed in parallel and still calls it with three
arguments, so main's buzz-db lib tests no longer compile. Pass the channel
creator as the sender. The test only renames an open channel, so the
private-to-open rule does not apply.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
brow added a commit that referenced this pull request Nov 17, 2026
… test

#9581 added a sender parameter to Db::update_channel, but
single_table_guard_channels_remain_tenant_bound_without_trigger still
called it with three arguments, so buzz-db tests no longer compiled on
main. Pass the channel's creator; both calls only rename the channel.

Also mark the file's existing local dev database URL as test-only for
the secrets scanner, as test_support.rs already does.

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
… test call) (#9616)

## Summary

Main has two migrations numbered `0093`:

- `0093_push_gateway_installation_platform.sql` from #9560
- `0093_drop_plain_sql_functions.sql` from #9598

The file names differ, so GitHub showed no conflict between the PRs.
sqlx applies the first version-93 migration and then rejects the second
as a changed migration 93. Every migrate run on main fails, including
relay startup with auto-migration on.

This PR moves #9598's migration to `0094`:

- `git mv migrations/0093_drop_plain_sql_functions.sql
migrations/0094_drop_plain_sql_functions.sql`. The SQL is unchanged.
- `embedded_migrator_contains_consolidated_initial_schema` now expects
94 migrations, with the function drop at version 94.
- The Postgres test is renamed to
`migration_0094_drops_plain_sql_functions`. It finds the migration by
description, so its logic is unchanged.
- `docs/trigger-retirement-deployment.md` now names `0094`.

#9560's `0093` keeps its number. It reached main first and may already
be applied on deployments that auto-migrate.

## Second break on main: `update_channel` call sites

Main's buzz-db lib tests also stopped compiling. #9581 added a `sender`
argument to `update_channel`, and #8320's cross-community test
(`deletion.rs`) landed in parallel with the old three-argument call.
This PR passes the channel creator as the sender. The test only renames
an open channel, so the private-to-open rule does not apply.

## Deployments

No deployment has applied #9598's `0093`: no image built from main after
#9598 has rolled out yet. A database that applied #9560's `0093` applies
`0094` next. Do not promote any image built from `4e8f8365` (the #9598
merge) or later until this PR merges.

## What got simpler

Nothing. This is a renumber and a test call fix only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
wpfleger96 added a commit that referenced this pull request Nov 17, 2026
…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
wpfleger96 added a commit that referenced this pull request Nov 18, 2026
…c-spec-mobile

* origin/main: (37 commits)
  buzz-db: drop the five single-table guard triggers (BUZZ-318 phase 2) (#9398)
  push-gateway: lock expired installations before reaping (#9627)
  Retire the 0032 roster trigger in migration 0095 (#8696)
  fix(db): hard-delete superseded relay-signed lists (#9586)
  Add community-scoped user and agent profile cleanup (#9580)
  fix(sdk): timestamp channel messages with millisecond offsets (#9548)
  Check product_feedback's community in the writing transaction (#9608)
  buzz-db: stop calling the dropped lock-key function in SQL (#9615)
  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)
  ...

Signed-off-by: Will Pfleger <wpfleger@block.xyz>

This branch was previously deployed

1 inactive deployment
codex-review — c52412ab Deployed Nov 17, 2026 by loganj via Run Codex Security Review #15637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants