From 5595b1c647bd4238bd38526c532daadeef6f602c Mon Sep 17 00:00:00 2001 From: Tom Brow Date: Wed, 18 Nov 2026 14:02:21 -0800 Subject: [PATCH] fix(relay): refuse Solo role changes on open channels The locked Solo guard accepted any stream labelled buzz.solo, so an open channel carrying that label let the owner's kind 9050 skip the ordinary role-change policy and its notices. Require private visibility, matching the Solo definition in the mobile contract. Signed-off-by: Tom Brow --- crates/buzz-db/src/store/channel_members.rs | 1 + .../solo_member_role_postgres_tests.rs | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/crates/buzz-db/src/store/channel_members.rs b/crates/buzz-db/src/store/channel_members.rs index 3b8f6e59a4e..d732c532856 100644 --- a/crates/buzz-db/src/store/channel_members.rs +++ b/crates/buzz-db/src/store/channel_members.rs @@ -2492,6 +2492,7 @@ impl Db { let channel = get_channel_tx(tx.conn(), community, channel_id).await?; if channel.channel_type != "stream" + || channel.visibility != "private" || !channel.labels.iter().any(|label| label == "buzz.solo") { return Err(denied("channel is not a Solo chat")); diff --git a/crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs b/crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs index 79b7d09056e..2b46d4ad87a 100644 --- a/crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs +++ b/crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs @@ -245,3 +245,49 @@ async fn solo_owner_edits_active_members_and_publishes_the_new_roster() { .expect("query declined command") .is_none()); } + +#[tokio::test] +#[ignore = "requires Postgres"] +async fn solo_role_change_is_refused_on_an_open_channel() { + let state = state().await; + let tenant = community(&state, "solo-role-open-channel").await; + let [owner, own_agent] = std::array::from_fn(|_| Keys::generate()); + record_agent_owner(&state, &tenant, &own_agent, &owner).await; + let channel_id = create_channel( + &state, + &tenant, + &owner, + &[ + &["visibility", "open"], + &["t", "buzz.solo"], + &["p", &own_agent.public_key().to_hex()], + ], + ) + .await; + + let command = role_change(&owner, channel_id, &own_agent, "member", "guest"); + let command_id = command.id; + let refused = ingest_event(&state, &tenant, command, http_auth(&owner)) + .await + .err(); + assert!( + matches!(refused, Some(IngestError::Rejected(ref message)) if message.contains("channel is not a Solo chat")), + "{refused:?}" + ); + assert!(state + .db + .get_event_by_id(tenant.community(), command_id.as_bytes()) + .await + .expect("query declined command") + .is_none()); + let active_role = state + .db + .get_member_role( + tenant.community(), + channel_id, + &own_agent.public_key().to_bytes(), + ) + .await + .expect("active role"); + assert_eq!(active_role.as_deref(), Some("member")); +}