Originally created by: 5dive-bot
DIVE-7972 (security pass DIVE-7963, finding [#2] and the CLI half of [#6]).
What was wrong. The shared team-bot listener runs as root and drops messages into an agent's relay-in. It passed on any message that was not from a bot and whose thread id matched an agent's topic. Nothing checked the chat or the sender. So anyone in the team group, or anyone who added the team bot to their own supergroup and posted in a thread with a matching (small) number, could talk to an agent with sudo as if they were its owner.
What changed.
src/cmd_agent_teambot.sh, the embedded listener: teamSenderAllowed() drops a message unless the chat is the team group this topic was registered in (teamTopic.chatId) AND the sender is on the agent's allowFrom for that group (falling back to the agent's own allowFrom). No list at all means nobody gets through. Each drop is logged with its reason. The check runs before the rate limit and before the drop into relay-in. The telegram plugin (5dive-plugins, same branch) runs the same check again in its relay drain.src/cmd_agent_pairing.sh: telegram-access groups --answer=name|every now stores groupsOwnerOnly: false (groups opened on purpose) instead of removing the key. With the key absent, telegram 0.5.138 lets a new group in with its owners only. Leaving that default for name/every also opens a group the default closed.Checked (worktree, at this head):
bash tests/team_bot_sender_gate_unit.sh: 11 pass, 0 fail. Covers: the owner gets through; a stranger in the team group is refused; a foreign supergroup with the same thread id is refused, even for the owner's id; no lane chat or no allowFrom is refused (fail closed); fallback to the agent's own allowFrom; the loop order is checked; the listener still transpiles; a MUTANT with the chat check removed lets the foreign group through, which shows the foreign-group arm catches it.bash tests/telegram_access_groups_unit.sh: 65 pass, 0 fail (two arms updated, one added for the absent-key case).Residual: a box whose team bot was set up with no --owner and whose agent was never paired now drops all team-group messages until team-bot shared --owner=<id> is re-run. That is the fail-closed choice the row asked for.
🤖 Generated with Claude Code
Ticket changed by: lodar