Skip to content

feat(relay): add BUZZ_AGENT_SHARING_DISABLED flag and tighten channel_add_policy default#1297

Closed
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/agent-sharing-disabled
Closed

feat(relay): add BUZZ_AGENT_SHARING_DISABLED flag and tighten channel_add_policy default#1297
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/agent-sharing-disabled

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

Summary

Addresses the security gap where any relay member could add any agent to any channel, and agents could configure themselves to respond to anyone.

Two targeted changes in one PR:

1. Migration 0005 — changes the channel_add_policy column default from 'anyone' to 'owner_only'. New agents on any relay start safe without any operator action.

2. BUZZ_AGENT_SHARING_DISABLED=true — relay-wide enforcement flag for immediate Block relay relief:

  • kind:9000 PUT_USER targeting an agent is rejected pre-storage unless the actor is the agent's registered owner. Non-agent targets are unaffected.
  • kind:10100 setting channel_add_policy = 'anyone' is blocked: the DB column is not updated (the event is stored per NIP-01 semantics, but has no effect).
  • On startup, all existing channel_add_policy = 'anyone' rows are clamped to 'owner_only'. Idempotent — runs every restart while the flag is set.

When the flag is false (default), behavior is identical to today.

Files changed

  • migrations/0005_default_channel_add_policy_owner_only.sql — new migration
  • crates/buzz-relay/src/config.rsagent_sharing_disabled field + env var parsing + 3 new tests
  • crates/buzz-relay/src/handlers/side_effects.rs — enforcement at kind:10100 and kind:9000
  • crates/buzz-relay/src/main.rs — startup clamp
  • crates/buzz-db/src/lib.rsclamp_anyone_channel_add_policy method on Db
  • crates/buzz-db/src/user.rsclamp_anyone_channel_add_policy fn + DB test
  • crates/buzz-db/src/migration.rs — migration count test updated to 4

…_add_policy default

Security: any relay member could add any agent to any channel because
channel_add_policy defaulted to 'anyone'. Two targeted fixes:

1. Migration 0005 changes the column default from 'anyone' to 'owner_only'
   so new agents start safe on all relays.

2. BUZZ_AGENT_SHARING_DISABLED=true enables relay-wide enforcement:
   - kind:9000 PUT_USER targeting an agent is rejected unless the actor
     is the agent's owner (pre-storage, returns NIP-01 NOTICE).
   - kind:10100 setting channel_add_policy='anyone' is blocked (the DB
     column is not updated; the event is stored but has no effect).
   - On startup, all existing channel_add_policy='anyone' rows are
     clamped to 'owner_only' (idempotent, runs every restart while
     the flag is set).

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>

@shellz-n-stuff shellz-n-stuff left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥

@wpfleger96

Copy link
Copy Markdown
Collaborator Author

Closing in favor of ACP harness-side enforcement per team decision. Relay should not control client behavior.

@wpfleger96 wpfleger96 closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants